All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolai Stange <nstange@suse.de>
To: speck@linutronix.de
Subject: [MODERATED] [RFC PATCH 3/6] kvm: handle host mode irqs 3
Date: Sat, 21 Jul 2018 22:35:28 +0200	[thread overview]
Message-ID: <a75d6fb6638093b8f7e7bc15f60430aa32d5a000.1532339695.git.nstange@suse.de> (raw)
In-Reply-To: <cover.1532339695.git.nstange@suse.de>

Currently, vmx_vcpu_run() checks if ->l1tf_flush_l1d is set and invokes
vmx_l1d_flush() if so.

This test is unncessary for the "always flush L1d" mode.

Move the check to vmx_l1d_flush()'s conditional mode code path.

Notes:
- vmx_l1d_flush() is likely to get inlined anyway and thus, there's no
  extra function call.
- This change inverts the (static) branch prediction, but there hadn't been
  any explicit likely()/unlikely() annotations before and so I decided
  to leave it as is.

Signed-off-by: Nicolai Stange <nstange@suse.de>
---
 arch/x86/kvm/vmx.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 5139738cc5a9..ec955b870756 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -9693,12 +9693,16 @@ static void vmx_l1d_flush(struct kvm_vcpu *vcpu)
 	 * 'always'
 	 */
 	if (static_branch_likely(&vmx_l1d_flush_cond)) {
+		bool flush_l1d = vcpu->arch.l1tf_flush_l1d;
+
 		/*
 		 * Clear the flush bit, it gets set again either from
 		 * vcpu_run() or from one of the unsafe VMEXIT
 		 * handlers.
 		 */
 		vcpu->arch.l1tf_flush_l1d = false;
+		if (!flush_l1d)
+			return;
 	}
 
 	vcpu->stat.l1d_flush++;
@@ -10228,10 +10232,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 	evmcs_rsp = static_branch_unlikely(&enable_evmcs) ?
 		(unsigned long)&current_evmcs->host_rsp : 0;
 
-	if (static_branch_unlikely(&vmx_l1d_should_flush)) {
-		if (vcpu->arch.l1tf_flush_l1d)
-			vmx_l1d_flush(vcpu);
-	}
+	if (static_branch_unlikely(&vmx_l1d_should_flush))
+		vmx_l1d_flush(vcpu);
 
 	asm(
 		/* Store host registers */
-- 
2.13.7

  parent reply	other threads:[~2018-07-23 10:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23  9:54 [MODERATED] [RFC PATCH 0/6] kvm: handle host mode irqs 0 Nicolai Stange
2018-07-21 20:16 ` [MODERATED] [RFC PATCH 1/6] kvm: handle host mode irqs 1 Nicolai Stange
2018-07-21 20:25 ` [MODERATED] [RFC PATCH 2/6] kvm: handle host mode irqs 2 Nicolai Stange
2018-07-21 20:35 ` Nicolai Stange [this message]
2018-07-22  9:35 ` [MODERATED] [RFC PATCH 4/6] kvm: handle host mode irqs 4 Nicolai Stange
2018-07-23 15:40   ` [MODERATED] " Andi Kleen
2018-07-24  5:58     ` Nicolai Stange
2018-07-24 14:12       ` Andi Kleen
2018-07-24 14:39         ` Paolo Bonzini
2018-07-24 15:21   ` Peter Zijlstra
2018-07-25 11:45     ` Nicolai Stange
2018-07-27  7:45       ` Peter Zijlstra
2018-07-27  9:17         ` Nicolai Stange
2018-07-27  9:55           ` Paolo Bonzini
2018-07-29 20:00             ` Nicolai Stange
2018-07-22 11:06 ` [MODERATED] [RFC PATCH 5/6] kvm: handle host mode irqs 5 Nicolai Stange
2018-07-22 11:38 ` [MODERATED] [RFC PATCH 6/6] kvm: handle host mode irqs 6 Nicolai Stange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a75d6fb6638093b8f7e7bc15f60430aa32d5a000.1532339695.git.nstange@suse.de \
    --to=nstange@suse.de \
    --cc=speck@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.