Re: [PATCH v4 RESEND 3/5] KVM: x86: hyperv: use get_vcpu_by_vpidx() in kvm_hv_flush_tlb()
From: Roman Kagan
Date: Tue Sep 25 2018 - 04:58:11 EST
On Mon, Sep 24, 2018 at 06:55:28PM +0200, Paolo Bonzini wrote:
> On 24/09/2018 18:24, Paolo Bonzini wrote:
> > Hi Paolo,
> >
> > could you please clarify what needs to be done to get this merged? In
> > particular, are you OK with my comment above or do we need to do
> > something with it (e.g. get back to the 'logarythmic search' from v2)?
> >
> > In kvm/queue I can see only 'x86/hyper-v: rename ipi_arg_{ex,non_ex}
> > structures' patch from this series applied.
>
> Hi,
>
> my plan was to apply only 1/2/5 for now. I singled out the rename patch
> because that one could be included in 4.19-rc kernels as a cleanup.
Is this supposed to mean you're not happy with the approach taken in
Vitaly's patch? Can you explain why? I take my part of guilt for it so
I'd like to know, too.
Speaking of the options we have, the choice depends on the assumptions
we take. (And I guess when you spoke of quadratic complexity you
referred to the algorithm to convert the vp_index mask into the KVM cpu
mask.)
If we can assume that in all relevant cases vp_index coincides with the
cpu index (which I think we can) then Vitaly's approach is the most
efficient.
If, on the opposite, we want to optimize for random mapping between
vp_index and cpu index, then it's probably better instead to iterate
over vcpus and test if their vp_index belongs to the requested mask.
Neither of the above is quadratic.
Dunno if we need to specifically consider intermediate situations.
Anyway using a havier vp_index -> cpu index translation looks like an
overkill to me.
What do you think?
Thanks,
Roman.