From: Wanpeng Li <wanpeng.li@linux.intel.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
Gleb Natapov <gleb@kernel.org>
Subject: Re: [PATCH] x86, kvm, vmx: Always use LOAD_IA32_EFER if available
Date: Mon, 10 Nov 2014 12:33:50 +0800 [thread overview]
Message-ID: <20141110043350.GA3773@kernel> (raw)
In-Reply-To: <32d96cddbe65b897151b95a0e0f8326e404646f8.1415413387.git.luto@amacapital.net>
Hi Andy,
On Fri, Nov 07, 2014 at 06:25:18PM -0800, Andy Lutomirski wrote:
>At least on Sandy Bridge, letting the CPU switch IA32_EFER is much
>faster than switching it manually.
>
>I benchmarked this using the vmexit kvm-unit-test (single run, but
>GOAL multiplied by 5 to do more iterations):
>
>Test Before After Change
>cpuid 2000 1932 -3.40%
>vmcall 1914 1817 -5.07%
>mov_from_cr8 13 13 0.00%
>mov_to_cr8 19 19 0.00%
>inl_from_pmtimer 19164 10619 -44.59%
>inl_from_qemu 15662 10302 -34.22%
What's the difference of IA32_EFER between guest and host in your config?
IIUC,
- NX is not consistent
IA32_EFER will be auto load w/ and w/o the patch.
- SCE is not consistent
IA32_EFER will be switched through wrmsr(urn) w/o the patch, and auto load
w/ the patch.
Regards,
Wanpeng Li
>inl_from_kernel 3916 3802 -2.91%
>outl_to_kernel 2230 2194 -1.61%
>mov_dr 172 176 2.33%
>ipi (skipped) (skipped)
>ipi+halt (skipped) (skipped)
>ple-round-robin 13 13 0.00%
>wr_tsc_adjust_msr 1920 1845 -3.91%
>rd_tsc_adjust_msr 1892 1814 -4.12%
>mmio-no-eventfd:pci-mem 16394 11165 -31.90%
>mmio-wildcard-eventfd:pci-mem 4607 4645 0.82%
>mmio-datamatch-eventfd:pci-mem 4601 4610 0.20%
>portio-no-eventfd:pci-io 11507 7942 -30.98%
>portio-wildcard-eventfd:pci-io 2239 2225 -0.63%
>portio-datamatch-eventfd:pci-io 2250 2234 -0.71%
>
>I haven't explicitly computed the significance of these numbers,
>but this isn't subtle.
>
>Signed-off-by: Andy Lutomirski <luto@amacapital.net>
>---
> arch/x86/kvm/vmx.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>index 3e556c68351b..e72b9660e51c 100644
>--- a/arch/x86/kvm/vmx.c
>+++ b/arch/x86/kvm/vmx.c
>@@ -1659,8 +1659,14 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
> vmx->guest_msrs[efer_offset].mask = ~ignore_bits;
>
> clear_atomic_switch_msr(vmx, MSR_EFER);
>- /* On ept, can't emulate nx, and must switch nx atomically */
>- if (enable_ept && ((vmx->vcpu.arch.efer ^ host_efer) & EFER_NX)) {
>+
>+ /*
>+ * On EPT, we can't emulate NX, so we must switch EFER atomically.
>+ * On CPUs that support "load IA32_EFER", always switch EFER
>+ * atomically, since it's faster than switching it manually.
>+ */
>+ if (cpu_has_load_ia32_efer ||
>+ (enable_ept && ((vmx->vcpu.arch.efer ^ host_efer) & EFER_NX))) {
> guest_efer = vmx->vcpu.arch.efer;
> if (!(guest_efer & EFER_LMA))
> guest_efer &= ~EFER_LME;
>--
>1.9.3
>
>--
>To unsubscribe from this list: send the line "unsubscribe kvm" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-11-10 4:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-08 2:25 [PATCH] x86, kvm, vmx: Always use LOAD_IA32_EFER if available Andy Lutomirski
2014-11-10 4:33 ` Wanpeng Li [this message]
2014-11-10 19:31 ` Andy Lutomirski
2014-11-12 11:38 ` Paolo Bonzini
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=20141110043350.GA3773@kernel \
--to=wanpeng.li@linux.intel.com \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=pbonzini@redhat.com \
/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.