[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201027224652.GB2011@linux.intel.com>
Date: Tue, 27 Oct 2020 15:46:52 -0700
From: Sean Christopherson <sean.j.christopherson@...el.com>
To: Ben Gardon <bgardon@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm <kvm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] KVM: x86/mmu: Add helper macro for computing
hugepage GFN mask
On Tue, Oct 27, 2020 at 03:17:40PM -0700, Ben Gardon wrote:
> On Tue, Oct 27, 2020 at 2:43 PM Sean Christopherson
> <sean.j.christopherson@...el.com> wrote:
> >
> > Add a helper to compute the GFN mask given a hugepage level, KVM is
> > accumulating quite a few users with the addition of the TDP MMU.
> >
> > Note, gcc is clever enough to use a single NEG instruction instead of
> > SUB+NOT, i.e. use the more common "~(level -1)" pattern instead of
> > round_gfn_for_level()'s direct two's complement trickery.
>
> As far as I can tell this patch has no functional changes intended.
> Please correct me if that's not correct.
Correct. :-)
> >
> > Signed-off-by: Sean Christopherson <sean.j.christopherson@...el.com>
>
> Reviewed-by: Ben Gardon <bgardon@...gle.com>
>
> > ---
> > arch/x86/include/asm/kvm_host.h | 1 +
> > arch/x86/kvm/mmu/mmu.c | 2 +-
> > arch/x86/kvm/mmu/paging_tmpl.h | 4 ++--
> > arch/x86/kvm/mmu/tdp_iter.c | 2 +-
> > 4 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index d44858b69353..6ea046415f29 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -119,6 +119,7 @@
> > #define KVM_HPAGE_SIZE(x) (1UL << KVM_HPAGE_SHIFT(x))
> > #define KVM_HPAGE_MASK(x) (~(KVM_HPAGE_SIZE(x) - 1))
> > #define KVM_PAGES_PER_HPAGE(x) (KVM_HPAGE_SIZE(x) / PAGE_SIZE)
> > +#define KVM_HPAGE_GFN_MASK(x) (~(KVM_PAGES_PER_HPAGE(x) - 1))
>
> NIT: I know x follows the convention on adjacent macros, but this
> would be clearer to me if x was changed to level. (Probably for all
> the macros in this block)
Agreed. I'll spin a v2 and opportunistically change them all to "level"
in this patch. I'll also add "No function change intendedâ„¢." to patches
1 and 3.
> > static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
> > {
Powered by blists - more mailing lists