All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm/hugetlb: move hugetlb_sysfs_initialized into hugetlb_register_all_nodes()
@ 2026-10-09 14:20 Enze Li
  2026-10-09 18:02 ` David Hildenbrand (Arm)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Enze Li @ 2026-10-09 14:20 UTC (permalink / raw)
  To: muchun.song, osalvador, david, akpm; +Cc: linux-mm, enze.li, Enze Li

hugetlb_sysfs_init() guards the "hugetlb_sysfs_initialized = true"
assignment with an #ifdef CONFIG_NUMA block, while the following
hugetlb_register_all_nodes() call is left unguarded and relies on the empty
!CONFIG_NUMA stub.

Move the assignment into the NUMA version of hugetlb_register_all_nodes(),
before it registers the online nodes, so the #ifdef in hugetlb_sysfs_init()
can go away.  Keep the !CONFIG_NUMA stub, so the call site is unconditional
in both configurations.

Suggested-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Enze Li <lienze@kylinos.cn>
---
v2:
  - Keep the !CONFIG_NUMA stub and move "hugetlb_sysfs_initialized = true"
    into hugetlb_register_all_nodes() instead, so the #ifdef in
    hugetlb_sysfs_init() can be dropped, as suggested by Muchun Song.

 mm/hugetlb_sysfs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/hugetlb_sysfs.c b/mm/hugetlb_sysfs.c
index 326a54b4d991..c89e4c847575 100644
--- a/mm/hugetlb_sysfs.c
+++ b/mm/hugetlb_sysfs.c
@@ -462,6 +462,8 @@ static void __init hugetlb_register_all_nodes(void)
 {
 	int nid;
 
+	hugetlb_sysfs_initialized = true;
+
 	for_each_online_node(nid)
 		hugetlb_register_node(node_devices[nid]);
 }
@@ -495,8 +497,5 @@ void __init hugetlb_sysfs_init(void)
 			pr_err("HugeTLB: Unable to add hstate %s\n", h->name);
 	}
 
-#ifdef CONFIG_NUMA
-	hugetlb_sysfs_initialized = true;
-#endif
 	hugetlb_register_all_nodes();
 }

base-commit: 8b38ed9ab5b09c8ba168cbcc49524e9b380ee5c4
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-10 22:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-09 14:20 [PATCH v2] mm/hugetlb: move hugetlb_sysfs_initialized into hugetlb_register_all_nodes() Enze Li
2026-10-09 18:02 ` David Hildenbrand (Arm)
2026-10-10  2:51 ` Muchun Song
2026-10-10 22:41 ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.