All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] KVM: LAPIC: Optimize timer latency further
@ 2019-05-16  3:06 Wanpeng Li
  2019-05-16  3:06 ` [PATCH v3 1/5] KVM: LAPIC: Extract adaptive tune timer advancement logic Wanpeng Li
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Wanpeng Li @ 2019-05-16  3:06 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Paolo Bonzini, Radim Krčmář

Advance lapic timer tries to hidden the hypervisor overhead between the 
host emulated timer fires and the guest awares the timer is fired. However, 
it just hidden the time between apic_timer_fn/handle_preemption_timer -> 
wait_lapic_expire, instead of the real position of vmentry which is 
mentioned in the orignial commit d0659d946be0 ("KVM: x86: add option to 
advance tscdeadline hrtimer expiration"). There is 700+ cpu cycles between 
the end of wait_lapic_expire and before world switch on my haswell desktop.

This patchset tries to narrow the last gap(wait_lapic_expire -> world switch), 
it takes the real overhead time between apic_timer_fn/handle_preemption_timer
and before world switch into consideration when adaptively tuning timer 
advancement. The patchset can reduce 40% latency (~1600+ cycles to ~1000+ 
cycles on a haswell desktop) for kvm-unit-tests/tscdeadline_latency when 
testing busy waits.

v2 -> v3:
 * expose 'kvm_timer.timer_advance_ns' to userspace
 * move the tracepoint below guest_exit_irqoff()
 * move wait_lapic_expire() before flushing the L1

v1 -> v2:
 * fix indent in patch 1/4
 * remove the wait_lapic_expire() tracepoint and expose by debugfs
 * move the call to wait_lapic_expire() into vmx.c and svm.c

Wanpeng Li (5):
  KVM: LAPIC: Extract adaptive tune timer advancement logic
  KVM: LAPIC: Fix lapic_timer_advance_ns parameter overflow
  KVM: LAPIC: Expose per-vCPU timer_advance_ns to userspace
  KVM: LAPIC: Delay trace advance expire delta
  KVM: LAPIC: Optimize timer latency further

 arch/x86/kvm/debugfs.c | 16 +++++++++++++
 arch/x86/kvm/lapic.c   | 62 +++++++++++++++++++++++++++++---------------------
 arch/x86/kvm/lapic.h   |  3 ++-
 arch/x86/kvm/svm.c     |  4 ++++
 arch/x86/kvm/vmx/vmx.c |  4 ++++
 arch/x86/kvm/x86.c     |  7 +++---
 6 files changed, 65 insertions(+), 31 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH v3 0/5] KVM: LAPIC: Optimize timer latency further
@ 2019-06-12  9:35 Wanpeng Li
  2019-06-12  9:35 ` [PATCH v3 4/5] KVM: LAPIC: Delay trace advance expire delta Wanpeng Li
  0 siblings, 1 reply; 15+ messages in thread
From: Wanpeng Li @ 2019-06-12  9:35 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Paolo Bonzini, Radim Krčmář

Advance lapic timer tries to hidden the hypervisor overhead between the 
host emulated timer fires and the guest awares the timer is fired. However, 
it just hidden the time between apic_timer_fn/handle_preemption_timer -> 
wait_lapic_expire, instead of the real position of vmentry which is 
mentioned in the orignial commit d0659d946be0 ("KVM: x86: add option to 
advance tscdeadline hrtimer expiration"). There is 700+ cpu cycles between 
the end of wait_lapic_expire and before world switch on my haswell desktop.

This patchset tries to narrow the last gap(wait_lapic_expire -> world switch), 
it takes the real overhead time between apic_timer_fn/handle_preemption_timer
and before world switch into consideration when adaptively tuning timer 
advancement. The patchset can reduce 40% latency (~1600+ cycles to ~1000+ 
cycles on a haswell desktop) for kvm-unit-tests/tscdeadline_latency when 
testing busy waits.

v2 -> v3:
 * expose 'kvm_timer.timer_advance_ns' to userspace
 * move the tracepoint below guest_exit_irqoff()
 * move wait_lapic_expire() before flushing the L1

v1 -> v2:
 * fix indent in patch 1/4
 * remove the wait_lapic_expire() tracepoint and expose by debugfs
 * move the call to wait_lapic_expire() into vmx.c and svm.c

Wanpeng Li (5):
  KVM: LAPIC: Extract adaptive tune timer advancement logic
  KVM: LAPIC: Fix lapic_timer_advance_ns parameter overflow
  KVM: LAPIC: Expose per-vCPU timer_advance_ns to userspace
  KVM: LAPIC: Delay trace advance expire delta
  KVM: LAPIC: Optimize timer latency further

 arch/x86/kvm/debugfs.c | 16 +++++++++++++
 arch/x86/kvm/lapic.c   | 62 +++++++++++++++++++++++++++++---------------------
 arch/x86/kvm/lapic.h   |  3 ++-
 arch/x86/kvm/svm.c     |  4 ++++
 arch/x86/kvm/vmx/vmx.c |  4 ++++
 arch/x86/kvm/x86.c     |  7 +++---
 6 files changed, 65 insertions(+), 31 deletions(-)

-- 
2.7.4


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

end of thread, other threads:[~2019-06-12  9:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16  3:06 [PATCH v3 0/5] KVM: LAPIC: Optimize timer latency further Wanpeng Li
2019-05-16  3:06 ` [PATCH v3 1/5] KVM: LAPIC: Extract adaptive tune timer advancement logic Wanpeng Li
2019-05-16  3:06 ` [PATCH v3 2/5] KVM: LAPIC: Fix lapic_timer_advance_ns parameter overflow Wanpeng Li
2019-05-16  3:06 ` [PATCH v3 3/5] KVM: LAPIC: Expose per-vCPU timer_advance_ns to userspace Wanpeng Li
2019-05-17 20:05   ` Sean Christopherson
2019-05-20  8:43     ` Wanpeng Li
2019-05-16  3:06 ` [PATCH v3 4/5] KVM: LAPIC: Delay trace advance expire delta Wanpeng Li
2019-05-17 19:44   ` Sean Christopherson
2019-05-20  6:38     ` Wanpeng Li
2019-05-20 14:56       ` Sean Christopherson
2019-05-16  3:06 ` [PATCH v3 5/5] KVM: LAPIC: Optimize timer latency further Wanpeng Li
2019-05-17 19:50   ` Sean Christopherson
2019-05-20  8:19     ` Wanpeng Li
2019-05-20 15:08       ` Sean Christopherson
2019-06-12  9:35 [PATCH v3 0/5] " Wanpeng Li
2019-06-12  9:35 ` [PATCH v3 4/5] KVM: LAPIC: Delay trace advance expire delta Wanpeng Li

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.