[PATCH 2/3] mm, treewide: replace __folio_alloc_node() with folio_alloc_node()
From: Brendan Jackman <jackmanb@google.com>
Date: 2026-07-16 14:30:20
Also in:
linux-fsdevel, linux-iommu, linux-mm, linux-nfs, lkml, loongarch
Subsystem:
iommu subsystem, irqchip drivers, kernel nfsd, sunrpc, and lockd servers, loongarch, memory management, memory management - core, memory management - memory policy and migration, memory management - page allocator, networking [general], nfs, sunrpc, and lockd clients, page cache, the rest · Maintainers:
Joerg Roedel, Will Deacon, Thomas Gleixner, Chuck Lever, Jeff Layton, Huacai Chen, Andrew Morton, David Hildenbrand, Vlastimil Babka, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Trond Myklebust, Anna Schumaker, Matthew Wilcox, Jan Kara, Linus Torvalds
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)" <vbabka@kernel.org>
Link: https://lore.kernel.org/all/ed4572f4-0074-45c5-993d-7b6533eddc31@kernel.org/ (local)
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
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 = get_order(size); - /* - * __folio_alloc_node() does not handle NUMA_NO_NODE like - * alloc_pages_node() did. - */ - if (nid == NUMA_NO_NODE) - nid = numa_mem_id(); - - folio = __folio_alloc_node(gfp | __GFP_ZERO, order, nid); + folio = folio_alloc_node(gfp | __GFP_ZERO, order, nid); if (unlikely(!folio)) return NULL;
diff --git a/drivers/irqchip/irq-loongarch-ir.c b/drivers/irqchip/irq-loongarch-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 *irde) unsigned long *bitmap; struct folio *folio; - folio = __folio_alloc_node(GFP_KERNEL | __GFP_ZERO, IRD_TABLE_PAGE_ORDER, irde->node); + folio = 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 *irde) struct redirect_queue *inv_queue = &irde->inv_queue; struct folio *folio; - folio = __folio_alloc_node(GFP_KERNEL | __GFP_ZERO, INV_QUEUE_PAGE_ORDER, irde->node); + folio = 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(); } -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 nid); - 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_ARGS__)) /* * Allocate pages, preferring the node given as nid. When nid == 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 order) { - 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, unsigned int order, do { cpuset_mems_cookie = read_mems_allowed_begin(); n = cpuset_mem_spread_node(); - folio = __folio_alloc_node_noprof(gfp, order, n); + folio = folio_alloc_node_noprof(gfp, order, n); } while (!folio && read_mems_allowed_retry(cpuset_mems_cookie)); 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 &= ~__GFP_RECLAIM; } - return __folio_alloc_node(gfp, order, nid); + return folio_alloc_node(gfp, order, nid); } /*
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 preferred_nid, nodemask_t *nodemask) { - struct page *page = __alloc_pages_noprof(gfp | __GFP_COMP, order, - preferred_nid, nodemask, ALLOC_DEFAULT); + struct page *page; + + if (preferred_nid == NUMA_NO_NODE) + preferred_nid = numa_mem_id(); + + warn_if_node_offline(preferred_nid, gfp); + + page = __alloc_pages_noprof(gfp | __GFP_COMP, order, + preferred_nid, nodemask, ALLOC_DEFAULT); return page_rmappable_folio(page); } EXPORT_SYMBOL(__folio_alloc_noprof); +struct folio *folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int nid) +{ + return __folio_alloc_noprof(gfp, order, nid, NULL); +} +EXPORT_SYMBOL(folio_alloc_node_noprof); + /* * Common helper functions. Never use with __GFP_HIGHMEM because the returned * 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_pool *pool, int node) rqstp->rq_server = serv; rqstp->rq_pool = pool; - rqstp->rq_scratch_folio = __folio_alloc_node(GFP_KERNEL, 0, node); + rqstp->rq_scratch_folio = folio_alloc_node(GFP_KERNEL, 0, node); if (!rqstp->rq_scratch_folio) goto out_enomem;
--
2.54.0