Skip to contentSkip to conversation

sched: remove unnecessary check in sched_{debug_}start()

PATCH In review Fushuai Wang 2 participants 3 messages Aug 7, 2025 – Oct 6, 2025 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: remove unnecessary check in sched_{debug_}start()

-1 is a legal argument for cpumask_next(), and cpumask_next(-1, mask) is equivalent to cpumask_first(mask). The explicit check and separate branch are unnecessary.

---
 kernel/sched/debug.c | 5 +----
 kernel/sched/stats.c | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)
kernel/sched/debug.c +1 -4
index 3f06ab84d53f..1b3592bac62b 100644
@@ -1080,10 +1080,7 @@ static void *sched_debug_start(struct seq_file *file, loff_t *offset)
 
 	n--;
 
-	if (n > 0)
-		n = cpumask_next(n - 1, cpu_online_mask);
-	else
-		n = cpumask_first(cpu_online_mask);
+	n = cpumask_next(n - 1, cpu_online_mask);
 
 	*offset = n + 1;
 
kernel/sched/stats.c +1 -4
index d1c9429a4ac5..f93b1c87c538 100644
@@ -181,10 +181,7 @@ static void *schedstat_start(struct seq_file *file, loff_t *offset)
 
 	n--;
 
-	if (n > 0)
-		n = cpumask_next(n - 1, cpu_online_mask);
-	else
-		n = cpumask_first(cpu_online_mask);
+	n = cpumask_next(n - 1, cpu_online_mask);
 
 	*offset = n + 1;
 
Signature · 1 line
2.36.1
#2 lore raw
In reply to Fushuai Wang
Quoted 3 lines

-1 is a legal argument for cpumask_next(), and cpumask_next(-1, mask) is equivalent to cpumask_first(mask). The explicit check and separate branch are unnecessary.

Gentle ping. This patch has been reviewed but not merged yet.

Regards,
Wang.