Re: [PATCH] mm/mm_init: handle alloc_percpu failure in free_area_init_core_hotplug
From: David Hildenbrand (Arm)
Date: Wed Jul 01 2026 - 04:36:04 EST
> * 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?
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?)
--
Cheers,
David