Linux-mm Archive on 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

* Re: [PATCH v2] mm/hugetlb: move hugetlb_sysfs_initialized into hugetlb_register_all_nodes()
  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
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand (Arm) @ 2026-10-09 18:02 UTC (permalink / raw)
  To: Enze Li, muchun.song, osalvador, akpm; +Cc: linux-mm, enze.li

On 10/9/26 16:20, Enze Li wrote:
> 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>
> ---

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


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

* Re: [PATCH v2] mm/hugetlb: move hugetlb_sysfs_initialized into hugetlb_register_all_nodes()
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Muchun Song @ 2026-10-10  2:51 UTC (permalink / raw)
  To: Enze Li; +Cc: osalvador, david, akpm, linux-mm, enze.li



> On Oct 9, 2026, at 22:20, Enze Li <lienze@kylinos.cn> wrote:
> 
> 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>

Reviewed-by: Muchun Song <muchun.song@linux.dev>

Thanks.



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

* Re: [PATCH v2] mm/hugetlb: move hugetlb_sysfs_initialized into hugetlb_register_all_nodes()
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2026-10-10 22:41 UTC (permalink / raw)
  To: Enze Li; +Cc: muchun.song, osalvador, david, linux-mm, enze.li

On Fri,  9 Oct 2026 22:20:10 +0800 Enze Li <lienze@kylinos.cn> wrote:

> 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.

Thanks.

What's missing here is "why".  What effect does this have.

$LLM tells me

	No functional change; its an #ifdef cleanup.

which I shall add to the changelog.


^ permalink raw reply	[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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox