From nobody Sat Jul 25 15:51:14 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C191337688 for ; Thu, 16 Jul 2026 14:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212222; cv=none; b=ZJO/E3P+cwnAE02xu943rmmXdi+yh6avlSJYNobnixRnEuP6giMhdPo+GdQqY1f2XXpsSqiBS/6ZIK83HGLh6Uf/I3eUcysnVjSzSWKU6gnECrv1svQmHjEnxLwv9L/KwyQVIytTXFVfmMRqVQbu2n7e4NW00zG7Hj6YM0Jg6bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212222; c=relaxed/simple; bh=/FB0/SqBk6YlqdFayoLeOWZJGRngkjOT3cbxJecVoEs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=J97secVTeYU1+QOKIA2Oug3YgoY2Xx2MPJ8RryYueDmKfejeUmj+Yxkxon77JFpOfcvI5XJUW4kZ6A1zH9R/8bx/mGBh+bEHMMkNPqxqm7Vyq5PwHEtSVaSDiw9xwjMBvw1h5cRhWK+9AlSXWlOp/23p7jA0xMDn+BVcuBoQP4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jfWf226p; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jfWf226p" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-492488f8583so96536445e9.2 for ; Thu, 16 Jul 2026 07:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784212218; x=1784817018; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qXj/ylmXdmqbjEPyQgiWZrVSrCcZeklAgzKFbFtJ76k=; b=jfWf226pzepC8/KHA4dKKSD9gI1sPbN3zQMaIUNyW5y/wtaCACNMMOnIT/Q0NQwaON ssV5DtEW9+vsu9KVnyXWzhGn1TaeEcajesIvU1BfXqX7B3yuusl50pJEK+YETg5aMl23 eMiRrHPndDi4h01oTn6jQGlQerxtoDOsr7mLpWKsWVfXmHhmJtn2yds6U77b0bS0/kNF lthfcrzeI2nZTH21Od/yXRD6+dXL4SN7mKdCjJ+UWBeEYzg7Ftm4iXfK2WVVQzfByL8O DDTdeGhhs5ItutHLZ+qpUs5xPcUXQdZxVLC4z/LJQtQWx3YcktYyUN/ng7PwpPSIeuZj 3Sag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784212218; x=1784817018; h=content-type: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:content-type; bh=qXj/ylmXdmqbjEPyQgiWZrVSrCcZeklAgzKFbFtJ76k=; b=r+lXOa+Z9Wt4DPW5SwDjXDGQPGwFb0dyqs9btO0l04NHEOheMHK201iAB0dMZQTfZe GS9k0ceir3kHwT0SUD2lzJ09EsdIVEXcfctRLIad3M7+0/nbT5yTgfC0Y7jF6OqUvLR3 G6K0gLUvqMk73ZgAh0OnzuSgxpyRfi45D+lhx/zC2b0LZuOPQamn3p/5NW8ilUAuSaOH jNsg2KOaIij6shT+tvp37EKC4NCcnu/gm/dXJsAPRsyI4CR3S7gwMCPZ7dMDOczq9C6w oIIL/MGHd2M266POWXJU4Ihtk4KYCICDyXUCmM6Cl0hwTiI6zOePbIq+0pupjY0TO8W0 pEiw== X-Gm-Message-State: AOJu0Yzke+ZzEwDDI1xybJQRWnLtlwog2H/Dyn5n6VO42LXWhgnBdYuJ bwBoQb0ta87zKphNBQCLJ/4U+GrlTPh9EltCyCQWHHPVQHtA00BWMdLGWgOUiQHguGMgdkK/AxR rdZHcrTKeVjg42g== X-Received: from wmbdr10.prod.google.com ([2002:a05:600c:608a:b0:495:4728:580]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:628f:b0:493:d305:b8f3 with SMTP id 5b1f17b1804b1-49538ff827dmr104868985e9.3.1784212216047; Thu, 16 Jul 2026 07:30:16 -0700 (PDT) Date: Thu, 16 Jul 2026 14:30:10 +0000 In-Reply-To: <20260716-folio-alloc-cleanups-v1-0-5363b8e92d33@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260716-folio-alloc-cleanups-v1-0-5363b8e92d33@google.com> X-Mailer: b4 0.15.2 Message-ID: <20260716-folio-alloc-cleanups-v1-1-5363b8e92d33@google.com> Subject: [PATCH 1/3] mm: move internal mempolicy APIs to new internal header From: Brendan Jackman To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Zi Yan , "Matthew Wilcox (Oracle)" , Jan Kara , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hugh Dickins , Baolin Wang , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , "Joerg Roedel (AMD)" , Will Deacon , Robin Murphy , Huacai Chen , WANG Xuerui , Thomas Gleixner , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, iommu@lists.linux.dev, loongarch@lists.linux.dev, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable There are no external users for this surface, reduce the scope. Ulterior motive: a later patch will add an alloc_flags arg to some parts of this. Note it might seem like this could just go in internal.h, since it's pretty small, but actually it will eventually need to import page_alloc.h, we don't want to import that from internal.h so best to proactively created this header now. Signed-off-by: Brendan Jackman --- MAINTAINERS | 1 + include/linux/gfp.h | 9 --------- mm/filemap.c | 2 ++ mm/mempolicy.c | 1 + mm/mempolicy.h | 31 +++++++++++++++++++++++++++++++ mm/shmem.c | 1 + mm/swap_state.c | 1 + 7 files changed, 37 insertions(+), 9 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 8813d5d7eb0c1..9cde99c259639 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17068,6 +17068,7 @@ F: include/uapi/linux/mempolicy.h F: include/linux/migrate.h F: include/linux/migrate_mode.h F: mm/mempolicy.c +F: mm/mempolicy.h F: mm/migrate.c F: mm/migrate_device.c =20 diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 872bc53f32ec8..e4e974a6e5f90 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -11,7 +11,6 @@ #include =20 struct vm_area_struct; -struct mempolicy; =20 /* Helper macro to avoid gfp flags if they are the default one */ #define __default_gfp(a,b,...) b @@ -274,8 +273,6 @@ struct page *alloc_pages_node_noprof(int nid, gfp_t gfp= _mask, unsigned int order #ifdef CONFIG_NUMA struct page *alloc_pages_noprof(gfp_t gfp, unsigned int order); struct folio *folio_alloc_noprof(gfp_t gfp, unsigned int order); -struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int order, - struct mempolicy *mpol, pgoff_t ilx, int nid); struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_= struct *vma, unsigned long addr); #else @@ -287,11 +284,6 @@ static inline struct folio *folio_alloc_noprof(gfp_t g= fp, unsigned int order) { return __folio_alloc_node_noprof(gfp, order, numa_node_id()); } -static inline struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned in= t order, - struct mempolicy *mpol, pgoff_t ilx, int nid) -{ - return folio_alloc_noprof(gfp, order); -} static inline struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_struct *vma, unsigned long addr) { @@ -301,7 +293,6 @@ static inline struct folio *vma_alloc_folio_noprof(gfp_= t gfp, int order, =20 #define alloc_pages(...) alloc_hooks(alloc_pages_noprof(__VA_ARGS__)) #define folio_alloc(...) alloc_hooks(folio_alloc_noprof(__VA_ARGS__)) -#define folio_alloc_mpol(...) alloc_hooks(folio_alloc_mpol_noprof(__VA_A= RGS__)) #define vma_alloc_folio(...) alloc_hooks(vma_alloc_folio_noprof(__VA_ARG= S__)) =20 #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) diff --git a/mm/filemap.c b/mm/filemap.c index 1dbb4c6f824e9..0dd8e2a15d746 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -52,6 +52,7 @@ =20 #include #include "internal.h" +#include "mempolicy.h" =20 #define CREATE_TRACE_POINTS #include @@ -63,6 +64,7 @@ =20 #include =20 +#include "mempolicy.h" #include "swap.h" =20 /* diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 5720f7f54d942..31c4e9f49b5e9 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -119,6 +119,7 @@ #include =20 #include "internal.h" +#include "mempolicy.h" #include "page_alloc.h" =20 /* Internal flags */ diff --git a/mm/mempolicy.h b/mm/mempolicy.h new file mode 100644 index 0000000000000..d80fe4c559786 --- /dev/null +++ b/mm/mempolicy.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * mm-internal API for mempolicy.c. Public API lives in + * include/linux/mempolicy.h. + */ +#ifndef __MM_MEMPOLICY_H +#define __MM_MEMPOLICY_H + +#include +#include + +#ifdef CONFIG_NUMA +struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int order, + struct mempolicy *mpol, pgoff_t ilx, int nid); +#else +static inline struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned in= t order, + struct mempolicy *mpol, pgoff_t ilx, int nid) +{ + return folio_alloc_noprof(gfp, order); +} +#endif + +#define folio_alloc_mpol(...) alloc_hooks(folio_alloc_mpol_noprof(__VA_A= RGS__)) + +unsigned long alloc_pages_bulk_mempolicy_noprof(gfp_t gfp, + unsigned long nr_pages, + struct page **page_array); +#define alloc_pages_bulk_mempolicy(...) \ + alloc_hooks(alloc_pages_bulk_mempolicy_noprof(__VA_ARGS__)) + +#endif /* __MM_MEMPOLICY_H */ diff --git a/mm/shmem.c b/mm/shmem.c index 5071177059a96..69f561332bb93 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -41,6 +41,7 @@ #include #include #include +#include "mempolicy.h" #include "swap.h" =20 static struct vfsmount *shm_mnt __ro_after_init; diff --git a/mm/swap_state.c b/mm/swap_state.c index 5be825911e645..8ccd03c39a407 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -24,6 +24,7 @@ #include #include #include "internal.h" +#include "mempolicy.h" #include "swap_table.h" #include "swap.h" =20 --=20 2.54.0 From nobody Sat Jul 25 15:51:14 2026 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C818431A2D for ; Thu, 16 Jul 2026 14:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212223; cv=none; b=JnsrZyqOE2fto7s6pPLqI1cddbOeXXwV9V4QKHFJkVwH1V9lsCf4z99Bg67DDnndZRwMItWiGkgeNzwBa3sAkpzscjDELNtIb8OqmgdSSg6kGBcwTZRs1W1UM5Fn+7kRKqy6ySgR2iAFCeGZpYmX04UWzkQnlP4TEbtIXD3nRDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212223; c=relaxed/simple; bh=SQfF1SlG+YKrLzMOWa5OdbaXN61l98ieLIvRa/Hm4bI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AOkLgBZeSUsAR5VcoA8BZcG3NiqhP/B0EpV6jlHFT9X5Wr02qDAN0xTq3wRb1TWyqCISVRw2of9772ZogAidbHpSmnHpNaBvnHstq43acQ7lyxqMPvOid26eANvuICp7O2jPN5EdJPKHaUY7zCh+qzdEBapXHHhZX9C+unY72xk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=U7FQ5Znb; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="U7FQ5Znb" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-c1662ffbf57so344957166b.2 for ; Thu, 16 Jul 2026 07:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784212218; x=1784817018; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pYdU4t2+gE6AXuv8NtGQXs6INIroF6XnwJU0+W2hmSY=; b=U7FQ5ZnbopDQVhQkpFmOU3fDuxXuxizYEnQKG4oIvOjIqnzt++gbV89ZpkJ9397TdL avRlHTRrlgqqj3SvagWRXq3GvcQpTVDyM3A6dSg/hTuru8Nz3VWe5Tn1nHFy9Eo8JSN2 q95UTHUb406/leBz17hr3RSPJ40hhM+dZAv88CxQIu6DqtmjYrGcteZev7tjSlXZpyi+ sH68TTwt+mK5IgyPDg8DeS+lgHl7jxNoTDLPgKKeW5ohgmeYervOwDnRfRxIsKvOSs+C y1kxADts3aCqRlxYhdSUzCiWykHsXGDvEpy+jNJX21TnqiaPlEGTFMpHKCBCyB2/YG3T I6/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784212218; x=1784817018; h=content-type: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:content-type; bh=pYdU4t2+gE6AXuv8NtGQXs6INIroF6XnwJU0+W2hmSY=; b=FAhq66eCBopj6CxS36IaUitIrBiZQ66+HGC+r1hqQz0sGA3BTw1xplViHeOisGi/mD BexiJXgHfcpisxYNkbMZx73ECQ7QAMy/72ZyYFJOru7vAUJAdB7+OwO6AReUWrqs3oXa mCbyM+5jxZ6Iio+0I3A8gNCtkQtRKoXu4NfVQ0fZKJEcOQaF6DAorL/ERc9B3Mf1i8wO smtpGbi8VTZ0ZsD1ZCx06VchmFONKvmqaMVD8IN73D0SlmJtkDBfjy4CsU9opXfkNmUM 80ESEWAZFNFs35pwIc+qNFEaKhF+9wJr5d9ipMoiEqOrM+Trs7LreF7/S1PkFM6NUl0B AHAw== X-Gm-Message-State: AOJu0Yznh4hI3fC1H0aX746m6SGtIzNJVpJbdXW32dV50RcUkOf45qcZ uOg7r69hpUkHDWFwBkX3aPf7UdQc7svI7HGHLmvn8Y6kZc9/Bfr8MThGtmPdLgZca8MxKayJiCF 6L9EdT7r6UNVtwQ== X-Received: from ejfz17.prod.google.com ([2002:a17:906:ad1:b0:c12:6e77:2fb7]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:a710:b0:c12:6584:c1 with SMTP id a640c23a62f3a-c1667a6921dmr585573666b.40.1784212218007; Thu, 16 Jul 2026 07:30:18 -0700 (PDT) Date: Thu, 16 Jul 2026 14:30:11 +0000 In-Reply-To: <20260716-folio-alloc-cleanups-v1-0-5363b8e92d33@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260716-folio-alloc-cleanups-v1-0-5363b8e92d33@google.com> X-Mailer: b4 0.15.2 Message-ID: <20260716-folio-alloc-cleanups-v1-2-5363b8e92d33@google.com> Subject: [PATCH 2/3] mm, treewide: replace __folio_alloc_node() with folio_alloc_node() From: Brendan Jackman To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Zi Yan , "Matthew Wilcox (Oracle)" , Jan Kara , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hugh Dickins , Baolin Wang , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , "Joerg Roedel (AMD)" , Will Deacon , Robin Murphy , Huacai Chen , WANG Xuerui , Thomas Gleixner , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, iommu@lists.linux.dev, loongarch@lists.linux.dev, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Commit 5b584d2d22dca ("mm: remove __alloc_pages_node()") removed the __ variant of alloc_pages_node(), after users had been migrated off it, since it just complicates the API (requiring users to handle NUMA_NO_NODE, or risking hotplug bugs) for no real benefit. This patch brings __folio_alloc_node() into line too for exactly the same reasons (including the ulterior motive of freeing up the __ variant for use as an internal API). This time, it's done as a single patch because A) the users are fewer and B) folio_alloc_node() does not already exist like alloc_pages_node() did. No functional change intended. Suggested-by: "Vlastimil Babka (SUSE)" Link: https://lore.kernel.org/all/ed4572f4-0074-45c5-993d-7b6533eddc31@kern= el.org/ Signed-off-by: Brendan Jackman Reviewed-by: Gregory Price --- drivers/iommu/iommu-pages.c | 9 +-------- drivers/irqchip/irq-loongarch-ir.c | 4 ++-- include/linux/gfp.h | 12 +++--------- mm/filemap.c | 2 +- mm/migrate.c | 2 +- mm/page_alloc.c | 17 +++++++++++++++-- net/sunrpc/svc.c | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/iommu/iommu-pages.c b/drivers/iommu/iommu-pages.c index 3bab175d85571..47e0759f0e0ae 100644 --- a/drivers/iommu/iommu-pages.c +++ b/drivers/iommu/iommu-pages.c @@ -56,14 +56,7 @@ void *iommu_alloc_pages_node_sz(int nid, gfp_t gfp, size= _t size) */ order =3D get_order(size); =20 - /* - * __folio_alloc_node() does not handle NUMA_NO_NODE like - * alloc_pages_node() did. - */ - if (nid =3D=3D NUMA_NO_NODE) - nid =3D numa_mem_id(); - - folio =3D __folio_alloc_node(gfp | __GFP_ZERO, order, nid); + folio =3D folio_alloc_node(gfp | __GFP_ZERO, order, nid); if (unlikely(!folio)) return NULL; =20 diff --git a/drivers/irqchip/irq-loongarch-ir.c b/drivers/irqchip/irq-loong= arch-ir.c index 21c649a89a706..427f7fd3cad42 100644 --- a/drivers/irqchip/irq-loongarch-ir.c +++ b/drivers/irqchip/irq-loongarch-ir.c @@ -384,7 +384,7 @@ static int redirect_table_init(struct redirect_desc *ir= de) unsigned long *bitmap; struct folio *folio; =20 - folio =3D __folio_alloc_node(GFP_KERNEL | __GFP_ZERO, IRD_TABLE_PAGE_ORDE= R, irde->node); + folio =3D folio_alloc_node(GFP_KERNEL | __GFP_ZERO, IRD_TABLE_PAGE_ORDER,= irde->node); if (!folio) { pr_err("Node [%d] redirect table alloc pages failed!\n", irde->node); return -ENOMEM; @@ -410,7 +410,7 @@ static int redirect_queue_init(struct redirect_desc *ir= de) struct redirect_queue *inv_queue =3D &irde->inv_queue; struct folio *folio; =20 - folio =3D __folio_alloc_node(GFP_KERNEL | __GFP_ZERO, INV_QUEUE_PAGE_ORDE= R, irde->node); + folio =3D folio_alloc_node(GFP_KERNEL | __GFP_ZERO, INV_QUEUE_PAGE_ORDER,= irde->node); if (!folio) { pr_err("Node [%d] invalid queue alloc pages failed!\n", irde->node); return -ENOMEM; diff --git a/include/linux/gfp.h b/include/linux/gfp.h index e4e974a6e5f90..572605d84e30e 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -251,15 +251,9 @@ static inline void warn_if_node_offline(int this_node,= gfp_t gfp_mask) dump_stack(); } =20 -static inline -struct folio *__folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int= nid) -{ - warn_if_node_offline(nid, gfp); +struct folio *folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int n= id); =20 - return __folio_alloc_noprof(gfp, order, nid, NULL); -} - -#define __folio_alloc_node(...) alloc_hooks(__folio_alloc_node_noprof(__= VA_ARGS__)) +#define folio_alloc_node(...) alloc_hooks(folio_alloc_node_noprof(__VA_A= RGS__)) =20 /* * Allocate pages, preferring the node given as nid. When nid =3D=3D NUMA_= NO_NODE, @@ -282,7 +276,7 @@ static inline struct page *alloc_pages_noprof(gfp_t gfp= _mask, unsigned int order } static inline struct folio *folio_alloc_noprof(gfp_t gfp, unsigned int ord= er) { - return __folio_alloc_node_noprof(gfp, order, numa_node_id()); + return folio_alloc_node_noprof(gfp, order, numa_node_id()); } static inline struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_struct *vma, unsigned long addr) diff --git a/mm/filemap.c b/mm/filemap.c index 0dd8e2a15d746..1cf91970a6850 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1007,7 +1007,7 @@ struct folio *filemap_alloc_folio_noprof(gfp_t gfp, u= nsigned int order, do { cpuset_mems_cookie =3D read_mems_allowed_begin(); n =3D cpuset_mem_spread_node(); - folio =3D __folio_alloc_node_noprof(gfp, order, n); + folio =3D folio_alloc_node_noprof(gfp, order, n); } while (!folio && read_mems_allowed_retry(cpuset_mems_cookie)); =20 return folio; diff --git a/mm/migrate.c b/mm/migrate.c index 222c8c15f782f..b7836b02f32db 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2682,7 +2682,7 @@ static struct folio *alloc_misplaced_dst_folio(struct= folio *src, __GFP_NOWARN; gfp &=3D ~__GFP_RECLAIM; } - return __folio_alloc_node(gfp, order, nid); + return folio_alloc_node(gfp, order, nid); } =20 /* diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 37a3c1c00e169..86922270df157 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5435,12 +5435,25 @@ EXPORT_SYMBOL(alloc_pages_node_noprof); struct folio *__folio_alloc_noprof(gfp_t gfp, unsigned int order, int pref= erred_nid, nodemask_t *nodemask) { - struct page *page =3D __alloc_pages_noprof(gfp | __GFP_COMP, order, - preferred_nid, nodemask, ALLOC_DEFAULT); + struct page *page; + + if (preferred_nid =3D=3D NUMA_NO_NODE) + preferred_nid =3D numa_mem_id(); + + warn_if_node_offline(preferred_nid, gfp); + + page =3D __alloc_pages_noprof(gfp | __GFP_COMP, order, + preferred_nid, nodemask, ALLOC_DEFAULT); return page_rmappable_folio(page); } EXPORT_SYMBOL(__folio_alloc_noprof); =20 +struct folio *folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int n= id) +{ + return __folio_alloc_noprof(gfp, order, nid, NULL); +} +EXPORT_SYMBOL(folio_alloc_node_noprof); + /* * Common helper functions. Never use with __GFP_HIGHMEM because the retur= ned * address cannot represent highmem pages. Use alloc_pages and then kmap if diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index ae9ec4bf34f72..74350a2e07036 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -711,7 +711,7 @@ svc_prepare_thread(struct svc_serv *serv, struct svc_po= ol *pool, int node) rqstp->rq_server =3D serv; rqstp->rq_pool =3D pool; =20 - rqstp->rq_scratch_folio =3D __folio_alloc_node(GFP_KERNEL, 0, node); + rqstp->rq_scratch_folio =3D folio_alloc_node(GFP_KERNEL, 0, node); if (!rqstp->rq_scratch_folio) goto out_enomem; =20 --=20 2.54.0 From nobody Sat Jul 25 15:51:14 2026 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BC57437858 for ; Thu, 16 Jul 2026 14:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212226; cv=none; b=ImAVB1in1LP/NmSZmpXS6WogrdzmPQPkDcbKaksJ5wfVDM1muyScWHfC2MQ2HYx3iCQZlfxlsiRjXnvd7Ikpv2wdzJ3+qhuJ0Hg5DYeR88DS60YphRLpy9gwqGbUIAzmmP/+IFMFnJxzRjHMdUNu7omRs80mMzl8TiT4nX3z4jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784212226; c=relaxed/simple; bh=qzD/CNlHTImzTpy/YkW9yoSxvDfct3ktpkoKGeDbIF4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UrBBHd6FzOP+wXnhvJ2be/MnXNLhLVoKJ3weCcOdX8m/E6go32Owe/IgNtvzk1ZQbWRTXJ+n9e4oruEarqJUtcTDxeD8X+kM2D0+qRE7pdSKmiT/QnrR5hZSR/4phTfSGSnuJVW/f3KMXV4yIcJCJIpM3W603XISa0QNZ0/lpSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aMNLje+o; arc=none smtp.client-ip=209.85.208.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aMNLje+o" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-69a1ab55774so9450376a12.1 for ; Thu, 16 Jul 2026 07:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784212222; x=1784817022; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qPPMQZI6K5BD2JSD4w/twAcndg7pfdwRcZm6mUR6S/U=; b=aMNLje+ouipiMyzVuEwVIuF9Nzlc4MlzMvFwV5yIG2OXN24XAGc0OcPoFDxrCaHMaq gsvkBB8o6FPzqjkcd/kYs6EUdqZ29TFSyNmW5ghQpMDx1H5Hs5opKJx1ww4lNL6eOxSm k5fhb9ks2J9J0hvMW+cLFNGdRW3ahpDdj36IpKM+ZWWMZ0TT23fcBi7yaUvpdQ6N8WEU CsMl8odXntm9LtXWYNXvnjW9L0b3wmowcZd9u6iKkR18N0AinDjTHXorqfEnva1w7AoK RucuBD0UdvycDQfC2FfyapHEpgAxUPvs6v8ZlQYc/G8DuiMXtIxh3ZQS3ICnDbcetGKN B/Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784212222; x=1784817022; h=content-type: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:content-type; bh=qPPMQZI6K5BD2JSD4w/twAcndg7pfdwRcZm6mUR6S/U=; b=cg+ziErtDRsX1My0RpK4LppAkjSH3sjCyNtcR/z5Bv4TD2ICTVAk/DFrw4/BHW+/BG TMkIzGgQfV1JIelZoGmeUvjaZ/YxCTDmEUI9YarE/lvlSXHZ4aUVnUaKPmvXeSyXVYWN /gaUZs1lnD2GIDzipG2gmc9jpngn9qm71bfZ7t5ewjt/ER1rLDmHQVlbpKjF1dHFhgYH J4oq+G2SjKMQgjlo7BOLszd30kvjv768A0OmWCzzmftTSyKqjDoqJZwSW3cym0BfljE5 2QeaZdyID7KZTmXWopgqg18fU3WPeIUjCwL2zCj1elc73y7WYjFzJnMTvWFGjqHA3FyY YVMQ== X-Gm-Message-State: AOJu0YwjRye0F4mdqqzrvcqywlm88QMS/mMiARmxOa3tccv9pMuVR5wL RgcYp+VYeqOT3AMPtb9g6AaisD6CFsPlL21XwE+ntx52GxgQhdEbqEr8/7ujCYtLuY9dj2d4oGV 6czJZmzQaN4qC6w== X-Received: from edl2-n2.prod.google.com ([2002:a05:6402:4242:20b0:698:c0d2:794d]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:3596:b0:69c:72e2:a3d9 with SMTP id 4fb4d7f45d1cf-69e199c3870mr3879463a12.21.1784212219530; Thu, 16 Jul 2026 07:30:19 -0700 (PDT) Date: Thu, 16 Jul 2026 14:30:12 +0000 In-Reply-To: <20260716-folio-alloc-cleanups-v1-0-5363b8e92d33@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260716-folio-alloc-cleanups-v1-0-5363b8e92d33@google.com> X-Mailer: b4 0.15.2 Message-ID: <20260716-folio-alloc-cleanups-v1-3-5363b8e92d33@google.com> Subject: [PATCH 3/3] mm: move __folio_alloc() to page_alloc.h From: Brendan Jackman To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Johannes Weiner , Zi Yan , "Matthew Wilcox (Oracle)" , Jan Kara , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hugh Dickins , Baolin Wang , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , "Joerg Roedel (AMD)" , Will Deacon , Robin Murphy , Huacai Chen , WANG Xuerui , Thomas Gleixner , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, iommu@lists.linux.dev, loongarch@lists.linux.dev, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This is no longer used outside of mm so reduce the scope. Ulterior motive for the move to mm/: A later patch will add an alloc_flags arg here. Signed-off-by: Brendan Jackman Reviewed-by:Gregory Price --- include/linux/gfp.h | 4 ---- mm/page_alloc.c | 1 - mm/page_alloc.h | 4 ++++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 572605d84e30e..17c14b8ca007d 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -203,10 +203,6 @@ static inline void arch_free_page(struct page *page, i= nt order) { } static inline void arch_alloc_page(struct page *page, int order) { } #endif =20 -struct folio *__folio_alloc_noprof(gfp_t gfp, unsigned int order, int pref= erred_nid, - nodemask_t *nodemask); -#define __folio_alloc(...) alloc_hooks(__folio_alloc_noprof(__VA_ARGS__)) - unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, nodemask_t *nodemask, int nr_pages, struct page **page_array); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 86922270df157..ff8515e173e1e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5446,7 +5446,6 @@ struct folio *__folio_alloc_noprof(gfp_t gfp, unsigne= d int order, int preferred_ preferred_nid, nodemask, ALLOC_DEFAULT); return page_rmappable_folio(page); } -EXPORT_SYMBOL(__folio_alloc_noprof); =20 struct folio *folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int n= id) { diff --git a/mm/page_alloc.h b/mm/page_alloc.h index b9259deddb59d..409be31898ae7 100644 --- a/mm/page_alloc.h +++ b/mm/page_alloc.h @@ -258,6 +258,10 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned = int order, int preferred_n nodemask_t *nodemask, unsigned int alloc_flags); #define __alloc_pages(...) alloc_hooks(__alloc_pages_noprof(__VA_ARGS__)) =20 +struct folio *__folio_alloc_noprof(gfp_t gfp, unsigned int order, int pref= erred_nid, + nodemask_t *nodemask); +#define __folio_alloc(...) alloc_hooks(__folio_alloc_noprof(__VA_ARGS__)) + extern void zone_pcp_reset(struct zone *zone); extern void zone_pcp_disable(struct zone *zone); extern void zone_pcp_enable(struct zone *zone); --=20 2.54.0