[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <642f73ee-9425-0149-f4f4-f56be9ae5713@redhat.com>
Date: Tue, 22 Oct 2019 16:04:18 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>,
James Hogan <jhogan@...nel.org>,
Paul Mackerras <paulus@...abs.org>,
Christian Borntraeger <borntraeger@...ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Marc Zyngier <maz@...nel.org>
Cc: David Hildenbrand <david@...hat.com>,
Cornelia Huck <cohuck@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
James Morse <james.morse@....com>,
Julien Thierry <julien.thierry.kdev@...il.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
linux-mips@...r.kernel.org, kvm-ppc@...r.kernel.org,
kvm@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
kvmarm@...ts.cs.columbia.edu, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 14/15] KVM: Terminate memslot walks via used_slots
On 22/10/19 02:35, Sean Christopherson wrote:
> +static inline int kvm_shift_memslots_forward(struct kvm_memslots *slots,
> + struct kvm_memory_slot *new)
> +{
> + struct kvm_memory_slot *mslots = slots->memslots;
> + int i;
> +
> + if (WARN_ON_ONCE(slots->id_to_index[new->id] == -1) ||
> + WARN_ON_ONCE(!slots->used_slots))
> + return -1;
> +
> + for (i = slots->id_to_index[new->id]; i < slots->used_slots - 1; i++) {
> + if (new->base_gfn > mslots[i + 1].base_gfn)
> + break;
> +
> + WARN_ON_ONCE(new->base_gfn == mslots[i + 1].base_gfn);
> +
> + /* Shift the next memslot forward one and update its index. */
> + mslots[i] = mslots[i + 1];
> + slots->id_to_index[mslots[i].id] = i;
> + }
> + return i;
> +}
> +
> +static inline int kvm_shift_memslots_back(struct kvm_memslots *slots,
> + struct kvm_memory_slot *new,
> + int start)
This new implementation of the insertion sort loses the comments that
were there in the old one. Please keep them as function comments.
Paolo
Powered by blists - more mailing lists