diff mbox

[v3,5/5] KVM: nVMX: Optimization: Dont set KVM_REQ_EVENT when VMExit with nested_run_pending

Message ID 1521763294-7061-6-git-send-email-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liran Alon March 23, 2018, 12:01 a.m. UTC
When vCPU runs L2 and there is a pending event that requires to exit
from L2 to L1 and nested_run_pending=1, vcpu_enter_guest() will request
an immediate-exit from L2 (See req_immediate_exit).

Since now handling of req_immediate_exit also makes sure to set
KVM_REQ_EVENT, there is no need to also set it on vmx_vcpu_run() when
nested_run_pending=1.

This optimizes cases where VMRESUME was executed by L1 to enter L2 and
there is no pending events that require exit from L2 to L1. Previously,
this would have set KVM_REQ_EVENT unnecessarly.

Signed-off-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/kvm/vmx.c | 8 --------
 1 file changed, 8 deletions(-)

Comments

Jim Mattson March 23, 2018, 4:29 p.m. UTC | #1
On Thu, Mar 22, 2018 at 5:01 PM, Liran Alon <liran.alon@oracle.com> wrote:
> When vCPU runs L2 and there is a pending event that requires to exit
> from L2 to L1 and nested_run_pending=1, vcpu_enter_guest() will request
> an immediate-exit from L2 (See req_immediate_exit).
>
> Since now handling of req_immediate_exit also makes sure to set
> KVM_REQ_EVENT, there is no need to also set it on vmx_vcpu_run() when
> nested_run_pending=1.
>
> This optimizes cases where VMRESUME was executed by L1 to enter L2 and
> there is no pending events that require exit from L2 to L1. Previously,
> this would have set KVM_REQ_EVENT unnecessarly.
>
> Signed-off-by: Liran Alon <liran.alon@oracle.com>
> Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Reviewed-by: Jim Mattson <jmattson@google.com>
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c1fad906281d..4c2a4303b479 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -9647,14 +9647,6 @@  static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 			__write_pkru(vmx->host_pkru);
 	}
 
-	/*
-	 * the KVM_REQ_EVENT optimization bit is only on for one entry, and if
-	 * we did not inject a still-pending event to L1 now because of
-	 * nested_run_pending, we need to re-enable this bit.
-	 */
-	if (vmx->nested.nested_run_pending)
-		kvm_make_request(KVM_REQ_EVENT, vcpu);
-
 	vmx->nested.nested_run_pending = 0;
 	vmx->idt_vectoring_info = 0;