Skip to contentSkip to conversation

Changed cpumask_next to wrap instead of terminating after nr_cpus.

PATCH NAK Cade Richard 2 participants 2 messages Aug 26, 2024 – Aug 27, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Changed cpumask_next to wrap instead of terminating after nr_cpus.

Changed cpumask_next() to wrap instead of terminating after nr_cpus.

---
 lib/cpumask.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/cpumask.h +4 -2
index be191923..5105c3bd 100644
@@ -109,8 +109,10 @@ static inline void cpumask_copy(cpumask_t *dst, const cpumask_t *src)
 
 static inline int cpumask_next(int cpu, const cpumask_t *mask)
 {
-	while (++cpu < nr_cpus && !cpumask_test_cpu(cpu, mask))
-		;
+	do {
+		if (++cpu > nr_cpus)
+			cpu = 0;
+	} while (!cpumask_test_cpu(cpu, mask));
 	return cpu;
 }
 
Signature · 1 line
2.43.0
#1 lore raw

Patch summaries shouldn't have periods and they should be concise.

Quoted 12 lines · Cade Richard

Changed cpumask_next() to wrap instead of terminating after nr_cpus.

---
 lib/cpumask.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/cpumask.h +0 -0
index be191923..5105c3bd 100644

lib/cpumask.h static inline void cpumask_copy(cpumask_t *dst, const cpumask_t *src) · line 113

Quoted 7 lines
lib/cpumask.h +2 -2
@@ -109,8 +109,10 @@ static inline void cpumask_copy(cpumask_t *dst, const cpumask_t *src)
 
 static inline int cpumask_next(int cpu, const cpumask_t *mask)
 {
-	while (++cpu < nr_cpus && !cpumask_test_cpu(cpu, mask))
-		;
+	do {
+		if (++cpu > nr_cpus)

Should be ++cpu == nr_cpus, but...

lib/cpumask.h static inline void cpumask_copy(cpumask_t *dst, const cpumask_t *src) · line 115

Quoted 2 lines
lib/cpumask.h +2 -0
+			cpu = 0;
+	} while (!cpumask_test_cpu(cpu, mask));

...this will break everything. See for_each_cpu().

Nack

drew

Quoted 11 lines
lib/cpumask.h +0 -0
 	return cpu;
 }
 
Signature · 7 lines
2.43.0


-- 
kvm-riscv mailing list
kvm-riscv at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv