Message ID | 20230306224127.1689967-16-vipinsh@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2125525wrd; Mon, 6 Mar 2023 15:14:12 -0800 (PST) X-Google-Smtp-Source: AK7set9GIpIKmBFY/NUkVJuYHoSWdTIrcnzJzSQkbZfkIj4KcEjUXF7BzGxYXYTRD+bea6g1uyTO X-Received: by 2002:a17:907:c25:b0:907:6759:7679 with SMTP id ga37-20020a1709070c2500b0090767597679mr14933709ejc.54.1678144451964; Mon, 06 Mar 2023 15:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678144451; cv=none; d=google.com; s=arc-20160816; b=orBqbZkysCWqOJcNfImqipTUnJERs4fztZCM0cxo9sTfeD+eTia9mLadqj4E7Eb8uG fr04wT7+7x9/z9ADASQduhVekQFGZRzsVUzu1OmiIt7Nz/Cge6w+Z87tz84i2eKbaux/ /2RZvk1pXlUVIa/MsziVIIh8Fv1+Bcs74vKrTr3BFq4Vd+JGqDZZpvJd5hmkSgaPFkqZ 9NKMfj6bDlhyrg4r7qT89W2/BlW8ce22l9GWy4t1hd6EKFBRtj6NRFDPbF3GN329OjPc JxRgZ5u0WAi5NtY0T9CwfDT+BuLMwkffYQTpFWksx+MJoyQ0SZmDE4K51GvReJq8uk5N RUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=QF0YVo49bCSm6bcyFWH7OqAKf22akzrbGA/pGOKX2s4=; b=qmunaKj2FS+VJtzQOZbL+/j395BZtPmsL8AHzZv9KO9jMQWveDmPJLLhr+Tu5zeWxg h4ANzNIUH4XAXVJz79FxrT6kVyxTXpsalLF9oFwK2ho+IlEuZuj3UnjcKXfLhS19eW7p osGCa+6J3Rbrt90SXdRz5p/w2VVv1HrwFzLS/re+scRoTB86FmKoRmC8oFc5PJO8z1NV IMvzMXZ9/RuJIInoU3uFffYvX9cnGA1hYPnPTWgctgnf+sotHGHfwnK+k2tvFTTarUJq DB6gTIWmI+J+7FOwBCVhTdkJelizrAWO8XtJg+EyZ+zxv+NbIzw/RR9yQ13EKB4+Noic S13Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=j70Rx6on; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a170906829000b008cc17a6e394si10749781ejx.779.2023.03.06.15.13.48; Mon, 06 Mar 2023 15:14:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=j70Rx6on; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230310AbjCFWnO (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 17:43:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbjCFWmq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 17:42:46 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5146F79B3C for <linux-kernel@vger.kernel.org>; Mon, 6 Mar 2023 14:42:13 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id iw4-20020a170903044400b0019ccafc1fbeso6574394plb.3 for <linux-kernel@vger.kernel.org>; Mon, 06 Mar 2023 14:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678142520; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QF0YVo49bCSm6bcyFWH7OqAKf22akzrbGA/pGOKX2s4=; b=j70Rx6ona9KIAnQ4HWSz5x9GD68BX0x1weHZP2/r+WzR2h1/SSUiCMoGT0/LMn8Krl hDwgLLwODSiQraOXzkU5foUjHwl43UOCrK1AKg2uMA8DJsB9kMN/FpRAawq/Jm/VX/cJ LD8cxRl72IW9wCnhEe3Tet/54wvO6hOSZMHRw53rLydqkVnq/i9RrbKZqXUkjhisFLgo MwQy/8x+BSK/8fCADVgj6wpzAz8cfMGDyyHWx55HQAg+EUJ4PFbAHSh2HUhxjhsnfQjL g901dK4CRZerMpvmU1+ZNo/lW5rSjLY+I7K/GMlMMlDpjMd2e9OzGaB7LM7xYGdRwzrT ePNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678142520; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QF0YVo49bCSm6bcyFWH7OqAKf22akzrbGA/pGOKX2s4=; b=IE2/H5Gf5/gIqu2n6ic3oU8hRi7uUMfAxJRl3j8yXGsWf+SZKOd5jLGMYoPKZGz8zI /l+uzn7XBlVJXIUrVc7SOUnT9hwIXmIKEOlNI6IP2+32c8Rg3S92OBXPQUNhMiZTOxkV 3bQ8z19e+vfa4qYfJxyAIqn3RerCbkW+mQKZ7rlrgdyMqPq18qe8tamVz4gszfVtNcTO P+iMsBrCSnrjqlGHlggxlw1kIETcHaXI+qEb/AhJM1g4lSTaXkKCO7itLzZSVUSJgWFQ 2gL6Xw0jkFnZuGglTtsXK2tiFxB7g+FpnQGbymkate6QTjL01coR+I5R33GbYDxejN5b wyhw== X-Gm-Message-State: AO0yUKVNrckwI8kExR9QyqNbc+vEdrcspPq81oqir3pMZ79FadWd+7Ac JAZ9LWcxGkKDW6jK7icvptxg7VxpinEy X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a63:3747:0:b0:503:2d50:5bf1 with SMTP id g7-20020a633747000000b005032d505bf1mr4047163pgn.7.1678142520704; Mon, 06 Mar 2023 14:42:00 -0800 (PST) Date: Mon, 6 Mar 2023 14:41:24 -0800 In-Reply-To: <20230306224127.1689967-1-vipinsh@google.com> Mime-Version: 1.0 References: <20230306224127.1689967-1-vipinsh@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306224127.1689967-16-vipinsh@google.com> Subject: [Patch v4 15/18] KVM: mmu: Add NUMA node support in struct kvm_mmu_memory_cache{} From: Vipin Sharma <vipinsh@google.com> To: seanjc@google.com, pbonzini@redhat.com, bgardon@google.com, dmatlack@google.com Cc: jmattson@google.com, mizhang@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma <vipinsh@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759661996495105043?= X-GMAIL-MSGID: =?utf-8?q?1759661996495105043?= |
Series |
NUMA aware page table allocation
|
|
Commit Message
Vipin Sharma
March 6, 2023, 10:41 p.m. UTC
Add NUMA node id variable in struct kvm_mmu_memory_cache{}. This
variable denotes preferable NUMA node from which memory will be
allocated under this memory cache.
Set this variable to NUMA_NO_NODE if there is no preferred node.
MIPS doesn't do any sort of initializatino of struct
kvm_mmu_memory_cache{}. Keep things similar in MIPS by setting gfp_zero
to 0 as INIT_KVM_MMU_MEMORY_CACHE() will initialize it to __GFP_ZERO.
"node" cannot be left as 0, as 0 is a valid NUMA node value.
Signed-off-by: Vipin Sharma <vipinsh@google.com>
---
arch/mips/kvm/mips.c | 3 +++
include/linux/kvm_types.h | 3 +++
2 files changed, 6 insertions(+)
Comments
On Mon, Mar 06, 2023 at 02:41:24PM -0800, Vipin Sharma wrote: > Add NUMA node id variable in struct kvm_mmu_memory_cache{}. This > variable denotes preferable NUMA node from which memory will be > allocated under this memory cache. > > Set this variable to NUMA_NO_NODE if there is no preferred node. > > MIPS doesn't do any sort of initializatino of struct > kvm_mmu_memory_cache{}. Keep things similar in MIPS by setting gfp_zero > to 0 as INIT_KVM_MMU_MEMORY_CACHE() will initialize it to __GFP_ZERO. > > "node" cannot be left as 0, as 0 is a valid NUMA node value. > > Signed-off-by: Vipin Sharma <vipinsh@google.com> > --- > arch/mips/kvm/mips.c | 3 +++ > include/linux/kvm_types.h | 3 +++ > 2 files changed, 6 insertions(+) > > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c > index 36c8991b5d39..5ec5ce919918 100644 > --- a/arch/mips/kvm/mips.c > +++ b/arch/mips/kvm/mips.c > @@ -294,6 +294,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > HRTIMER_MODE_REL); > vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; > > + INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); > + vcpu->arch.mmu_page_cache.gfp_zero = 0; Oh MIPS is here. Why isn't MIPS covered in the previous commits? > + > /* > * Allocate space for host mode exception handlers that handle > * guest mode exits > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > index 5da7953532ce..b2a405c8e629 100644 > --- a/include/linux/kvm_types.h > +++ b/include/linux/kvm_types.h > @@ -97,10 +97,13 @@ struct kvm_mmu_memory_cache { > struct kmem_cache *kmem_cache; > int capacity; > void **objects; > + /* Preferred NUMA node of memory allocation. */ > + int node; > }; > > #define KVM_MMU_MEMORY_CACHE_INIT() { \ > .gfp_zero = __GFP_ZERO, \ > + .node = NUMA_NO_NODE, \ > } > > #define KVM_MMU_MEMORY_CACHE(_name) \ > -- > 2.40.0.rc0.216.gc4246ad0f0-goog >
On Thu, Mar 23, 2023 at 3:30 PM David Matlack <dmatlack@google.com> wrote: > > On Mon, Mar 06, 2023 at 02:41:24PM -0800, Vipin Sharma wrote: > > Add NUMA node id variable in struct kvm_mmu_memory_cache{}. This > > variable denotes preferable NUMA node from which memory will be > > allocated under this memory cache. > > > > Set this variable to NUMA_NO_NODE if there is no preferred node. > > > > MIPS doesn't do any sort of initializatino of struct > > kvm_mmu_memory_cache{}. Keep things similar in MIPS by setting gfp_zero > > to 0 as INIT_KVM_MMU_MEMORY_CACHE() will initialize it to __GFP_ZERO. > > > > "node" cannot be left as 0, as 0 is a valid NUMA node value. > > > > Signed-off-by: Vipin Sharma <vipinsh@google.com> > > --- > > arch/mips/kvm/mips.c | 3 +++ > > include/linux/kvm_types.h | 3 +++ > > 2 files changed, 6 insertions(+) > > > > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c > > index 36c8991b5d39..5ec5ce919918 100644 > > --- a/arch/mips/kvm/mips.c > > +++ b/arch/mips/kvm/mips.c > > @@ -294,6 +294,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > > HRTIMER_MODE_REL); > > vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; > > > > + INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); > > + vcpu->arch.mmu_page_cache.gfp_zero = 0; > > Oh MIPS is here. Why isn't MIPS covered in the previous commits? > Because this is the patch where MIPS get impacted. MIPS doesn't initialize gfp_zero, so there was no need to change the code in MIPS. However, with the addition of "node" in kvm_mmu_memory_cache{} in this patch, we need initialization in MIPS to (1) Set node to NUMA_NO_NODE as 0 is now a valid value, and (2) INIT_KVM_MMU_MEMORY_CACHE() will set gfp_zero to __GFP_ZERO which is different than existing code in MIPS to keep it 0. I asked MIPS maintainers in the previous version to see if GFP_ZERO can be added but didn't get any response. https://lore.kernel.org/lkml/CAHVum0c+17Z-RbGAFdU-xmRejDjDQ+MKOfN4XaObh2SwgWAjLg@mail.gmail.com/ > > + > > /* > > * Allocate space for host mode exception handlers that handle > > * guest mode exits > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > > index 5da7953532ce..b2a405c8e629 100644 > > --- a/include/linux/kvm_types.h > > +++ b/include/linux/kvm_types.h > > @@ -97,10 +97,13 @@ struct kvm_mmu_memory_cache { > > struct kmem_cache *kmem_cache; > > int capacity; > > void **objects; > > + /* Preferred NUMA node of memory allocation. */ > > + int node; > > }; > > > > #define KVM_MMU_MEMORY_CACHE_INIT() { \ > > .gfp_zero = __GFP_ZERO, \ > > + .node = NUMA_NO_NODE, \ > > } > > > > #define KVM_MMU_MEMORY_CACHE(_name) \ > > -- > > 2.40.0.rc0.216.gc4246ad0f0-goog > >
On Tue, Mar 28, 2023 at 10:51 AM Vipin Sharma <vipinsh@google.com> wrote: > > On Thu, Mar 23, 2023 at 3:30 PM David Matlack <dmatlack@google.com> wrote: > > > > On Mon, Mar 06, 2023 at 02:41:24PM -0800, Vipin Sharma wrote: > > > Add NUMA node id variable in struct kvm_mmu_memory_cache{}. This > > > variable denotes preferable NUMA node from which memory will be > > > allocated under this memory cache. > > > > > > Set this variable to NUMA_NO_NODE if there is no preferred node. > > > > > > MIPS doesn't do any sort of initializatino of struct > > > kvm_mmu_memory_cache{}. Keep things similar in MIPS by setting gfp_zero > > > to 0 as INIT_KVM_MMU_MEMORY_CACHE() will initialize it to __GFP_ZERO. > > > > > > "node" cannot be left as 0, as 0 is a valid NUMA node value. > > > > > > Signed-off-by: Vipin Sharma <vipinsh@google.com> > > > --- > > > arch/mips/kvm/mips.c | 3 +++ > > > include/linux/kvm_types.h | 3 +++ > > > 2 files changed, 6 insertions(+) > > > > > > diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c > > > index 36c8991b5d39..5ec5ce919918 100644 > > > --- a/arch/mips/kvm/mips.c > > > +++ b/arch/mips/kvm/mips.c > > > @@ -294,6 +294,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > > > HRTIMER_MODE_REL); > > > vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; > > > > > > + INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); > > > + vcpu->arch.mmu_page_cache.gfp_zero = 0; > > > > Oh MIPS is here. Why isn't MIPS covered in the previous commits? > > Because this is the patch where MIPS get impacted. MIPS doesn't > initialize gfp_zero, so there was no need to change the code in MIPS. > However, with the addition of "node" in kvm_mmu_memory_cache{} in this > patch, we need initialization in MIPS to (1) Set node to NUMA_NO_NODE > as 0 is now a valid value, and (2) INIT_KVM_MMU_MEMORY_CACHE() will > set gfp_zero to __GFP_ZERO which is different than existing code in > MIPS to keep it 0. > > I asked MIPS maintainers in the previous version to see if GFP_ZERO > can be added but didn't get any response. > https://lore.kernel.org/lkml/CAHVum0c+17Z-RbGAFdU-xmRejDjDQ+MKOfN4XaObh2SwgWAjLg@mail.gmail.com/ I see. IMO it's more logical to convert the MIPS cache to INIT_KVM_MMU_MEMORY_CACHE() in patch 13, along with all the other users of struct kvm_mmu_memory_cache. Then in patch 14, add the line to set gfp_zero to 0 for MIPS to preserve the existing behavior. That produces a very simple chain of changes: Patch 13: Convert all users of struct kvm_mmu_memory_cache to INIT() Patch 14: Invert the default value of kvm_mmu_memory_cache.gfp_zero Patch 15: Add node to kvm_mmu_memory_cache > > > > + > > > /* > > > * Allocate space for host mode exception handlers that handle > > > * guest mode exits > > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > > > index 5da7953532ce..b2a405c8e629 100644 > > > --- a/include/linux/kvm_types.h > > > +++ b/include/linux/kvm_types.h > > > @@ -97,10 +97,13 @@ struct kvm_mmu_memory_cache { > > > struct kmem_cache *kmem_cache; > > > int capacity; > > > void **objects; > > > + /* Preferred NUMA node of memory allocation. */ > > > + int node; > > > }; > > > > > > #define KVM_MMU_MEMORY_CACHE_INIT() { \ > > > .gfp_zero = __GFP_ZERO, \ > > > + .node = NUMA_NO_NODE, \ > > > } > > > > > > #define KVM_MMU_MEMORY_CACHE(_name) \ > > > -- > > > 2.40.0.rc0.216.gc4246ad0f0-goog > > >
On Tue, Mar 28, 2023 at 4:25 PM David Matlack <dmatlack@google.com> wrote: > > On Tue, Mar 28, 2023 at 10:51 AM Vipin Sharma <vipinsh@google.com> wrote: > > > > On Thu, Mar 23, 2023 at 3:30 PM David Matlack <dmatlack@google.com> wrote: > > > > > > On Mon, Mar 06, 2023 at 02:41:24PM -0800, Vipin Sharma wrote: > > > > + INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); > > > > + vcpu->arch.mmu_page_cache.gfp_zero = 0; > > > > > > Oh MIPS is here. Why isn't MIPS covered in the previous commits? > > > > Because this is the patch where MIPS get impacted. MIPS doesn't > > initialize gfp_zero, so there was no need to change the code in MIPS. > > However, with the addition of "node" in kvm_mmu_memory_cache{} in this > > patch, we need initialization in MIPS to (1) Set node to NUMA_NO_NODE > > as 0 is now a valid value, and (2) INIT_KVM_MMU_MEMORY_CACHE() will > > set gfp_zero to __GFP_ZERO which is different than existing code in > > MIPS to keep it 0. > > > > I asked MIPS maintainers in the previous version to see if GFP_ZERO > > can be added but didn't get any response. > > https://lore.kernel.org/lkml/CAHVum0c+17Z-RbGAFdU-xmRejDjDQ+MKOfN4XaObh2SwgWAjLg@mail.gmail.com/ > > I see. IMO it's more logical to convert the MIPS cache to > INIT_KVM_MMU_MEMORY_CACHE() in patch 13, along with all the other > users of struct kvm_mmu_memory_cache. Then in patch 14, add the line > to set gfp_zero to 0 for MIPS to preserve the existing behavior. That > produces a very simple chain of changes: > > Patch 13: Convert all users of struct kvm_mmu_memory_cache to INIT() > Patch 14: Invert the default value of kvm_mmu_memory_cache.gfp_zero > Patch 15: Add node to kvm_mmu_memory_cache > > Yeah, this looks better. I will do this.
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 36c8991b5d39..5ec5ce919918 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -294,6 +294,9 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) HRTIMER_MODE_REL); vcpu->arch.comparecount_timer.function = kvm_mips_comparecount_wakeup; + INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); + vcpu->arch.mmu_page_cache.gfp_zero = 0; + /* * Allocate space for host mode exception handlers that handle * guest mode exits diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h index 5da7953532ce..b2a405c8e629 100644 --- a/include/linux/kvm_types.h +++ b/include/linux/kvm_types.h @@ -97,10 +97,13 @@ struct kvm_mmu_memory_cache { struct kmem_cache *kmem_cache; int capacity; void **objects; + /* Preferred NUMA node of memory allocation. */ + int node; }; #define KVM_MMU_MEMORY_CACHE_INIT() { \ .gfp_zero = __GFP_ZERO, \ + .node = NUMA_NO_NODE, \ } #define KVM_MMU_MEMORY_CACHE(_name) \