All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] vmx_vcpu_run micro-optimizations
@ 2011-01-06 16:09 Avi Kivity
  2011-01-06 16:09 ` [PATCH 1/2] KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run Avi Kivity
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Avi Kivity @ 2011-01-06 16:09 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm

A couple of minor optimizations to the vmx_vcpu_run assembly code.

Avi Kivity (2):
  KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run
  KVM: VMX: Avoid atomic operation in vmx_vcpu_run

 arch/x86/kvm/vmx.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run
  2011-01-06 16:09 [PATCH 0/2] vmx_vcpu_run micro-optimizations Avi Kivity
@ 2011-01-06 16:09 ` Avi Kivity
  2011-01-06 16:09 ` [PATCH 2/2] KVM: VMX: Avoid atomic operation " Avi Kivity
  2011-01-18 13:49 ` [PATCH 0/2] vmx_vcpu_run micro-optimizations Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2011-01-06 16:09 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm

Change

  push top-of-stack
  pop guest-rcx
  pop dummy

to

  pop guest-rcx

which is the same thing, only simpler.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/vmx.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index bf89ec2..0d56fe0 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4035,7 +4035,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 		"xchg %0,     (%%"R"sp) \n\t"
 		"mov %%"R"ax, %c[rax](%0) \n\t"
 		"mov %%"R"bx, %c[rbx](%0) \n\t"
-		"push"Q" (%%"R"sp); pop"Q" %c[rcx](%0) \n\t"
+		"pop"Q" %c[rcx](%0) \n\t"
 		"mov %%"R"dx, %c[rdx](%0) \n\t"
 		"mov %%"R"si, %c[rsi](%0) \n\t"
 		"mov %%"R"di, %c[rdi](%0) \n\t"
@@ -4053,7 +4053,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 		"mov %%cr2, %%"R"ax   \n\t"
 		"mov %%"R"ax, %c[cr2](%0) \n\t"
 
-		"pop  %%"R"bp; pop  %%"R"bp; pop  %%"R"dx \n\t"
+		"pop  %%"R"bp; pop  %%"R"dx \n\t"
 		"setbe %c[fail](%0) \n\t"
 	      : : "c"(vmx), "d"((unsigned long)HOST_RSP),
 		[launched]"i"(offsetof(struct vcpu_vmx, launched)),
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] KVM: VMX: Avoid atomic operation in vmx_vcpu_run
  2011-01-06 16:09 [PATCH 0/2] vmx_vcpu_run micro-optimizations Avi Kivity
  2011-01-06 16:09 ` [PATCH 1/2] KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run Avi Kivity
@ 2011-01-06 16:09 ` Avi Kivity
  2011-01-18 13:49 ` [PATCH 0/2] vmx_vcpu_run micro-optimizations Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2011-01-06 16:09 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm

Instead of exchanging the guest and host rcx, have separate storage
for each.  This allows us to avoid using the xchg instruction, which
is is a little slower than normal operations.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/vmx.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0d56fe0..d9fd4e6 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3991,6 +3991,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 	asm(
 		/* Store host registers */
 		"push %%"R"dx; push %%"R"bp;"
+		"push %%"R"cx \n\t" /* placeholder for guest rcx */
 		"push %%"R"cx \n\t"
 		"cmp %%"R"sp, %c[host_rsp](%0) \n\t"
 		"je 1f \n\t"
@@ -4032,7 +4033,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 		".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
 		".Lkvm_vmx_return: "
 		/* Save guest registers, load host registers, keep flags */
-		"xchg %0,     (%%"R"sp) \n\t"
+		"mov %0, %c[wordsize](%%"R"sp) \n\t"
+		"pop %0 \n\t"
 		"mov %%"R"ax, %c[rax](%0) \n\t"
 		"mov %%"R"bx, %c[rbx](%0) \n\t"
 		"pop"Q" %c[rcx](%0) \n\t"
@@ -4076,7 +4078,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
 		[r14]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_R14])),
 		[r15]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_R15])),
 #endif
-		[cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2))
+		[cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
+		[wordsize]"i"(sizeof(ulong))
 	      : "cc", "memory"
 		, R"ax", R"bx", R"di", R"si"
 #ifdef CONFIG_X86_64
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] vmx_vcpu_run micro-optimizations
  2011-01-06 16:09 [PATCH 0/2] vmx_vcpu_run micro-optimizations Avi Kivity
  2011-01-06 16:09 ` [PATCH 1/2] KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run Avi Kivity
  2011-01-06 16:09 ` [PATCH 2/2] KVM: VMX: Avoid atomic operation " Avi Kivity
@ 2011-01-18 13:49 ` Marcelo Tosatti
  2 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2011-01-18 13:49 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On Thu, Jan 06, 2011 at 06:09:10PM +0200, Avi Kivity wrote:
> A couple of minor optimizations to the vmx_vcpu_run assembly code.
> 
> Avi Kivity (2):
>   KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run
>   KVM: VMX: Avoid atomic operation in vmx_vcpu_run
> 
>  arch/x86/kvm/vmx.c |   11 +++++++----
>  1 files changed, 7 insertions(+), 4 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-18 14:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-06 16:09 [PATCH 0/2] vmx_vcpu_run micro-optimizations Avi Kivity
2011-01-06 16:09 ` [PATCH 1/2] KVM: VMX: Simplify saving guest rcx in vmx_vcpu_run Avi Kivity
2011-01-06 16:09 ` [PATCH 2/2] KVM: VMX: Avoid atomic operation " Avi Kivity
2011-01-18 13:49 ` [PATCH 0/2] vmx_vcpu_run micro-optimizations Marcelo Tosatti

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.