[tip: sched/core] sched/rt: cpupri_find: Use cpumask_intersects where applicable

From: tip-bot2 for Shrikanth Hegde

Date: Wed Nov 18 2026 - 08:45:18 EST


The following commit has been merged into the sched/core branch of tip:

Commit-ID: fda7fb5adda6c71be96f5836498d4b207c0811fc
Gitweb: https://git.kernel.org/tip/fda7fb5adda6c71be96f5836498d4b207c0811fc
Author: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
AuthorDate: Wed, 11 Nov 2026 13:29:41 +05:30
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Wed, 18 Nov 2026 14:32:20 +01:00

sched/rt: cpupri_find: Use cpumask_intersects where applicable

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@xxxxxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Link: https://patch.msgid.link/20261111075945.3930230-2-sshegde@xxxxxxxxxxxxx
---
kernel/sched/cpupri.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 8f2237e..44d67fb 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -97,7 +97,7 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p,
if (skip)
return 0;

- if (cpumask_any_and(&p->cpus_mask, vec->mask) >= nr_cpu_ids)
+ if (!cpumask_intersects(&p->cpus_mask, vec->mask))
return 0;

if (lowest_mask) {