[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YY29d7Vb6aiv93mu@google.com>
Date: Fri, 12 Nov 2021 01:03:51 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: "Maciej S. Szmigiero" <maciej.szmigiero@...cle.com>
Cc: James Morse <james.morse@....com>,
Alexandru Elisei <alexandru.elisei@....com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Atish Patra <atish.patra@....com>,
David Hildenbrand <david@...hat.com>,
Cornelia Huck <cohuck@...hat.com>,
Claudio Imbrenda <imbrenda@...ux.ibm.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
linux-arm-kernel@...ts.infradead.org, kvmarm@...ts.cs.columbia.edu,
linux-mips@...r.kernel.org, kvm@...r.kernel.org,
kvm-ppc@...r.kernel.org, kvm-riscv@...ts.infradead.org,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
Ben Gardon <bgardon@...gle.com>, Marc Zyngier <maz@...nel.org>,
Huacai Chen <chenhuacai@...nel.org>,
Aleksandar Markovic <aleksandar.qemu.devel@...il.com>,
Paul Mackerras <paulus@...abs.org>,
Anup Patel <anup.patel@....com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Christian Borntraeger <borntraeger@...ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Paolo Bonzini <pbonzini@...hat.com>
Subject: Re: [PATCH v5.5 23/30] KVM: Resolve memslot ID via a hash table
instead of via a static array
On Fri, Nov 12, 2021, Maciej S. Szmigiero wrote:
> On 04.11.2021 01:25, Sean Christopherson wrote:
> > From: Maciej S. Szmigiero <maciej.szmigiero@...cle.com>
> >
> > Memslot ID to the corresponding memslot mappings are currently kept as
> > indices in static id_to_index array.
> > The size of this array depends on the maximum allowed memslot count
> > (regardless of the number of memslots actually in use).
> >
> > This has become especially problematic recently, when memslot count cap was
> > removed, so the maximum count is now full 32k memslots - the maximum
> > allowed by the current KVM API.
> >
> > Keeping these IDs in a hash table (instead of an array) avoids this
> > problem.
> >
> > Resolving a memslot ID to the actual memslot (instead of its index) will
> > also enable transitioning away from an array-based implementation of the
> > whole memslots structure in a later commit.
> >
> > Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@...cle.com>
> > Co-developed-by: Sean Christopherson <seanjc@...gle.com>
> > Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> > ---
> > include/linux/kvm_host.h | 16 +++----
> > virt/kvm/kvm_main.c | 96 +++++++++++++++++++++++++++++++---------
> > 2 files changed, 84 insertions(+), 28 deletions(-)
> >
> (..)
> > @@ -1259,17 +1257,49 @@ static int kvm_alloc_dirty_bitmap(struct kvm_memory_slot *memslot)
> > return 0;
> > }
> > +static void kvm_replace_memslot(struct kvm_memslots *slots,
> > + struct kvm_memory_slot *old,
> > + struct kvm_memory_slot *new)
> > +{
> > + /*
> > + * Remove the old memslot from the hash list, copying the node data
> > + * would corrupt the list.
> > + */
> > + if (old) {
> > + hash_del(&old->id_node);
> > +
> > + if (!new)
> > + return;
> > + }
> > +
> > + /* Copy the source *data*, not the pointer, to the destination. */
> > + if (old)
> > + *new = *old;
>
> This way of writing it (that, is re-checking whether "old" is not-NULL)
> suggests that it could have been set to NULL inside the previous block
> (since the last check), which isn't true.
Yeah, I think I was trying to minimize the logic delta in future patches, but
looking back at the diffs, that didn't pan out. I've no objection to folding
the two together.
Powered by blists - more mailing lists