mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arch_numa: remove redundant nodemask clears in numa_init()
@ 2026-06-17 16:39 Sang-Heon Jeon
  2026-06-18  9:58 ` Mike Rapoport
  2026-06-25  3:40 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-06-17 16:39 UTC (permalink / raw)
  To: rppt, akpm, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
  Cc: linux-mm, Sang-Heon Jeon, driver-core, linux-kernel

numa_init() clears numa_nodes_parsed, node_possible_map and
node_online_map, then calls numa_memblks_init(), which clears the same
nodemasks. Nothing uses them in between.

These clears have been redundant since commit 767507654c22 ("arch_numa:
switch over to numa_memblks") made numa_init() use numa_memblks_init().

No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
 drivers/base/arch_numa.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
index c99f2ab105e5..442ea239bba7 100644
--- a/drivers/base/arch_numa.c
+++ b/drivers/base/arch_numa.c
@@ -231,10 +231,6 @@ static int __init numa_init(int (*init_func)(void))
 {
 	int ret;
 
-	nodes_clear(numa_nodes_parsed);
-	nodes_clear(node_possible_map);
-	nodes_clear(node_online_map);
-
 	ret = numa_memblks_init(init_func, /* memblock_force_top_down */ false);
 	if (ret < 0)
 		goto out_free_distance;
-- 
2.43.0


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

* Re: [PATCH] arch_numa: remove redundant nodemask clears in numa_init()
  2026-06-17 16:39 [PATCH] arch_numa: remove redundant nodemask clears in numa_init() Sang-Heon Jeon
@ 2026-06-18  9:58 ` Mike Rapoport
  2026-06-25  3:40 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-06-18  9:58 UTC (permalink / raw)
  To: Sang-Heon Jeon
  Cc: akpm, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	linux-mm, driver-core, linux-kernel

