Skip to contentSkip to conversation

kernel/sched: use seq_putc instead of seq_puts

PATCH Superseded Maxim Moskalets 2 participants 2 messages Mar 3, 2024 – Mar 14, 2024 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/sched: use seq_putc instead of seq_puts

Using seq_putc for newline characters is faster and more appropriate than seq_puts, since only one character is passed and there is no need to use a more powerful and less fast function

---
 kernel/sched/cpuacct.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/cpuacct.c +3 -3
index 0de9dda09949..54d9dd68f517 100644
@@ -217,7 +217,7 @@ static int __cpuacct_percpu_seq_show(struct seq_file *m,
 		percpu = cpuacct_cpuusage_read(ca, i, index);
 		seq_printf(m, "%llu ", (unsigned long long) percpu);
 	}
-	seq_printf(m, "\n");
+	seq_putc(m, '\n');
 	return 0;
 }
 
@@ -245,14 +245,14 @@ static int cpuacct_all_seq_show(struct seq_file *m, void *V)
 	seq_puts(m, "cpu");
 	for (index = 0; index < CPUACCT_STAT_NSTATS; index++)
 		seq_printf(m, " %s", cpuacct_stat_desc[index]);
-	seq_puts(m, "\n");
+	seq_putc(m, '\n');
 
 	for_each_possible_cpu(cpu) {
 		seq_printf(m, "%d", cpu);
 		for (index = 0; index < CPUACCT_STAT_NSTATS; index++)
 			seq_printf(m, " %llu",
 				   cpuacct_cpuusage_read(ca, cpu, index));
-		seq_puts(m, "\n");
+		seq_putc(m, '\n');
 	}
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Maxim Moskalets

Using seq_putc for newline characters is faster and more appropriate than seq_puts, since only one character is passed and there is no need to use a more powerful and less fast function

Why not, but then why not do this treewide? A quick grep shows ~340 such sites. That makes for a fairly easy coccinelle patch.