Skip to contentSkip to conversation

sched/fair: cleanups and readability fixes

PATCH In review Zhan Xusheng 2 participants 4 messages Dec 19, 2025 Scheduler

lore
Share & tools
lore
#0 lore raw

cover sched/fair: cleanups and readability fixes

This series contains two small cleanups in the CFS scheduler:

1. Fix misuse of the comma operator in NUMA fault accounting by replacing it with explicit statements, improving readability.

2. Replace bare 'unsigned' casts with explicit 'unsigned int' casts to comply with kernel coding style.

No functional changes intended.

Thanks,
Zhan Xusheng

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 sched/fair: fix comma operator misuse in NUMA fault accounting

Replace the comma operator with separate statements when assigning NUMA fault statistics. This improves readability and follows kernel coding style.

---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index da46c3164537..56dd655d9bc2 100644
@@ -13957,7 +13957,7 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m)
 			tpf = p->numa_faults[task_faults_idx(NUMA_MEM, node, 1)];
 		}
 		if (ng) {
-			gsf = ng->faults[task_faults_idx(NUMA_MEM, node, 0)],
+			gsf = ng->faults[task_faults_idx(NUMA_MEM, node, 0)];
 			gpf = ng->faults[task_faults_idx(NUMA_MEM, node, 1)];
 		}
 		print_numa_stats(m, node, tsf, tpf, gsf, gpf);
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH 1/2] sched/fair: fix comma operator misuse in NUMA fault accounting

Quoted 3 lines · Zhan Xusheng

Replace the comma operator with separate statements when assigning NUMA fault statistics. This improves readability and follows kernel coding style.

This is the only one of the lot I would remotely consider applying. The rest is just noise. Please don't do style patches.

Quoted 22 lines
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index da46c3164537..56dd655d9bc2 100644
@@ -13957,7 +13957,7 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m)
 			tpf = p->numa_faults[task_faults_idx(NUMA_MEM, node, 1)];
 		}
 		if (ng) {
-			gsf = ng->faults[task_faults_idx(NUMA_MEM, node, 0)],
+			gsf = ng->faults[task_faults_idx(NUMA_MEM, node, 0)];
 			gpf = ng->faults[task_faults_idx(NUMA_MEM, node, 1)];
 		}
 		print_numa_stats(m, node, tsf, tpf, gsf, gpf);
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/2 sched/fair: replace bare 'unsigned' with 'unsigned int'

In reply to Zhan Xusheng

Replace 'unsigned' casts with explicit 'unsigned int' casts to comply with kernel coding style.

No functional change intended.

---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/fair.c +2 -2
index 56dd655d9bc2..4e6a57708229 100644
@@ -7861,7 +7861,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 		 */
 		if (sd) {
 			i = select_idle_capacity(p, sd, target);
-			return ((unsigned)i < nr_cpumask_bits) ? i : target;
+			return ((unsigned int)i < nr_cpumask_bits) ? i : target;
 		}
 	}
 
@@ -7880,7 +7880,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
 	}
 
 	i = select_idle_cpu(p, sd, has_idle_core, target);
-	if ((unsigned)i < nr_cpumask_bits)
+	if ((unsigned int)i < nr_cpumask_bits)
 		return i;
 
 	/*
Signature · 1 line
2.43.0