Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats
@ 2026-07-29 15:51 Sang-Heon Jeon
  2026-07-29 20:27 ` Andrew Morton
  2026-07-30  7:06 ` Mike Rapoport
  0 siblings, 2 replies; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-07-29 15:51 UTC (permalink / raw)
  To: Andrew Morton, Mike Rapoport; +Cc: linux-mm

free_area_init_node() sets pgdat->per_cpu_nodestats to NULL and later
calls free_area_init_core(), which unconditionally overwrites it with
&boot_nodestats. Nothing reads the field in between, so the store has
no effect.

Remove unnecessary initialization. No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
 mm/mm_init.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 711f821f7b3c..367b03623f89 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1722,7 +1722,6 @@ static void __init free_area_init_node(int nid)
 
 	pgdat->node_id = nid;
 	pgdat->node_start_pfn = start_pfn;
-	pgdat->per_cpu_nodestats = NULL;
 
 	if (start_pfn != end_pfn) {
 		pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
-- 
2.43.0



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

* Re: [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats
  2026-07-29 15:51 [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats Sang-Heon Jeon
@ 2026-07-29 20:27 ` Andrew Morton
  2026-07-30  6:58   ` Mike Rapoport
  2026-07-30  7:06 ` Mike Rapoport
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-07-29 20:27 UTC (permalink / raw)
  To: Sang-Heon Jeon; +Cc: Mike Rapoport, linux-mm

On Thu, 30 Jul 2026 00:51:15 +0900 Sang-Heon Jeon <ekffu200098@gmail.com> wrote:

> free_area_init_node() sets pgdat->per_cpu_nodestats to NULL and later
> calls free_area_init_core(), which unconditionally overwrites it with
> &boot_nodestats. Nothing reads the field in between, so the store has
> no effect.
> 
> Remove unnecessary initialization. No functional change.
> 
> ...
>
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1722,7 +1722,6 @@ static void __init free_area_init_node(int nid)
>  
>  	pgdat->node_id = nid;
>  	pgdat->node_start_pfn = start_pfn;
> -	pgdat->per_cpu_nodestats = NULL;
>  
>  	if (start_pfn != end_pfn) {
>  		pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,

Looks OK, thanks.  Although this statement is "free" in __init code and
its removal does make the code that bit harder to follow.

Possibly *pgdat was zeroed out anyway, I got bored figuring that out. 
The memblock_alloc_range_nid() kerneldoc is silent on the state of the
returned memory but I spy a kzalloc_node() in there.


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

* Re: [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats
  2026-07-29 20:27 ` Andrew Morton
@ 2026-07-30  6:58   ` Mike Rapoport
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-07-30  6:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Sang-Heon Jeon, linux-mm

On Wed, Jul 29, 2026 at 01:27:45PM -0700, Andrew Morton wrote:
> On Thu, 30 Jul 2026 00:51:15 +0900 Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> 
> > free_area_init_node() sets pgdat->per_cpu_nodestats to NULL and later
> > calls free_area_init_core(), which unconditionally overwrites it with
> > &boot_nodestats. Nothing reads the field in between, so the store has
> > no effect.
> > 
> > Remove unnecessary initialization. No functional change.
> > 
> > ...
> >
> > --- a/mm/mm_init.c
> > +++ b/mm/mm_init.c
> > @@ -1722,7 +1722,6 @@ static void __init free_area_init_node(int nid)
> >  
> >  	pgdat->node_id = nid;
> >  	pgdat->node_start_pfn = start_pfn;
> > -	pgdat->per_cpu_nodestats = NULL;
> >  
> >  	if (start_pfn != end_pfn) {
> >  		pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
> 
> Looks OK, thanks.  Although this statement is "free" in __init code and
> its removal does make the code that bit harder to follow.

Heh, it's already not that easy to follow :)

We initialize a few fields in pgdat, then setup node and its zone sizes,
then return to initialization of the rest of pgdat internals.

It feels like we need a larger cleanup there, and this patch wouldn't
really move a needle.
 
> Possibly *pgdat was zeroed out anyway, I got bored figuring that out. 
> The memblock_alloc_range_nid() kerneldoc is silent on the state of the
> returned memory but I spy a kzalloc_node() in there.

memblock_alloc_range_nid() does not zero the memory, unless inappropriately
called after slab_is_available(). But alloc_node_data() that allocates
pgdat's does :)

-- 
Sincerely yours,
Mike.


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

* Re: [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats
  2026-07-29 15:51 [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats Sang-Heon Jeon
  2026-07-29 20:27 ` Andrew Morton
@ 2026-07-30  7:06 ` Mike Rapoport
  1 sibling, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-07-30  7:06 UTC (permalink / raw)
  To: Andrew Morton, Sang-Heon Jeon; +Cc: linux-mm

On Thu, 30 Jul 2026 00:51:15 +0900, Sang-Heon Jeon wrote:
> mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats

Applied to misc branch of memblock.git tree, thanks!

[1/1] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats
      commit: 78fac571b06490654af45c902c7ab5f651fe7067

tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
branch: misc

--
Sincerely yours,
Mike.




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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 15:51 [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats Sang-Heon Jeon
2026-07-29 20:27 ` Andrew Morton
2026-07-30  6:58   ` Mike Rapoport
2026-07-30  7:06 ` Mike Rapoport

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