Skip to contentSkip to conversation

cpuidle: Use cpumask_intersects_and where applicable

PATCH RESEND Applied Shrikanth Hegde 2 participants 2 messages Nov 17 – Nov 20 CPU idle time management framework

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 cpuidle: Use cpumask_intersects_and where applicable

cpumask_first_and_and returns, usually the first CPU in the intersection of the three cpumasks. However, if the returned CPU is not used or only to check it against nr_cpu_ids, that implies to check whether the three cpumasks have a bit in common. I.e use cpumask_intersects_and.

cpumask_first_and_and uses ffs on (addr1[idx] & addr2[idx] & addr3[idx]) whereas cpumask_intersects_and checks only
(addr1[idx] & addr2[idx] & addr3[idx]).

So replace such an occurrence.

---
This is resend of the v1 series posted as independent patch
https://lore.kernel.org/all/[email protected]/#t

 drivers/cpuidle/coupled.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpuidle/coupled.c +2 -2
index fb91a9e0e3c2..40db5c86a466 100644
@@ -439,8 +439,8 @@ static int cpuidle_coupled_clear_pokes(int cpu)
 
 static bool cpuidle_coupled_any_pokes_pending(struct cpuidle_coupled *coupled)
 {
-	return cpumask_first_and_and(cpu_online_mask, &coupled->coupled_cpus,
-				     &cpuidle_coupled_poke_pending) < nr_cpu_ids;
+	return cpumask_intersects_and(cpu_online_mask, &coupled->coupled_cpus,
+				      &cpuidle_coupled_poke_pending);
 }
 
 /**
Signature · 1 line
2.52.0
maintainer Applied
#1 lore raw
Quoted 27 lines · Shrikanth Hegde

cpumask_first_and_and returns, usually the first CPU in the intersection of the three cpumasks. However, if the returned CPU is not used or only to check it against nr_cpu_ids, that implies to check whether the three cpumasks have a bit in common. I.e use cpumask_intersects_and.

cpumask_first_and_and uses ffs on (addr1[idx] & addr2[idx] & addr3[idx]) whereas cpumask_intersects_and checks only
(addr1[idx] & addr2[idx] & addr3[idx]).

So replace such an occurrence.

---
This is resend of the v1 series posted as independent patch
https://lore.kernel.org/all/[email protected]/#t

 drivers/cpuidle/coupled.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpuidle/coupled.c +0 -0
index fb91a9e0e3c2..40db5c86a466 100644
@@ -439,8 +439,8 @@ static int cpuidle_coupled_clear_pokes(int cpu)
 

drivers/cpuidle/coupled.c static int cpuidle_coupled_clear_pokes(int cpu)

Quoted 10 lines
drivers/cpuidle/coupled.c +2 -3
 static bool cpuidle_coupled_any_pokes_pending(struct cpuidle_coupled *coupled)
 {
-       return cpumask_first_and_and(cpu_online_mask, &coupled->coupled_cpus,
-                                    &cpuidle_coupled_poke_pending) < nr_cpu_ids;
+       return cpumask_intersects_and(cpu_online_mask, &coupled->coupled_cpus,
+                                     &cpuidle_coupled_poke_pending);
 }
 
 /**
--

Applied as 7.5 material, thanks!