[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHVum0dPRqOmoMQsjV5M0kcaccqTpfwou0zrMj1R1RUYMFBjEg@mail.gmail.com>
Date: Wed, 7 Dec 2022 11:05:09 -0800
From: Vipin Sharma <vipinsh@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>,
David Matlack <dmatlack@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>, KVM <kvm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc: Ben Gardon <bgardon@...gle.com>
Subject: Re: [Patch v2 2/2] KVM: x86/mmu: Allocate page table pages on NUMA
node of underlying pages
By mistake I started replying to just Ben and realized it after few
exchanges. Adding others. Sorry about that.
On Wed, Dec 7, 2022 at 10:58 AM Vipin Sharma <vipinsh@...gle.com> wrote:
>
> On Tue, Dec 6, 2022 at 11:57 AM Ben Gardon <bgardon@...gle.com> wrote:
> >
> > On Tue, Dec 6, 2022 at 11:18 AM Vipin Sharma <vipinsh@...gle.com> wrote:
> > >
> > > On Tue, Dec 6, 2022 at 10:17 AM Ben Gardon <bgardon@...gle.com> wrote:
> > > >
> > > > On Mon, Dec 5, 2022 at 3:40 PM Vipin Sharma <vipinsh@...gle.com> wrote:
> > > > >
> > > > > On Mon, Dec 5, 2022 at 10:17 AM Ben Gardon <bgardon@...gle.com> wrote:
> > > > > >
> > > > > > On Thu, Dec 1, 2022 at 11:57 AM Vipin Sharma <vipinsh@...gle.com> wrote:
> > > > > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > > > > > > index 1782c4555d94..4d59c9d48277 100644
> > > > > > > --- a/virt/kvm/kvm_main.c
> > > > > > > +++ b/virt/kvm/kvm_main.c
> > > > > > > @@ -384,6 +384,11 @@ static void kvm_flush_shadow_all(struct kvm *kvm)
> > > > > > > kvm_arch_guest_memory_reclaimed(kvm);
> > > > > > > }
> > > > > > >
> > > > > > > +void * __weak kvm_arch_mmu_get_free_page(int nid, gfp_t gfp_flags)
> > > > > > > +{
> > > > > > > + return (void *)__get_free_page(gfp_flags);
> > > > > > > +}
> > > > > > > +
> > > > > >
> > > > > > Rather than making this __weak, you could use #ifdef CONFIG_NUMA to
> > > > > > just put all the code in the arch-neutral function.
> > > > > >
> > > > >
> > > > > I am not sure how it will work. Here, I am trying to keep this feature
> > > > > only for x86. This function will be used for all architecture except
> > > > > in x86 where we have different implementation in arch/x86/mmu/mmu.c
> > > > > So, even if CONFIG_NUMA is defined, we want to keep the same
> > > > > definition on other architectures.
> > > > >
> > > > >
> > > >
> > > > Something like:
> > > >
> > > > +void * kvm_arch_mmu_get_free_page(int nid, gfp_t gfp_flags)
> > > > +{
> > > > + struct page *spt_page;
> > > > + void *address = NULL;
> > > > +
> > > > + #ifdef CONFIG_NUMA
> > > > + if (nid != NUMA_NO_NODE) {
> > > > + spt_page = alloc_pages_node(nid, gfp, 0);
> > > > + if (spt_page) {
> > > > + address = page_address(spt_page);
> > > > + return address;
> > > > + }
> > > > + }
> > > > + #endif // CONFIG_NUMA
> > > > + return (void *)__get_free_page(gfp);
> > > > +}
> > > >
> > >
> > > 'nid' will be 0 not NUMA_NO_NODE for other architectures. In x86, I am
> > > explicitly setting kvm_mmu_memory_cache->node to NUMA_NO_NODE or
> > > specific desired nodes. In others architectures it will be 0 as struct
> > > will be 0 initialized. __weak avoids initializing nid to NUM_NO_NODE
> > > in other architectures.
> >
> > ooh, I see. It might be worth setting it to NUMA_NO_NODE on other
> > archs as 0 could be kind of misleading.
>
> Discussed offline with Ben.
> Initialization code for cache is in the respective architectures.
> Using "__weak" avoids touching code in other architectures.
Powered by blists - more mailing lists