From: Gregory Price <gourry@gourry.net>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-cxl@vger.kernel.org, kernel-team@meta.com,
osalvador@suse.de, akpm@linux-foundation.org, rppt@kernel.org,
mgorman@techsingularity.net, hannes@cmpxchg.org,
vbabka@kernel.org
Subject: Re: [PATCH] mm/mm_init: handle alloc_percpu failure in free_area_init_core_hotplug
Date: Wed, 1 Jul 2026 11:05:48 -0400 [thread overview]
Message-ID: <akUszCySPFA7IRlb@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <b8baae33-d551-40fe-abb5-287f3711dd80@kernel.org>
On Wed, Jul 01, 2026 at 10:35:41AM +0200, David Hildenbrand (Arm) wrote:
>
> > * The node we allocated has no zone fallback lists. For avoiding
> > diff --git a/mm/mm_init.c b/mm/mm_init.c
> > index 306ea5c13f54..37fd64ce144d 100644
> > --- a/mm/mm_init.c
> > +++ b/mm/mm_init.c
> > @@ -1536,7 +1536,7 @@ void __init set_pageblock_order(void)
> > * NOTE: this function is only called during memory hotplug
> > */
> > #ifdef CONFIG_MEMORY_HOTPLUG
> > -void __ref free_area_init_core_hotplug(struct pglist_data *pgdat)
> > +int __ref free_area_init_core_hotplug(struct pglist_data *pgdat)
> > {
> > int nid = pgdat->node_id;
> > enum zone_type z;
> > @@ -1544,8 +1544,14 @@ void __ref free_area_init_core_hotplug(struct pglist_data *pgdat)
> >
> > pgdat_init_internals(pgdat);
> >
> > - if (pgdat->per_cpu_nodestats == &boot_nodestats)
> > - pgdat->per_cpu_nodestats = alloc_percpu(struct per_cpu_nodestat);
> > + if (pgdat->per_cpu_nodestats == &boot_nodestats) {
> > + struct per_cpu_nodestat __percpu *p;
> > +
> > + p = alloc_percpu(struct per_cpu_nodestat);
> > + if (!p)
> > + return -ENOMEM;
> > + pgdat->per_cpu_nodestats = p;
>
> Is there a need for the temporary variable?
>
at start:
pgdat->per_cpu_nodestats = &boot_nodestats
So need a tmp to do the swap/revert/etc
> Also how to handle cleanup on error? Or why can we skip cleanup? (what happens
> if we get another call to __try_online_node() later?)
>
-ENOMEM ->
hotadd_init_pgdat -> NULL
__try_online_node -> -ENOMEM
pr_err("Cannot online node %d due to NULL pgdat\n", nid);
try_online_node -> -ENOMEM
__add_memory_resource -> error_memblock_remove:
Basically we're left exactly where we were before we made the attempt.
Another call should work just fine after a bunch of dmesg spew.
If this happens during boot via add_memory then something else is
horribly horribly wrong and we'll at least get some debug info instead
of null deref.
~Gregory
next prev parent reply other threads:[~2026-07-01 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 21:40 [PATCH] mm/mm_init: handle alloc_percpu failure in free_area_init_core_hotplug Gregory Price
2026-07-01 6:38 ` Mike Rapoport
2026-07-01 15:20 ` Gregory Price
2026-07-01 20:14 ` Mike Rapoport
2026-07-01 8:35 ` David Hildenbrand (Arm)
2026-07-01 15:05 ` Gregory Price [this message]
2026-07-01 16:54 ` David Hildenbrand (Arm)
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=akUszCySPFA7IRlb@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=vbabka@kernel.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