Skip to contentSkip to conversation

MIPS: kernel: proc: More efficient data output in show_cpuinfo()

PATCH Applied Markus Elfring 4 participants 15 messages Jun 4 – Jul 17

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 8f0a0001540c..fdf659a8bb3d 100644
@@ -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
#2 lore raw

PATCH 2/4 MIPS: kernel: proc: Combine two seq_puts() calls in show_cpuinfo()

In reply to Markus Elfring

From: 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
index fdf659a8bb3d..9e8b8f99b606 100644
@@ -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
#3 lore raw

PATCH 3/4 MIPS: kernel: proc: Use seq_putc() calls in show_cpuinfo()

In reply to Markus Elfring

From: 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
index 9e8b8f99b606..42430c7f0acf 100644
@@ -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
maintainer Applied
#4 lore raw

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 +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
index 9e8b8f99b606..42430c7f0acf 100644
@@ -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 ]
#5 lore raw

PATCH 4/4 MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()

In reply to Markus Elfring

From: 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
index 42430c7f0acf..2c50b0b53be1 100644
@@ -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
maintainer Applied
#6 lore raw

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 +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
index 42430c7f0acf..2c50b0b53be1 100644
@@ -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 ]
#7 lore raw

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 +0200

Do not use curly brackets at one source code place where a single statement should be sufficient.

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

#8 lore raw

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

#9 lore raw

Re: [4/4] MIPS: kernel: proc: Delete unnecessary braces in show_cpuinfo()

In reply to Dan Carpenter
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.

By the way:
Would you eventually prefer any other indentation (or formatting) for the affected statement?

Regards,
Markus

#10 lore raw
In reply to Markus Elfring

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 +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(-)

--
2.54.0

#12 lore raw
Quoted 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 ]
#13 lore raw

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
index 5401c679813a..5f49fd4653a7 100644
@@ -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
maintainer Applied
#14 lore raw

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 +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
index 5401c679813a..5f49fd4653a7 100644
@@ -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 ]