From: Roman Kagan Subject: [PATCH 3/5] kvm: kick vcpu when async_pf is resolved Date: Fri, 2 Dec 2016 11:47:52 +0300 Message-ID: <20161202084754.22860-4-rkagan@virtuozzo.com> References: <20161202084754.22860-1-rkagan@virtuozzo.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Denis Lunev , Roman Kagan To: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini , Return-path: Received: from mail-db5eur01on0119.outbound.protection.outlook.com ([104.47.2.119]:32352 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758386AbcLBIsS (ORCPT ); Fri, 2 Dec 2016 03:48:18 -0500 In-Reply-To: <20161202084754.22860-1-rkagan@virtuozzo.com> Sender: kvm-owner@vger.kernel.org List-ID: When async_pf is ready the guest needs to be made aware of it ASAP, because it may be holding off a higher priority task pending the async_pf resolution in favor of a lower priority one. In case async_pf's are harvested in vcpu context (x86) we have to not only wake the vcpu up but kick it into host. While at this, also replace the open-coded vcpu wakeup by the existing helper. Signed-off-by: Roman Kagan --- virt/kvm/async_pf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index 9cced14..5f0a66c 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -105,8 +105,11 @@ static void async_pf_execute(struct work_struct *work) * This memory barrier pairs with prepare_to_wait's set_current_state() */ smp_mb(); - if (swait_active(&vcpu->wq)) - swake_up(&vcpu->wq); +#ifdef CONFIG_KVM_ASYNC_PF_SYNC + kvm_vcpu_wake_up(vcpu); +#else + kvm_vcpu_kick(vcpu); +#endif mmput(mm); kvm_put_kvm(vcpu->kvm); -- 2.9.3