[PATCH v9 loongarch-next 1/4] LoongArch: Replace seq_printf with seq_puts for simple strings

George Guo posted 4 patches 1 month ago
There is a newer version of this series
[PATCH v9 loongarch-next 1/4] LoongArch: Replace seq_printf with seq_puts for simple strings
Posted by George Guo 1 month ago
From: George Guo <guodongtai@kylinos.cn>

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 | 61 ++++++++++++++++++++++--------------
 1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/arch/loongarch/kernel/proc.c b/arch/loongarch/kernel/proc.c
index a8800d20e11b..1d646da010f9 100644
--- a/arch/loongarch/kernel/proc.c
+++ b/arch/loongarch/kernel/proc.c
@@ -50,32 +50,47 @@ 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_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_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) {
@@ -83,7 +98,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.43.0
Re: [PATCH v9 loongarch-next 1/4] LoongArch: Replace seq_printf with seq_puts for simple strings
Posted by Huacai Chen 4 weeks ago
Hi, George,

On Mon, Jan 5, 2026 at 6:55 PM George Guo <dongtai.guo@linux.dev> wrote:
>
> From: George Guo <guodongtai@kylinos.cn>
>
> Fix warnings like: "Prefer seq_puts to seq_printf" by checkpatch.pl.
Please move this patch to be the last one, because it is not the keystone.


Huacai
>
> 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 | 61 ++++++++++++++++++++++--------------
>  1 file changed, 38 insertions(+), 23 deletions(-)
>
> diff --git a/arch/loongarch/kernel/proc.c b/arch/loongarch/kernel/proc.c
> index a8800d20e11b..1d646da010f9 100644
> --- a/arch/loongarch/kernel/proc.c
> +++ b/arch/loongarch/kernel/proc.c
> @@ -50,32 +50,47 @@ 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_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_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) {
> @@ -83,7 +98,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.43.0
>
>