Fix warnings like: "Prefer seq_puts to seq_printf" by checkpatch.pl.
Replace seq_printf() calls with seq_puts() in show_cpuinfo()
when outputting simple constant strings without format specifiers.
This improves performance slightly as seq_puts() avoids parsing
the format string.
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
arch/loongarch/kernel/proc.c | 64 ++++++++++++++++++++++--------------
1 file changed, 40 insertions(+), 24 deletions(-)
diff --git a/arch/loongarch/kernel/proc.c b/arch/loongarch/kernel/proc.c
index a60471b96440..a8127e83da65 100644
--- a/arch/loongarch/kernel/proc.c
+++ b/arch/loongarch/kernel/proc.c
@@ -50,33 +50,49 @@ static int show_cpuinfo(struct seq_file *m, void *v)
seq_printf(m, "Address Sizes\t\t: %d bits physical, %d bits virtual\n",
cpu_pabits + 1, cpu_vabits + 1);
- seq_printf(m, "ISA\t\t\t:");
+ seq_puts(m, "ISA\t\t\t:");
if (isa & LOONGARCH_CPU_ISA_LA32R)
- seq_printf(m, " loongarch32r");
+ seq_puts(m, " loongarch32r");
if (isa & LOONGARCH_CPU_ISA_LA32S)
- seq_printf(m, " loongarch32s");
+ seq_puts(m, " loongarch32s");
if (isa & LOONGARCH_CPU_ISA_LA64)
- seq_printf(m, " loongarch64");
- seq_printf(m, "\n");
+ seq_puts(m, " loongarch64");
+ seq_puts(m, "\n");
- seq_printf(m, "Features\t\t:");
- if (cpu_has_cpucfg) seq_printf(m, " cpucfg");
- if (cpu_has_lam) seq_printf(m, " lam");
- if (cpu_has_scq) seq_printf(m, " scq");
- if (cpu_has_ual) seq_printf(m, " ual");
- if (cpu_has_fpu) seq_printf(m, " fpu");
- if (cpu_has_lsx) seq_printf(m, " lsx");
- if (cpu_has_lasx) seq_printf(m, " lasx");
- if (cpu_has_crc32) seq_printf(m, " crc32");
- if (cpu_has_complex) seq_printf(m, " complex");
- if (cpu_has_crypto) seq_printf(m, " crypto");
- if (cpu_has_ptw) seq_printf(m, " ptw");
- if (cpu_has_lspw) seq_printf(m, " lspw");
- if (cpu_has_lvz) seq_printf(m, " lvz");
- if (cpu_has_lbt_x86) seq_printf(m, " lbt_x86");
- if (cpu_has_lbt_arm) seq_printf(m, " lbt_arm");
- if (cpu_has_lbt_mips) seq_printf(m, " lbt_mips");
- seq_printf(m, "\n");
+ seq_puts(m, "Features\t\t:");
+ if (cpu_has_cpucfg)
+ seq_puts(m, " cpucfg");
+ if (cpu_has_lam)
+ seq_puts(m, " lam");
+ if (cpu_has_scq)
+ seq_puts(m, " scq");
+ if (cpu_has_ual)
+ seq_puts(m, " ual");
+ if (cpu_has_fpu)
+ seq_puts(m, " fpu");
+ if (cpu_has_lsx)
+ seq_puts(m, " lsx");
+ if (cpu_has_lasx)
+ seq_puts(m, " lasx");
+ if (cpu_has_crc32)
+ seq_puts(m, " crc32");
+ if (cpu_has_complex)
+ seq_puts(m, " complex");
+ if (cpu_has_crypto)
+ seq_puts(m, " crypto");
+ if (cpu_has_ptw)
+ seq_puts(m, " ptw");
+ if (cpu_has_lspw)
+ seq_puts(m, " lspw");
+ if (cpu_has_lvz)
+ seq_puts(m, " lvz");
+ if (cpu_has_lbt_x86)
+ seq_puts(m, " lbt_x86");
+ if (cpu_has_lbt_arm)
+ seq_puts(m, " lbt_arm");
+ if (cpu_has_lbt_mips)
+ seq_puts(m, " lbt_mips");
+ seq_puts(m, "\n");
seq_printf(m, "Hardware Watchpoint\t: %s", str_yes_no(cpu_has_watch));
if (cpu_has_watch) {
@@ -84,7 +100,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
cpu_data[n].watch_ireg_count, cpu_data[n].watch_dreg_count);
}
- seq_printf(m, "\n\n");
+ seq_puts(m, "\n\n");
return 0;
}
--
2.49.0
On Sat, 2026-01-10 at 21:11 +0800, George Guo wrote: > Fix warnings like: "Prefer seq_puts to seq_printf" by checkpatch.pl. > > Replace seq_printf() calls with seq_puts() in show_cpuinfo() > when outputting simple constant strings without format specifiers. > > This improves performance slightly as seq_puts() avoids parsing > the format string. [] > diff --git a/arch/loongarch/kernel/proc.c b/arch/loongarch/kernel/proc.c [] > @@ -50,33 +50,49 @@ static int show_cpuinfo(struct seq_file *m, void *v) [] > - seq_printf(m, "Features\t\t:"); > - if (cpu_has_cpucfg) seq_printf(m, " cpucfg"); > - if (cpu_has_lam) seq_printf(m, " lam"); [etc] > + seq_puts(m, "Features\t\t:"); > + if (cpu_has_cpucfg) > + seq_puts(m, " cpucfg"); > + if (cpu_has_lam) > + seq_puts(m, " lam"); trivia: Not sure this is better style as it's fairly difficult to read. Maybe a macro might help, something like: #define seq_cpu_feature(m, feature) \ if (cpu_has_##feature) seq_puts(m, " " #feature) seq_cpu_feature(m, cpucfg); seq_cpu_feature(m, lam); etc.
Hi, Joe, On Sun, Jan 11, 2026 at 2:04 AM Joe Perches <joe@perches.com> wrote: > > On Sat, 2026-01-10 at 21:11 +0800, George Guo wrote: > > Fix warnings like: "Prefer seq_puts to seq_printf" by checkpatch.pl. > > > > Replace seq_printf() calls with seq_puts() in show_cpuinfo() > > when outputting simple constant strings without format specifiers. > > > > This improves performance slightly as seq_puts() avoids parsing > > the format string. > [] > > diff --git a/arch/loongarch/kernel/proc.c b/arch/loongarch/kernel/proc.c > [] > > @@ -50,33 +50,49 @@ static int show_cpuinfo(struct seq_file *m, void *v) > [] > > - seq_printf(m, "Features\t\t:"); > > - if (cpu_has_cpucfg) seq_printf(m, " cpucfg"); > > - if (cpu_has_lam) seq_printf(m, " lam"); > [etc] > > + seq_puts(m, "Features\t\t:"); > > + if (cpu_has_cpucfg) > > + seq_puts(m, " cpucfg"); > > + if (cpu_has_lam) > > + seq_puts(m, " lam"); > > trivia: > > Not sure this is better style as it's fairly difficult to read. > > Maybe a macro might help, something like: > > #define seq_cpu_feature(m, feature) \ > if (cpu_has_##feature) seq_puts(m, " " #feature) > > seq_cpu_feature(m, cpucfg); > seq_cpu_feature(m, lam); Seems just some bikesheedings, the current style is OK at least for me. Since George has worked on this series for a very long time, let's stop changing and get it merged. Huacai > > etc. >
© 2016 - 2026 Red Hat, Inc.