Skip to contentSkip to conversation

random: Use cpumask_next_wrap() in try_to_generate_entropy()

PATCH New Fushuai Wang 1 participant 1 message Aug 7, 2025 Random number driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 random: Use cpumask_next_wrap() in try_to_generate_entropy()

Replace the manual sequence of cpumask_next() and cpumask_first() with a single call to cpumask_next_wrap() in try_to_generate_entropy().

---
 drivers/char/random.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/random.c +1 -3
index b8b24b6ed3fe..f85f35777c9b 100644
@@ -1336,9 +1336,7 @@ static void __cold try_to_generate_entropy(void)
 
 			/* Basic CPU round-robin, which avoids the current CPU. */
 			do {
-				cpu = cpumask_next(cpu, &timer_cpus);
-				if (cpu >= nr_cpu_ids)
-					cpu = cpumask_first(&timer_cpus);
+				cpu = cpumask_next_wrap(cpu, &timer_cpus);
 			} while (cpu == smp_processor_id() && num_cpus > 1);
 
 			/* Expiring the timer at `jiffies` means it's the next tick. */
Signature · 1 line
2.36.1