From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roman Kagan Subject: [PATCH v2 5/5] kvm/svm: kick L2 guest to L1 by ready async_pf Date: Mon, 12 Dec 2016 17:32:25 +0300 Message-ID: <20161212143225.10580-6-rkagan@virtuozzo.com> References: <20161212143225.10580-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-ve1eur01on0099.outbound.protection.outlook.com ([104.47.1.99]:46485 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753369AbcLMCFR (ORCPT ); Mon, 12 Dec 2016 21:05:17 -0500 In-Reply-To: <20161212143225.10580-1-rkagan@virtuozzo.com> Sender: kvm-owner@vger.kernel.org List-ID: When async pagefault is resolved vCPU may be executing L2 guest. In order to allow L1 take better scheduling decisions in such cases, make L2 exit to L1 on a fake external interupt, without actually injecting it (unless L2 has other reasons to vmexit). This patch does that for x86/AMD. Signed-off-by: Roman Kagan --- arch/x86/kvm/svm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 8ca1eca..1f6ae15 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -3723,6 +3723,15 @@ static int mwait_interception(struct vcpu_svm *svm) return nop_interception(svm); } +static int svm_check_nested_events(struct kvm_vcpu *vcpu, bool external_intr) +{ + struct vcpu_svm *svm = to_svm(vcpu); + + if (kvm_async_pf_has_ready(vcpu)) + nested_svm_intr(svm); + return 0; +} + enum avic_ipi_failure_cause { AVIC_IPI_FAILURE_INVALID_INT_TYPE, AVIC_IPI_FAILURE_TARGET_NOT_RUNNING, @@ -5406,6 +5415,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { .check_intercept = svm_check_intercept, .handle_external_intr = svm_handle_external_intr, + .check_nested_events = svm_check_nested_events, .sched_in = svm_sched_in, -- 2.9.3