Re: [PATCH] KVM: LAPIC: Recalculate apic map in batch
From: Wanpeng Li
Date: Tue Feb 18 2020 - 19:48:10 EST
On Tue, 18 Feb 2020 at 20:24, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> wrote:
> Wanpeng Li <kernellwp@xxxxxxxxx> writes:
> > From: Wanpeng Li <wanpengli@xxxxxxxxxxx>
> > 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.
> > Signed-off-by: Wanpeng Li <wanpengli@xxxxxxxxxxx>
> An alternative idea: instead of making every caller return bool and
> every call site handle the result (once) just add a
> KVM_REQ_APIC_MAP_RECALC flag or a boolean flag to struct kvm. I
> understand it may not be that easy as it sounds as we may be conunting
> on valid mapping somewhere before we actually get to handiling
> KVM_REQ_APIC_MAP_RECALC but we may preserve *some*
> recalculate_apic_map() calls (and make it reset KVM_REQ_APIC_MAP_RECALC).
Paolo, keep the caller return bool or add a booleen flag to struct
kvm, what do you think?