[PATCH v2 0/3] KVM: LAPIC: Implement Exitless Timer

From: Wanpeng Li
Date: Thu Jun 06 2019 - 01:35:37 EST


Dedicated instances are currently disturbed by unnecessary jitter due
to the emulated lapic timers fire on the same pCPUs which vCPUs resident.
There is no hardware virtual timer on Intel for guest like ARM. Both
programming timer in guest and the emulated timer fires incur vmexits.
This patchset tries to avoid vmexit which is incurred by the emulated
timer fires in dedicated instance scenario.

When nohz_full is enabled in dedicated instances scenario, the unpinned
timer will be moved to the nearest busy housekeepers after commit 444969223c8
("sched/nohz: Fix affine unpinned timers mess"). However, KVM always makes
lapic timer pinned to the pCPU which vCPU residents, the reason is explained
by commit 61abdbe0 (kvm: x86: make lapic hrtimer pinned). Actually, these
emulated timers can be offload to the housekeeping cpus since APICv
is really common in recent years. The guest timer interrupt is injected by
posted-interrupt which is delivered by housekeeping cpu once the emulated
timer fires.

The host admin should fine tuned, e.g. dedicated instances scenario w/
nohz_full cover the pCPUs which vCPUs resident, several pCPUs surplus
for housekeeping, disable mwait/hlt/pause vmexits to occupy the pCPUs,
fortunately preemption timer is disabled after mwait is exposed to
guest which makes emulated timer offload can be possible.
3%~5% redis performance benefit can be observed on Skylake server.

v1 -> v2:
* check vcpu_halt_in_guest
* move module parameter from kvm-intel to kvm
* add housekeeping_enabled
* rename apic_timer_expired_pi to kvm_apic_inject_pending_timer_irqs

Wanpeng Li (3):
KVM: LAPIC: Make lapic timer unpinned when timer is injected by
posted-interrupt
KVM: LAPIC: lapic timer interrupt is injected by posted interrupt
KVM: LAPIC: Ignore timer migration when lapic timer is injected by
posted-interrupt

arch/x86/kvm/lapic.c | 55 ++++++++++++++++++++++++++++++++---------
arch/x86/kvm/x86.c | 5 ++++
arch/x86/kvm/x86.h | 7 ++++++
include/linux/sched/isolation.h | 2 ++
kernel/sched/isolation.c | 6 +++++
5 files changed, 63 insertions(+), 12 deletions(-)

--
2.7.4