From: Yury Norov <ynorov@nvidia.com>
To: Hui Su <sh_def@163.com>
Cc: Yury Norov <yury.norov@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpumask: Fall back to online CPUs when NUMA lookup fails
Date: Fri, 23 Oct 2026 11:24:31 -0400 [thread overview]
Message-ID: <att8L4Q_eeTOXGXV@yury> (raw)
In-Reply-To: <20261021060352.1351469-1-sh_def@163.com>
On Wed, Oct 21, 2026 at 03:03:52PM +0900, Hui Su wrote:
> cpumask_local_spread() wraps the requested index by the number of
> online CPUs, but sched_numa_find_nth_cpu() can return nr_cpu_ids
> when NUMA ordering masks are unavailable.
>
> This can happen after a sched_init_numa() allocation failure or
> while the NUMA topology is being rebuilt.
>
> Since b1beed72b8b75, cpumask_local_spread() warns about the
> invalid result but still returns it to callers expecting a
> valid CPU number.
>
> When the NUMA lookup fails, warn once and fall back to the
> corresponding entry in cpu_online_mask. This preserves a valid
> CPU result when the online mask is stable, at the expense of
> NUMA ordering while the topology information is unavailable.
When the topology is unavailable, it's wrong to call this function.
If you do so, you anyways can't achieve optimal placement, so
returning a no-found looks reasonable.
Can you explain, is this a real bug in your deployment? Can you share
details?
Thanks,
Yury
> Fixes: b1beed72b8b75 ("lib/cpumask: reorganize cpumask_local_spread() logic")
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
> lib/cpumask.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/cpumask.c b/lib/cpumask.c
> index 5adb9874fbd0f..f09632219b267 100644
> --- a/lib/cpumask.c
> +++ b/lib/cpumask.c
> @@ -114,7 +114,9 @@ unsigned int cpumask_local_spread(unsigned int i, int node)
>
> cpu = sched_numa_find_nth_cpu(cpu_online_mask, i, node);
>
> - WARN_ON(cpu >= nr_cpu_ids);
> + if (WARN_ON_ONCE(cpu >= nr_cpu_ids))
> + cpu = cpumask_nth(i, cpu_online_mask);
> +
> return cpu;
> }
> EXPORT_SYMBOL(cpumask_local_spread);
>
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
> --
> 2.55.0
prev parent reply other threads:[~2026-10-23 15:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 6:03 Hui Su
2026-10-23 15:24 ` Yury Norov [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=att8L4Q_eeTOXGXV@yury \
--to=ynorov@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=sh_def@163.com \
--cc=yury.norov@gmail.com \
/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
all inboxes | Powered by JetHome®