From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51775466B71 for ; Tue, 20 Jan 2026 19:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768935614; cv=none; b=Gsg+3Z2C2qkGY/OAC5+j8l1OmUVzgokL/JLLSm/5R7bCC77yMxXhoihD9/znR/1OvIu+3RiZxM6fkdhqPBNwzJecwrxXZ+YWvMPKrgMNd/gARh8U40lB2ujETfKAi4zQf3qUNjsLBBDh4k+pVITMZtIkMbRnrg55Mm8zDPF15UA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768935614; c=relaxed/simple; bh=yvQMSUis/1NCpptkFQ9k3gZYHiivZOEOD7LfuZ7H1ks=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iyTzCsEbO5stLBEq46lNOqfmnGoZClzonuvKmpMheFqjJtaC3valOohn8gwOC4pR+1D68BQZgbP0rW7p1/lNOsnwojOqdrtdh9aXH/zDxmi/ml/N5y8xshMY9a5+IHLl6WkminHJhLKgSh8NdBxNDCnGwa6DILJxZHyCFusWM1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bxw8pyjH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bxw8pyjH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A071C16AAE; Tue, 20 Jan 2026 19:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768935614; bh=yvQMSUis/1NCpptkFQ9k3gZYHiivZOEOD7LfuZ7H1ks=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bxw8pyjHejSup2eL6mvA96uU19t1osAViIerhPz9jEnZivgiUot4+fBfGEx0iha+T tXrlbmjA2vd6EeDIeLRb2kKyZz70+J3Lr77AfxsAALlJdTn0+9HmXJY2vVEfquWKl+ /kUgz8xUTkbXsDISlW7QbcnuTK+LqCWkiBo4cft+B3f0bWY8VaUZvdrh5qXW97zWu+ Xwojtdzz62UqOT6v+AEq2StJ47k/j+r5XCK4QMrieSUO8Dxi0VYsRqff8ZaCPywzDC kk+ZxOYZl+u0wBH1Yd6NDCEzY7/NzyT+lk7J1sMjayMtIa2SKc2vNKYRBOWT+MAnMQ 3/uXHubLDOvIA== Date: Tue, 20 Jan 2026 21:00:07 +0200 From: Mike Rapoport To: Evangelos Petrongonas Cc: Pasha Tatashin , Pratyush Yadav , Alexander Graf , Jason Miu , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, nh-open-source@amazon.com Subject: Re: [PATCH v2] kho: skip memoryless NUMA nodes when reserving scratch areas Message-ID: References: <20260120175913.34368-1-epetron@amazon.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260120175913.34368-1-epetron@amazon.de> On Tue, Jan 20, 2026 at 05:59:11PM +0000, Evangelos Petrongonas wrote: > 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. > > Signed-off-by: Evangelos Petrongonas Reviewed-by: Mike Rapoport (Microsoft) > --- > v2: > - Removed kho_mem_nodes_count in favour of nodes_weight(nodes_state[N_MEMORY]) > - Use for_each_node_state(nid, N_MEMORY) to loop over nodes that are both > online and have memory. > TIL: Nodes in N_MEMORY are a subset of those that are online. Thanks Mike :) > > kernel/liveupdate/kexec_handover.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index 9dc51fab604f..979ebaf015bf 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -643,7 +643,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) > @@ -673,7 +673,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, > -- > 2.43.0 > > > > > Amazon Web Services Development Center Germany GmbH > Tamara-Danz-Str. 13 > 10243 Berlin > Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger > Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B > Sitz: Berlin > Ust-ID: DE 365 538 597 > -- Sincerely yours, Mike.