]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kho: skip memoryless NUMA nodes when reserving scratch areas
authorEvangelos Petrongonas <epetron@amazon.de>
Tue, 20 Jan 2026 17:59:11 +0000 (17:59 +0000)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:20 +0000 (07:21 -0500)
[ Upstream commit 427b2535f51342de3156babc6bdc3f3b7dd2c707 ]

kho_reserve_scratch() iterates over all online NUMA nodes to allocate
per-node scratch memory.  On systems with memoryless NUMA nodes (nodes
that have CPUs but no memory), memblock_alloc_range_nid() fails because
there is no memory available on that node.  This causes KHO initialization
to fail and kho_enable to be set to false.

Some ARM64 systems have NUMA topologies where certain nodes contain only
CPUs without any associated memory.  These configurations are valid and
should not prevent KHO from functioning.

Fix this by only counting nodes that have memory (N_MEMORY state) and skip
memoryless nodes in the per-node scratch allocation loop.

Link: https://lkml.kernel.org/r/20260120175913.34368-1-epetron@amazon.de
Fixes: 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers").
Signed-off-by: Evangelos Petrongonas <epetron@amazon.de>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Alexander Graf <graf@amazon.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/kexec_handover.c

index 03d12e27189fc4733bfcb20f30533ba00285f56f..2da4bd994322f5000ac7d1281ad1420d637d35f0 100644 (file)
@@ -619,7 +619,7 @@ static void __init kho_reserve_scratch(void)
        scratch_size_update();
 
        /* FIXME: deal with node hot-plug/remove */
-       kho_scratch_cnt = num_online_nodes() + 2;
+       kho_scratch_cnt = nodes_weight(node_states[N_MEMORY]) + 2;
        size = kho_scratch_cnt * sizeof(*kho_scratch);
        kho_scratch = memblock_alloc(size, PAGE_SIZE);
        if (!kho_scratch)
@@ -649,7 +649,11 @@ static void __init kho_reserve_scratch(void)
        kho_scratch[i].size = size;
        i++;
 
-       for_each_online_node(nid) {
+       /*
+        * Loop over nodes that have both memory and are online. Skip
+        * memoryless nodes, as we can not allocate scratch areas there.
+        */
+       for_each_node_state(nid, N_MEMORY) {
                size = scratch_size_node(nid);
                addr = memblock_alloc_range_nid(size, CMA_MIN_ALIGNMENT_BYTES,
                                                0, MEMBLOCK_ALLOC_ACCESSIBLE,