From: Mike Rapoport <rppt@kernel.org>
To: Evangelos Petrongonas <epetron@amazon.de>,
Pratyush Yadav <pratyush@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
Alexander Graf <graf@amazon.com>, Jason Miu <jasonmiu@google.com>,
linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
linux-mm@kvack.org, nh-open-source@amazon.com
Subject: Re: [PATCH] kho: skip memoryless NUMA nodes when reserving scratch areas
Date: Sun, 18 Jan 2026 14:16:33 +0200 [thread overview]
Message-ID: <aWzPIfZ0WeH0vca8@kernel.org> (raw)
In-Reply-To: <2vxzsec57oth.fsf@kernel.org>
On Fri, Jan 16, 2026 at 11:57:14AM +0000, Pratyush Yadav wrote:
> Hi Evangelos,
>
> On Fri, Jan 16 2026, 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 introducing kho_mem_nodes_count() which counts only nodes
> > that have memory (N_MEMORY state), and skip memoryless nodes in the
> > per-node scratch allocation loop.
> >
> > Signed-off-by: Evangelos Petrongonas <epetron@amazon.de>
> > ---
> > kernel/liveupdate/kexec_handover.c | 23 ++++++++++++++++++++++-
> > 1 file changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> > index 9dc51fab604f..c970ed08b477 100644
> > --- a/kernel/liveupdate/kexec_handover.c
> > +++ b/kernel/liveupdate/kexec_handover.c
> > @@ -623,6 +623,23 @@ static phys_addr_t __init scratch_size_node(int nid)
> > return round_up(size, CMA_MIN_ALIGNMENT_BYTES);
> > }
> >
> > +/*
> > + * Count online NUMA nodes that have memory. Memoryless nodes cannot have
> > + * scratch memory and should be excluded.
> > + */
> > +static unsigned int __init kho_mem_nodes_count(void)
> > +{
> > + unsigned int cnt = 0;
> > + int nid;
> > +
> > + for_each_online_node(nid) {
> > + if (node_state(nid, N_MEMORY))
> > + cnt++;
> > + }
> > +
> > + return cnt;
> > +}
> > +
>
> You don't need this. You can use nodes_weight(nodes_state[N_MEMORY])
> directly. Other than this, LGTM.
>
> > /**
> > * kho_reserve_scratch - Reserve a contiguous chunk of memory for kexec
> > *
> > @@ -643,7 +660,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 = kho_mem_nodes_count() + 2;
> > size = kho_scratch_cnt * sizeof(*kho_scratch);
> > kho_scratch = memblock_alloc(size, PAGE_SIZE);
> > if (!kho_scratch)
> > @@ -674,6 +691,10 @@ static void __init kho_reserve_scratch(void)
> > i++;
> >
> > for_each_online_node(nid) {
> > + /* Skip memoryless nodes - we cannot allocate scratch memory there */
> > + if (!node_state(nid, N_MEMORY))
> > + continue;
> > +
And here you can use 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,
>
> --
> Regards,
> Pratyush Yadav
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2026-01-18 12:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 11:26 Evangelos Petrongonas
2026-01-16 11:57 ` Pratyush Yadav
2026-01-18 12:16 ` Mike Rapoport [this message]
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=aWzPIfZ0WeH0vca8@kernel.org \
--to=rppt@kernel.org \
--cc=epetron@amazon.de \
--cc=graf@amazon.com \
--cc=jasonmiu@google.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nh-open-source@amazon.com \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@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