Re: [PATCH v2 5/6] kvm: allocate vcpu pointer array separately

From: Sean Christopherson
Date: Thu Sep 09 2021 - 16:28:17 EST


On Mon, Sep 06, 2021, Marc Zyngier wrote:
> On Mon, 06 Sep 2021 05:33:35 +0100,
> Juergen Gross <jgross@xxxxxxxx> wrote:
> >
> > On 03.09.21 16:41, Marc Zyngier wrote:
> >
> > > At this stage, I really wonder why we are not using an xarray instead.
> > >
> > > I wrote this [1] a while ago, and nothing caught fire. It was also a
> > > net deletion of code...
> >
> > Indeed, I'd prefer that solution!
> >
> > Are you fine with me swapping my patch with yours in the series?
>
> Of course, feel free to grab the whole series. You'll probably need
> the initial patches to set the scene for this. On their own, they are
> a nice cleanup, and I trust you can write a decent commit message for
> the three patches affecting mips/s390/x86.

It would also be a good idea to convert kvm_for_each_vcpu() to use xa_for_each(),
I assume that's more performant than 2x atomic_read() + xa_load(). Unless I'm
misreading the code, xa_for_each() is guaranteed to iterate in ascending index
order, i.e. preserves the current vcpu0..vcpuN iteration order.