KVM: LAPIC: Recalculate apic map in batch
authorWanpeng Li <wanpengli@tencent.com>
Wed, 26 Feb 2020 02:41:02 +0000 (10:41 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 16 Mar 2020 16:57:39 +0000 (17:57 +0100)
commit4abaffce4d25aa41392d2e81835592726d757857
tree320b25cf896492063edcab40c3173e7a3e967bfb
parent49f933d445b611a237a4687ec7135b57b6b2cfba
KVM: LAPIC: Recalculate apic map in batch

In the vCPU reset and set APIC_BASE MSR path, the apic map will be recalculated
several times, each time it will consume 10+ us observed by ftrace in my
non-overcommit environment since the expensive memory allocate/mutex/rcu etc
operations. This patch optimizes it by recaluating apic map in batch, I hope
this can benefit the serverless scenario which can frequently create/destroy
VMs.

Before patch:

kvm_lapic_reset  ~27us

After patch:

kvm_lapic_reset  ~14us

Observed by ftrace, improve ~48%.

Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/lapic.c
arch/x86/kvm/lapic.h
arch/x86/kvm/x86.c