mm: page_alloc: call panic() when memoryless node allocation fails
authorQi Zheng <zhengqi.arch@bytedance.com>
Sun, 12 Feb 2023 11:10:27 +0000 (19:10 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 17 Feb 2023 04:43:54 +0000 (20:43 -0800)
In free_area_init(), we will continue to run after allocation of
memoryless node pgdat fails.  However, in the subsequent process (such as
when initializing zonelist), the case that NODE_DATA(nid) is NULL is not
handled, which will cause panic.  Instead of this, it's better to call
panic() directly when the memory allocation fails during system boot.

Link: https://lkml.kernel.org/r/20230212111027.95520-1-zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index 21d820c429007d4264db5b5acce364d7789b4ed2..4b6bcec41c8f5efba35f866e052366350caa36a7 100644 (file)
@@ -8405,11 +8405,9 @@ void __init free_area_init(unsigned long *max_zone_pfn)
 
                        /* Allocator not initialized yet */
                        pgdat = arch_alloc_nodedata(nid);
-                       if (!pgdat) {
-                               pr_err("Cannot allocate %zuB for node %d.\n",
-                                               sizeof(*pgdat), nid);
-                               continue;
-                       }
+                       if (!pgdat)
+                               panic("Cannot allocate %zuB for node %d.\n",
+                                      sizeof(*pgdat), nid);
                        arch_refresh_nodedata(nid, pgdat);
                        free_area_init_memoryless_node(nid);