On Thu, Jun 18, 2026 at 01:39:19AM +0900, Sang-Heon Jeon wrote:
> numa_init() clears numa_nodes_parsed, node_possible_map and
> node_online_map, then calls numa_memblks_init(), which clears the same
> nodemasks. Nothing uses them in between.
> 
> These clears have been redundant since commit 767507654c22 ("arch_numa:
> switch over to numa_memblks") made numa_init() use numa_memblks_init().
> 
> No functional change.
> 
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  drivers/base/arch_numa.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
> index c99f2ab105e5..442ea239bba7 100644
> --- a/drivers/base/arch_numa.c
> +++ b/drivers/base/arch_numa.c
> @@ -231,10 +231,6 @@ static int __init numa_init(int (*init_func)(void))
>  {
>  	int ret;
>  
> -	nodes_clear(numa_nodes_parsed);
> -	nodes_clear(node_possible_map);
> -	nodes_clear(node_online_map);
> -
>  	ret = numa_memblks_init(init_func, /* memblock_force_top_down */ false);
>  	if (ret < 0)
>  		goto out_free_distance;
> -- 
> 2.43.0
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH] arch_numa: remove redundant nodemask clears in numa_init()
  2026-06-17 16:39 [PATCH] arch_numa: remove redundant nodemask clears in numa_init() Sang-Heon Jeon
  2026-06-18  9:58 ` Mike Rapoport
@ 2026-06-25  3:40 ` Andrew Morton
  2026-06-25  7:31   ` Sang-Heon Jeon
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-06-25  3:40 UTC (permalink / raw)
  To: Sang-Heon Jeon
  Cc: rppt, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	linux-mm, driver-core, linux-kernel

On Thu, 18 Jun 2026 01:39:19 +0900 Sang-Heon Jeon <ekffu200098@gmail.com> wrote:

> numa_init() clears numa_nodes_parsed, node_possible_map and
> node_online_map, then calls numa_memblks_init(), which clears the same
> nodemasks. Nothing uses them in between.
> 
> These clears have been redundant since commit 767507654c22 ("arch_numa:
> switch over to numa_memblks") made numa_init() use numa_memblks_init().
> 
> No functional change.
> 
> ...
>
> --- a/drivers/base/arch_numa.c
> +++ b/drivers/base/arch_numa.c
> @@ -231,10 +231,6 @@ static int __init numa_init(int (*init_func)(void))
>  {
>  	int ret;
>  
> -	nodes_clear(numa_nodes_parsed);
> -	nodes_clear(node_possible_map);
> -	nodes_clear(node_online_map);
> -
>  	ret = numa_memblks_init(init_func, /* memblock_force_top_down */ false);
>  	if (ret < 0)
>  		goto out_free_distance;

hm, OK, thanks.


A couple of driveby questions:

Are the other nodes_clear() calls are needed - aren't these things
zeroed when the kernel is loaded?


Also, 

#define node_possible_map 	node_states[N_POSSIBLE]

...

nodemask_t node_states[NR_NODE_STATES] __read_mostly = {
	[N_POSSIBLE] = NODE_MASK_ALL,

why do we carefully initialize node_possible_map at compile-time then
zero it within __init code?



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

* Re: [PATCH] arch_numa: remove redundant nodemask clears in numa_init()
  2026-06-25  3:40 ` Andrew Morton
@ 2026-06-25  7:31   ` Sang-Heon Jeon
  0 siblings, 0 replies; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-06-25  7:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: rppt, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	linux-mm, driver-core, linux-kernel

On Thu, Jun 25, 2026 at 12:40 PM Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> On Thu, 18 Jun 2026 01:39:19 +0900 Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> > numa_init() clears numa_nodes_parsed, node_possible_map and
> > node_online_map, then calls numa_memblks_init(), which clears the same
> > nodemasks. Nothing uses them in between.
> >
> > These clears have been redundant since commit 767507654c22 ("arch_numa:
> > switch over to numa_memblks") made numa_init() use numa_memblks_init().
> >
> > No functional change.
> >
> > ...
> >
> > --- a/drivers/base/arch_numa.c
> > +++ b/drivers/base/arch_numa.c
> > @@ -231,10 +231,6 @@ static int __init numa_init(int (*init_func)(void))
> >  {
> >       int ret;
> >
> > -     nodes_clear(numa_nodes_parsed);
> > -     nodes_clear(node_possible_map);
> > -     nodes_clear(node_online_map);
> > -
> >       ret = numa_memblks_init(init_func, /* memblock_force_top_down */ false);
> >       if (ret < 0)
> >               goto out_free_distance;
>
> hm, OK, thanks.
>
>
> A couple of driveby questions:
>
> Are the other nodes_clear() calls are needed - aren't these things
> zeroed when the kernel is loaded?
>

You're talking about nodes_clear() in numa_memblks_init(), right? If
so, I think they're needed.
Because numa_memblks_init() can run more than once during boot, and a
previous call can leave the maps dirty.

More detailed example, If we first try to set up NUMA from DT,
numa_memblks_init(of_numa_init) is called.
of_numa_init() parses the CPU and memory nodes in order, so if parsing
the CPU nodes succeed but the memory nodes fail, the CPU-node bits are
still set in numa_nodes_parsed.
We then fall back to calling numa_memblks_init(dummy_numa_init). Since
dummy_numa_init() only sets node 0, those stale bits could survive
unexpectedly without nodes_clear().

> Also,
>
> #define node_possible_map       node_states[N_POSSIBLE]
>
> ...
>
> nodemask_t node_states[NR_NODE_STATES] __read_mostly = {
>         [N_POSSIBLE] = NODE_MASK_ALL,
>
> why do we carefully initialize node_possible_map at compile-time then
> zero it within __init code?
>

I also can't find why we initialize node_possible_map carefully, at
least for NUMA.
I'm not sure it's safe to remove initialization with UMA. I'll take a
closer look when I have time, and send a patch to remove them if it's
safe to remove.


Best Regards,
Sang-Heon Jeon

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

end of thread, other threads:[~2026-06-25  7:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 16:39 [PATCH] arch_numa: remove redundant nodemask clears in numa_init() Sang-Heon Jeon
2026-06-18  9:58 ` Mike Rapoport
2026-06-25  3:40 ` Andrew Morton
2026-06-25  7:31   ` Sang-Heon Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome