From: tip-bot for Paolo Bonzini <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: rkrcmar@redhat.com, peterz@infradead.org, jmattson@google.com,
dwmw@amazon.co.uk, linux-kernel@vger.kernel.org, hpa@zytor.com,
torvalds@linux-foundation.org, karahmed@amazon.de,
pbonzini@redhat.com, tglx@linutronix.de, mingo@kernel.org
Subject: [tip:x86/pti] KVM/VMX: Optimize vmx_vcpu_run() and svm_vcpu_run() by marking the RDMSR path as unlikely()
Date: Fri, 23 Feb 2018 00:26:59 -0800 [thread overview]
Message-ID: <tip-946fbbc13dce68902f64515b610eeb2a6c3d7a64@git.kernel.org> (raw)
In-Reply-To: <20180222154318.20361-3-pbonzini@redhat.com>
Commit-ID: 946fbbc13dce68902f64515b610eeb2a6c3d7a64
Gitweb: https://git.kernel.org/tip/946fbbc13dce68902f64515b610eeb2a6c3d7a64
Author: Paolo Bonzini <pbonzini@redhat.com>
AuthorDate: Thu, 22 Feb 2018 16:43:18 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 23 Feb 2018 08:24:36 +0100
KVM/VMX: Optimize vmx_vcpu_run() and svm_vcpu_run() by marking the RDMSR path as unlikely()
vmx_vcpu_run() and svm_vcpu_run() are large functions, and giving
branch hints to the compiler can actually make a substantial cycle
difference by keeping the fast path contiguous in memory.
With this optimization, the retpoline-guest/retpoline-host case is
about 50 cycles faster.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: KarimAllah Ahmed <karahmed@amazon.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kvm@vger.kernel.org
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20180222154318.20361-3-pbonzini@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kvm/svm.c | 2 +-
arch/x86/kvm/vmx.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1598beeda11c..24c9521ebc24 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -5465,7 +5465,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
* If the L02 MSR bitmap does not intercept the MSR, then we need to
* save it.
*/
- if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL))
+ if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)))
svm->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
if (svm->spec_ctrl)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0927be315965..7f8401d05939 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -9588,7 +9588,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
* If the L02 MSR bitmap does not intercept the MSR, then we need to
* save it.
*/
- if (!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL))
+ if (unlikely(!msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL)))
vmx->spec_ctrl = native_read_msr(MSR_IA32_SPEC_CTRL);
if (vmx->spec_ctrl)
next prev parent reply other threads:[~2018-02-23 8:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 15:43 [PATCH v2 0/2] x86/pti: KVM: fixes and optimizations for IBRS Paolo Bonzini
2018-02-22 15:43 ` [PATCH v2 1/2] KVM: x86: use native MSR ops for SPEC_CTRL Paolo Bonzini
2018-02-23 8:26 ` [tip:x86/pti] KVM/x86: Remove indirect MSR op calls from SPEC_CTRL tip-bot for Paolo Bonzini
2018-02-22 15:43 ` [PATCH v2 2/2] KVM: VMX: mark RDMSR path as unlikely Paolo Bonzini
2018-02-23 8:26 ` tip-bot for Paolo Bonzini [this message]
2018-02-23 7:26 ` [PATCH v2 0/2] x86/pti: KVM: fixes and optimizations for IBRS Ingo Molnar
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=tip-946fbbc13dce68902f64515b610eeb2a6c3d7a64@git.kernel.org \
--to=tipbot@zytor.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=karahmed@amazon.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome