MIPS: kernel: proc: More efficient data output in show_cpuinfo()
Subsystems (2)
cover MIPS: kernel: proc: More efficient data output in show_cpuinfo()
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:33:55 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (4):
Simplify data output
Combine two seq_puts() calls
Use seq_putc() calls
Delete unnecessary braces
arch/mips/kernel/proc.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/4 MIPS: kernel: proc: Simplify data output in show_cpuinfo()
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 17:24:10 +0200
Move the specification for a line break from a seq_puts() call to a seq_printf() call.
The source code was transformed by using the Coccinelle software.
--- arch/mips/kernel/proc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/mips/kernel/proc.c +1 -3
@@ -274,10 +274,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," mm_sysad" );if (cpu_has_mm_full)seq_puts (m," mm_full" ); -seq_puts (m,"\n" ); -seq_printf (m,"shadow register sets\t: %d\n" , - cpu_data[n].srsets); +seq_printf (m,"\nshadow register sets\t: %d\n" , cpu_data[n].srsets);seq_printf (m,"kscratch registers\t: %d\n" ,hweight8 (cpu_data[n].kscratch_mask));seq_printf (m,"package\t\t\t: %d\n" , cpu_data[n].package);
Signature · 1 line
2.54.0
PATCH 2/4 MIPS: kernel: proc: Combine two seq_puts() calls in show_cpuinfo()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:10:04 +0200
Put data into a sequence by a single seq_puts() call instead of two.
This issue was detected by using the Coccinelle software.
--- arch/mips/kernel/proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/kernel/proc.c +1 -2
@@ -109,9 +109,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," mips64r5" );if (cpu_has_mips64r6)seq_puts (m," mips64r6" ); -seq_puts (m,"\n" ); -seq_puts (m,"ASEs implemented\t:" ); +seq_puts (m,"\nASEs implemented\t:" );if (cpu_has_mips16)seq_puts (m," mips16" );if (cpu_has_mips16e2)
Signature · 1 line
2.54.0
PATCH 3/4 MIPS: kernel: proc: Use seq_putc() calls in show_cpuinfo()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:12:11 +0200
Single characters should occasionally be put into a sequence. Thus use the corresponding function “seq_putc”.
The source code was transformed by using the Coccinelle software.
--- arch/mips/kernel/proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/kernel/proc.c +3 -3
@@ -79,7 +79,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)for (i =0 ; i < cpu_data[n].watch_reg_count; i++)seq_printf (m,"%s0x%04x" , i ?", " :"" , cpu_data[n].watch_reg_masks[i]); -seq_puts (m,"]" ); +seq_putc (m,']' ); }seq_puts (m,"\nisa\t\t\t:" );
@@ -149,7 +149,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," loongson-ext" );if (cpu_has_loongson_ext2)seq_puts (m," loongson-ext2" ); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );if (cpu_has_mmips) { seq_printf(m, "micromips kernel\t: %s\n",
@@ -298,7 +298,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)raw_notifier_call_chain (&proc_cpuinfo_chain,0 , &proc_cpuinfo_notifier_args); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
Signature · 1 line
2.54.0
Re: [PATCH 3/4] MIPS: kernel: proc: Use seq_putc() calls in show_cpuinfo()
Quoted 46 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:12:11 +0200Single characters should occasionally be put into a sequence. Thus use the corresponding function “seq_putc”.
The source code was transformed by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/mips/kernel/proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/mips/kernel/proc.c +3
-3@@ -79,7 +79,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)for (i =0 ; i < cpu_data[n].watch_reg_count; i++)seq_printf (m,"%s0x%04x" , i ?", " :"" , cpu_data[n].watch_reg_masks[i]); -seq_puts (m,"]" ); +seq_putc (m,']' ); }seq_puts (m,"\nisa\t\t\t:" );@@ -149,7 +149,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," loongson-ext" );if (cpu_has_loongson_ext2)seq_puts (m," loongson-ext2" ); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );if (cpu_has_mmips) { seq_printf(m, "micromips kernel\t: %s\n",@@ -298,7 +298,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)raw_notifier_call_chain (&proc_cpuinfo_chain,0 , &proc_cpuinfo_notifier_args); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }Signature · 1 line
2.54.0
applied to mips-next
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
PATCH 4/4 MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:15:15 +0200
Do not use curly brackets at one source code place where a single statement should be sufficient.
--- arch/mips/kernel/proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/kernel/proc.c +1 -2
@@ -151,10 +151,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," loongson-ext2" );seq_putc (m,'\n' ); -if (cpu_has_mmips) { +if (cpu_has_mmips)seq_printf (m,"micromips kernel\t: %s\n" ,str_yes_no (read_c0_config3 () &MIPS_CONF3_ISA_OE )); - }seq_puts (m,"Options implemented\t:" );if (cpu_has_tlb)
Signature · 1 line
2.54.0
Re: [PATCH 4/4] MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()
Quoted 29 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:15:15 +0200Do not use curly brackets at one source code place where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- arch/mips/kernel/proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/mips/kernel/proc.c +1
-2@@ -151,10 +151,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," loongson-ext2" );seq_putc (m,'\n' ); -if (cpu_has_mmips) { +if (cpu_has_mmips)seq_printf (m,"micromips kernel\t: %s\n" ,str_yes_no (read_c0_config3 () &MIPS_CONF3_ISA_OE )); - }seq_puts (m,"Options implemented\t:" );if (cpu_has_tlb)Signature · 1 line
2.54.0
applied to mips-next
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Re: [PATCH 4/4] MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()
Quoted 8 lines · Thomas Bogendoerfer
Quoted 7 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:15:15 +0200Do not use curly brackets at one source code place where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>
Generally, in most kernel subsystems the rule is that multi-line indents get curly braces for readability even when they aren't required because of the syntax.
regards,
dan carpenter
Re: [4/4] MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Do not use curly brackets at one source code place where a single statement should be sufficient.
…
Quoted 3 lines
Generally, in most kernel subsystems the rule is that multi-line indents get curly braces for readability even when they aren't required because of the syntax.
How do you think about to adjust any process and software documentation accordingly?
Regards,
Markus
Re: [4/4] MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()
In reply to Dan CarpenterQuoted 3 lines
Generally, in most kernel subsystems the rule is that multi-line indents get curly braces for readability even when they aren't required because of the syntax.
By the way:
Would you eventually prefer any other indentation (or formatting) for the affected statement?
Regards,
Markus
Hi, Markus,
I suggest squash these pieces to a single patch.
Huacai
Quoted 20 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 19:33:55 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (4):
Simplify data output
Combine twoseq_puts()calls
Useseq_putc()calls
Delete unnecessary bracesarch/mips/kernel/proc.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)--
2.54.0
Quoted 2 lines
A few update suggestions were taken into account
from static source code analysis.
Does the feedback indicate so far that you would like to omit the patch “MIPS: kernel: proc: Simplify data output in show_cpuinfo()”?
https://lore.kernel.org/linux-mips/[email protected]/
https://lkml.org/lkml/2026/6/4/1819
Will another source code adjustment become helpful?
Regards,
Markus
Thomas Bogendoerfer
maintainerQuoted 7 lines · Markus Elfring
Quoted 2 lines
A few update suggestions were taken into account
from static source code analysis.Does the feedback indicate so far that you would like to omit the patch “MIPS: kernel: proc: Simplify data output in show_cpuinfo()”?
https://lore.kernel.org/linux-mips/[email protected]/
https://lkml.org/lkml/2026/6/4/1819
I prefer the way how text is formated over saving a few bytes/cylcles.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
PATCH 1/1 MIPS: kernel: proc: Use two seq_putc() calls in show_cpuinfo()
From: Markus Elfring <[email protected]>
Date: Mon, 22 Jun 2026 17:50:13 +0200
Single line breaks should occasionally be put into a sequence. Thus use the corresponding function “seq_putc”.
The source code was transformed by using the Coccinelle software.
--- arch/mips/kernel/proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kernel/proc.c +2 -2
@@ -109,7 +109,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," mips64r5" );if (cpu_has_mips64r6)seq_puts (m," mips64r6" ); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_puts (m,"ASEs implemented\t:" );if (cpu_has_mips16)
@@ -273,7 +273,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," mm_sysad" );if (cpu_has_mm_full)seq_puts (m," mm_full" ); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_printf (m,"shadow register sets\t: %d\n" , cpu_data[n].srsets);
Signature · 1 line
2.54.0
Re: [PATCH] MIPS: kernel: proc: Use two seq_putc() calls in show_cpuinfo()
Quoted 37 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 22 Jun 2026 17:50:13 +0200Single line breaks should occasionally be put into a sequence. Thus use the corresponding function “seq_putc”.
The source code was transformed by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/mips/kernel/proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/mips/kernel/proc.c +2
-2@@ -109,7 +109,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," mips64r5" );if (cpu_has_mips64r6)seq_puts (m," mips64r6" ); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_puts (m,"ASEs implemented\t:" );if (cpu_has_mips16)@@ -273,7 +273,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m," mm_sysad" );if (cpu_has_mm_full)seq_puts (m," mm_full" ); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_printf (m,"shadow register sets\t: %d\n" , cpu_data[n].srsets);Signature · 1 line
2.54.0
applied to mips-next
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]