From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: linux-kernel@vger.kernel.org, yury.norov@gmail.com,
linux-perf-users@vger.kernel.org
Cc: sshegde@linux.ibm.com, mingo@kernel.org, peterz@infradead.org,
juri.lelli@redhat.com, vincent.guittot@linaro.org,
tglx@kernel.org, sudeep.holla@kernel.org,
linux@rasmusvillemoes.dk
Subject: [PATCH 3/5] perf: Use cpumask_intersects where applicable
Date: Wed, 11 Nov 2026 13:29:43 +0530 [thread overview]
Message-ID: <20261111075945.3930230-4-sshegde@linux.ibm.com> (raw)
In-Reply-To: <20261111075945.3930230-1-sshegde@linux.ibm.com>
cpumask_any_and returns, usually the first cpu in the intersection
of the two cpumasks. However, if the returned value is not used or
only to check it against nr_cpu_ids, that implies whether the two
cpumask have a bit in common. i.e cpumask_intersects.
cpumask_any_and uses ffs on (addr1[idx] & addr2[idx]) whereas
cpumask_intersects checks only (addr1[idx] & addr2[idx]).
So replace such occurrences.
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
kernel/events/core.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a6c8e38a3110..f9fa1b47ddf4 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -13159,7 +13159,6 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
if (pmu->scope != PERF_PMU_SCOPE_NONE && event->cpu >= 0) {
const struct cpumask *cpumask;
struct cpumask *pmu_cpumask;
- int cpu;
cpumask = perf_scope_cpu_topology_cpumask(pmu->scope, event->cpu);
pmu_cpumask = perf_scope_cpumask(pmu->scope);
@@ -13168,8 +13167,7 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
if (!pmu_cpumask || !cpumask)
goto err_destroy;
- cpu = cpumask_any_and(pmu_cpumask, cpumask);
- if (cpu >= nr_cpu_ids)
+ if (!cpumask_intersects(pmu_cpumask, cpumask))
goto err_destroy;
event->event_caps |= PERF_EV_CAP_READ_SCOPE;
@@ -15312,8 +15310,7 @@ static void perf_event_setup_cpumask(unsigned int cpu)
if (WARN_ON_ONCE(!pmu_cpumask || !cpumask))
continue;
- if (!cpumask_empty(cpumask) &&
- cpumask_any_and(pmu_cpumask, cpumask) >= nr_cpu_ids)
+ if (!cpumask_empty(cpumask) && !cpumask_intersects(pmu_cpumask, cpumask))
cpumask_set_cpu(cpu, pmu_cpumask);
}
end:
--
2.52.0
next prev parent reply other threads:[~2026-11-11 8:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 7:59 [PATCH 0/5] cpumask: Use cpumask_intersects* APIs where applicable Shrikanth Hegde
2026-11-11 7:59 ` [PATCH 1/5] sched/rt: cpupri_find: Use cpumask_intersects " Shrikanth Hegde
2026-11-11 8:06 ` sashiko-bot
2026-11-11 7:59 ` [PATCH 2/5] cpu/hotplug: " Shrikanth Hegde
2026-11-11 8:09 ` sashiko-bot
2026-11-11 7:59 ` Shrikanth Hegde [this message]
2026-11-11 8:20 ` [PATCH 3/5] perf: " sashiko-bot
2026-11-11 7:59 ` [PATCH 4/5] cpuidle: Use cpumask_intersects_and " Shrikanth Hegde
2026-11-11 8:03 ` sashiko-bot
2026-11-11 7:59 ` [PATCH 5/5] arch_topology: Use cpumask_intersects " Shrikanth Hegde
2026-11-11 8:03 ` sashiko-bot
2026-11-11 10:20 ` Sudeep Holla
2026-11-11 9:16 ` [PATCH 0/5] cpumask: Use cpumask_intersects* APIs " Peter Zijlstra
2026-11-11 9:22 ` Shrikanth Hegde
2026-11-11 10:10 ` Peter Zijlstra
2026-11-12 7:09 ` Shrikanth Hegde
2026-11-11 16:38 ` 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=20261111075945.3930230-4-sshegde@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sudeep.holla@kernel.org \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--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 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.