mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled
@ 2017-12-01  8:15 Wanpeng Li
  2017-12-01  8:35 ` Paolo Bonzini
  2017-12-12 14:00 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Wanpeng Li @ 2017-12-01  8:15 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Paolo Bonzini, Radim Krčmář, Wanpeng Li

When I run ebizzy in a 32 vCPUs guest on a 32 pCPUs Xeon box, I can observe 
~8000 kvm_wait_lapic_expire CurAvg/s through kvm_stat tool even if the advance 
tscdeadline hrtimer expiration is disabled. Each call to wait_lapic_expire() 
will consume ~70 cycles when a timer fires since apic_timer_expire() will 
set expired_tscdeadline and then wait_lapic_expire() will do some caculation 
before bailing out. So total ~175us per second is lost on this 3.2Ghz machine. 
This patch reduces the overhead by skipping the function wait_lapic_expire() 
when lapic_timer_advance is disabled.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
 arch/x86/kvm/x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 50c8361..d1abf13 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6994,7 +6994,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 	}
 
 	trace_kvm_entry(vcpu->vcpu_id);
-	wait_lapic_expire(vcpu);
+	if (lapic_timer_advance_ns)
+		wait_lapic_expire(vcpu);
 	guest_enter_irqoff();
 
 	if (unlikely(vcpu->arch.switch_db_regs)) {
-- 
2.7.4

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

* Re: [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled
  2017-12-01  8:15 [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled Wanpeng Li
@ 2017-12-01  8:35 ` Paolo Bonzini
  2017-12-12 14:00 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2017-12-01  8:35 UTC (permalink / raw)
  To: Wanpeng Li, linux-kernel, kvm; +Cc: Radim Krčmář, Wanpeng Li

On 01/12/2017 09:15, Wanpeng Li wrote:
> When I run ebizzy in a 32 vCPUs guest on a 32 pCPUs Xeon box, I can observe 
> ~8000 kvm_wait_lapic_expire CurAvg/s through kvm_stat tool even if the advance 
> tscdeadline hrtimer expiration is disabled. Each call to wait_lapic_expire() 
> will consume ~70 cycles when a timer fires since apic_timer_expire() will 
> set expired_tscdeadline and then wait_lapic_expire() will do some caculation 
> before bailing out. So total ~175us per second is lost on this 3.2Ghz machine. 
> This patch reduces the overhead by skipping the function wait_lapic_expire() 
> when lapic_timer_advance is disabled.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
>  arch/x86/kvm/x86.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 50c8361..d1abf13 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6994,7 +6994,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>  	}
>  
>  	trace_kvm_entry(vcpu->vcpu_id);
> -	wait_lapic_expire(vcpu);
> +	if (lapic_timer_advance_ns)
> +		wait_lapic_expire(vcpu);
>  	guest_enter_irqoff();
>  
>  	if (unlikely(vcpu->arch.switch_db_regs)) {
> 

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

* Re: [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled
  2017-12-01  8:15 [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled Wanpeng Li
  2017-12-01  8:35 ` Paolo Bonzini
@ 2017-12-12 14:00 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2017-12-12 14:00 UTC (permalink / raw)
  To: Wanpeng Li, linux-kernel, kvm; +Cc: Radim Krčmář, Wanpeng Li

On 01/12/2017 09:15, Wanpeng Li wrote:
> When I run ebizzy in a 32 vCPUs guest on a 32 pCPUs Xeon box, I can observe 
> ~8000 kvm_wait_lapic_expire CurAvg/s through kvm_stat tool even if the advance 
> tscdeadline hrtimer expiration is disabled. Each call to wait_lapic_expire() 
> will consume ~70 cycles when a timer fires since apic_timer_expire() will 
> set expired_tscdeadline and then wait_lapic_expire() will do some caculation 
> before bailing out. So total ~175us per second is lost on this 3.2Ghz machine. 
> This patch reduces the overhead by skipping the function wait_lapic_expire() 
> when lapic_timer_advance is disabled.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
>  arch/x86/kvm/x86.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 50c8361..d1abf13 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6994,7 +6994,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>  	}
>  
>  	trace_kvm_entry(vcpu->vcpu_id);
> -	wait_lapic_expire(vcpu);
> +	if (lapic_timer_advance_ns)
> +		wait_lapic_expire(vcpu);
>  	guest_enter_irqoff();
>  
>  	if (unlikely(vcpu->arch.switch_db_regs)) {
> 

Queued, thanks.

Paolo

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

end of thread, other threads:[~2017-12-12 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-01  8:15 [PATCH] KVM: X86: Reduce the overhead when lapic_timer_advance is disabled Wanpeng Li
2017-12-01  8:35 ` Paolo Bonzini
2017-12-12 14:00 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®