[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YXBnn6ZaXbaqKvOo@google.com>
Date: Wed, 20 Oct 2021 19:01:51 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: "Maciej S. Szmigiero" <mail@...iej.szmigiero.name>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Igor Mammedov <imammedo@...hat.com>,
Marc Zyngier <maz@...nel.org>,
James Morse <james.morse@....com>,
Julien Thierry <julien.thierry.kdev@...il.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Huacai Chen <chenhuacai@...nel.org>,
Aleksandar Markovic <aleksandar.qemu.devel@...il.com>,
Paul Mackerras <paulus@...abs.org>,
Christian Borntraeger <borntraeger@...ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
David Hildenbrand <david@...hat.com>,
Cornelia Huck <cohuck@...hat.com>,
Claudio Imbrenda <imbrenda@...ux.ibm.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 01/13] KVM: x86: Cache total page count to avoid
traversing the memslot array
On Wed, Oct 20, 2021, Maciej S. Szmigiero wrote:
> On 20.10.2021 00:24, Sean Christopherson wrote:
> > E.g. the whole thing can be
> >
> > if (!kvm->arch.n_requested_mmu_pages &&
> > (change == KVM_MR_CREATE || change == KVM_MR_DELETE)) {
> > unsigned long nr_mmu_pages;
> >
> > if (change == KVM_MR_CREATE) {
> > kvm->arch.n_memslots_pages += new->npages;
> > } else {
> > WARN_ON(kvm->arch.n_memslots_pages < old->npages);
> > kvm->arch.n_memslots_pages -= old->npages;
> > }
> >
> > nr_mmu_pages = (unsigned long)kvm->arch.n_memslots_pages;
> > nr_mmu_pages *= (KVM_PERMILLE_MMU_PAGES / 1000);
>
> The above line will set nr_mmu_pages to zero since KVM_PERMILLE_MMU_PAGES
> is 20, so when integer-divided by 1000 will result in a multiplication
> coefficient of zero.
Ugh, math. And thus do_div() to avoid the whole 64-bit divide issue on 32-bit KVM.
Bummer.
Powered by blists - more mailing lists