lkml.org 
[lkml]   [2021]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2021-10-20 21:02    [W:0.321 / U:3.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site