Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Sang-Heon Jeon <ekffu200098@gmail.com>, linux-mm@kvack.org
Subject: Re: [PATCH] mm/mm_init: remove unnecessary initialization of pgdat->per_cpu_nodestats
Date: Thu, 30 Jul 2026 09:58:01 +0300	[thread overview]
Message-ID: <amr1-eQ8twFONiew@kernel.org> (raw)
In-Reply-To: <20260729132745.9d42a13e614be2e18c5988ba@linux-foundation.org>

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.


  reply	other threads:[~2026-07-30  6:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-07-30  7:06 ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=amr1-eQ8twFONiew@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ekffu200098@gmail.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox