From: Yury Norov <ynorov@nvidia.com>
To: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Thomas Gleixner <tglx@kernel.org>, Nam Cao <namcao@linutronix.de>,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>,
Yury Norov <ynorov@nvidia.com>, Kees Cook <kees@kernel.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 1/2] Revert "powerpc/xive: Fix the size of the cpumask used in xive_find_target_in_mask()"
Date: Wed, 18 Mar 2026 23:36:45 -0400 [thread overview]
Message-ID: <20260319033647.881246-2-ynorov@nvidia.com> (raw)
In-Reply-To: <20260319033647.881246-1-ynorov@nvidia.com>
This reverts commit a9dadc1c512807f955f0799e85830b420da47932.
The commit message states:
When called from xive_irq_startup(), the size of the cpumask can be
larger than nr_cpu_ids. This can result in a WARN_ON.
[...]
This happens because we're being called with our affinity mask set to
irq_default_affinity. That in turn was populated using
cpumask_setall(), which sets NR_CPUs worth of bits, not nr_cpu_ids
worth. Finally cpumask_weight() will return > nr_cpu_ids when passed a
mask which has > nr_cpu_ids bits set.
In modern kernel, cpumask_weight() can't return > nr_cpu_ids.
In inline case, cpumask_setall() explicitly clears all bits above
nr_cpu_ids, see commit 63355b9884b3 ("cpumask: be more careful with
'cpumask_setall()'"). So, despite that cpumask_weight() is passed
with small_cpumask_bits, which is NR_CPUS in this case, it can't
count over the nr_cpu_ids.
In outline case, cpumask_setall() may set bits beyond the limit up to
the next byte alignment, but in this case small_cpumask_bits is wired
to nr_cpu_ids, thus making overcounting impossible.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
I've added some explicit tests for cpumask_weight() to make sure:
https://lore.kernel.org/all/20260319004349.849281-1-ynorov@nvidia.com/
arch/powerpc/sysdev/xive/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index e1a4f8a97393..e91ec9036ad8 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -551,7 +551,7 @@ static int xive_find_target_in_mask(const struct cpumask *mask,
int cpu, first, num, i;
/* Pick up a starting point CPU in the mask based on fuzz */
- num = min_t(int, cpumask_weight(mask), nr_cpu_ids);
+ num = cpumask_weight(mask);
first = fuzz % num;
/* Locate it */
--
2.43.0
next prev parent reply other threads:[~2026-03-19 3:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 3:36 [PATCH 0/2] powerpc/xive: rework xive_find_target_in_mask() Yury Norov
2026-03-19 3:36 ` Yury Norov [this message]
2026-03-20 5:57 ` [PATCH 1/2] Revert "powerpc/xive: Fix the size of the cpumask used in xive_find_target_in_mask()" Mukesh Kumar Chaurasiya
2026-03-19 3:36 ` [PATCH 2/2] powerpc/xive: rework xive_find_target_in_mask() Yury Norov
2026-03-29 9:13 ` Shrikanth Hegde
2026-03-30 17:04 ` Yury Norov
2026-03-31 2:59 ` Shrikanth Hegde
2026-03-31 5:30 ` Madhavan Srinivasan
2026-03-20 6:01 ` [PATCH 0/2] " Mukesh Kumar Chaurasiya
2026-04-08 4:29 ` Madhavan Srinivasan
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=20260319033647.881246-2-ynorov@nvidia.com \
--to=ynorov@nvidia.com \
--cc=chleroy@kernel.org \
--cc=jirislaby@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=namcao@linutronix.de \
--cc=npiggin@gmail.com \
--cc=tglx@kernel.org \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.