From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org,
yury.norov@gmail.com, linux@rasmusvillemoes.dk,
linux-kernel@vger.kernel.org
Cc: sshegde@linux.ibm.com, chleroy@kernel.org
Subject: [PATCH 2/2] powerpc: Few misc cpumask code refactors
Date: Fri, 27 Mar 2026 12:01:29 +0530 [thread overview]
Message-ID: <20260327063129.127302-3-sshegde@linux.ibm.com> (raw)
In-Reply-To: <20260327063129.127302-1-sshegde@linux.ibm.com>
A few miscellanous changes in handling cpumask api's in the order
they appear:
- cpumask_next(cpu, mask) >= nr_cpu_ids is used to determine if
cpu is the last CPU.
- cpumask_next can take -1 as valid argument. So simplify cpuinfo
iterator. /proc/cpuinfo shows same info with patch.
- cpumask_weight can't be more than nr_cpu_ids. So remove the pointless
comparison.
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
arch/powerpc/kernel/setup-common.c | 7 ++-----
arch/powerpc/sysdev/xive/common.c | 7 +++----
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index b1761909c23f..47215eab296b 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -323,7 +323,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
seq_putc(m, '\n');
/* If this is the last cpu, print the summary */
- if (cpumask_next(cpu_id, cpu_online_mask) >= nr_cpu_ids)
+ if (cpu_id == cpumask_last(cpu_online_mask))
show_cpuinfo_summary(m);
return 0;
@@ -331,10 +331,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
static void *c_start(struct seq_file *m, loff_t *pos)
{
- if (*pos == 0) /* just in case, cpu 0 is not the first */
- *pos = cpumask_first(cpu_online_mask);
- else
- *pos = cpumask_next(*pos - 1, cpu_online_mask);
+ *pos = cpumask_next(*pos - 1, cpu_online_mask);
if ((*pos) < nr_cpu_ids)
return (void *)(unsigned long)(*pos + 1);
return NULL;
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index b6446abe29a6..91dd3b364d7d 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -548,11 +548,10 @@ static void xive_dec_target_count(int cpu)
static int xive_find_target_in_mask(const struct cpumask *mask,
unsigned int fuzz)
{
- int cpu, first, num, i;
+ int cpu, first, i;
- /* Pick up a starting point CPU in the mask based on fuzz */
- num = min_t(int, cpumask_weight(mask), nr_cpu_ids);
- first = fuzz % num;
+ /* Pick up a starting point CPU in the mask based on fuzz */
+ first = fuzz % cpumask_weight(mask);
/* Locate it */
cpu = cpumask_first(mask);
--
2.47.3
next prev parent reply other threads:[~2026-03-27 6:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 6:31 [PATCH 0/2] powerpc: A few misc cpumask refactors Shrikanth Hegde
2026-03-27 6:31 ` [PATCH 1/2] powerpc: Use cpumask_next_wrap instead Shrikanth Hegde
2026-03-28 20:44 ` Yury Norov
2026-03-29 9:18 ` Shrikanth Hegde
2026-03-27 6:31 ` Shrikanth Hegde [this message]
2026-03-28 20:27 ` [PATCH 2/2] powerpc: Few misc cpumask code refactors Yury Norov
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=20260327063129.127302-3-sshegde@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.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