Skip to contentSkip to conversation

riscv/irq: use seq_put_decimal_ull_width() for decimal values

PATCH Applied David Wang 3 participants 4 messages Nov 8, 2024 – Feb 26, 2025 RISC-V

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

David Wang

author
#0 lore raw

PATCH 12/13 riscv/irq: use seq_put_decimal_ull_width() for decimal values

Performance improvement for reading /proc/interrupts on arch riscv

---
 arch/riscv/kernel/smp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/smp.c +2 -1
index c180a647a30e..f1e9c3db094c 100644
@@ -226,7 +226,8 @@ void show_ipi_stats(struct seq_file *p, int prec)
 		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
 			   prec >= 4 ? " " : "");
 		for_each_online_cpu(cpu)
-			seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu));
+			seq_put_decimal_ull_width(p, " ",
+						  irq_desc_kstat_cpu(ipi_desc[i], cpu), 10);
 		seq_printf(p, " %s\n", ipi_names[i]);
 	}
 }
Signature · 1 line
2.39.2
Reviewed-by Tested-by on v1 12/13
#1 lore raw
Quoted 3 lines · David Wang

Performance improvement for reading /proc/interrupts on arch riscv

Quoted 26 lines
---
 arch/riscv/kernel/smp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/smp.c +2 -1
index c180a647a30e..f1e9c3db094c 100644
@@ -226,7 +226,8 @@ void show_ipi_stats(struct seq_file *p, int prec)
 		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
 			   prec >= 4 ? " " : "");
 		for_each_online_cpu(cpu)
-			seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu));
+			seq_put_decimal_ull_width(p, " ",
+						  irq_desc_kstat_cpu(ipi_desc[i], cpu), 10);
 		seq_printf(p, " %s\n", ipi_names[i]);
 	}
 }
Signature · 7 lines
2.39.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw
In reply to David Wang

Hi David,

Quoted 12 lines · David Wang

Performance improvement for reading /proc/interrupts on arch riscv

---
  arch/riscv/kernel/smp.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/smp.c +0 -0
index c180a647a30e..f1e9c3db094c 100644

arch/riscv/kernel/smp.c void show_ipi_stats(struct seq_file *p, int prec) · line 233

Quoted 9 lines
arch/riscv/kernel/smp.c +2 -1
@@ -226,7 +226,8 @@ void show_ipi_stats(struct seq_file *p, int prec)
  		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
  			   prec >= 4 ? " " : "");
  		for_each_online_cpu(cpu)
-			seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu));
+			seq_put_decimal_ull_width(p, " ",
+						  irq_desc_kstat_cpu(ipi_desc[i], cpu), 10);
  		seq_printf(p, " %s\n", ipi_names[i]);
  	}
  }

Very late answer sorry!

I don't have the same output before and after your patch because seq_put_decimal_ull_width() second argument is placed *before* the number, not after as it was before.

The following diff fixes the issue:

arch/riscv/kernel/smp.c index f1e9c3db094c3..4b80ee4e5b2c0 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -225,9 +225,11 @@ void show_ipi_stats(struct seq_file *p, int prec) for (i = 0; i < IPI_MAX; i++) { seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, prec >= 4 ? " " : ""); - for_each_online_cpu(cpu) - seq_put_decimal_ull_width(p, " ", + for_each_online_cpu(cpu) { + seq_put_decimal_ull_width(p, NULL, irq_desc_kstat_cpu(ipi_desc[i], cpu), 10); + seq_putc(p, ' '); + } seq_printf(p, " %s\n", ipi_names[i]); } } renamed from arch/riscv/kernel/smp.c +0 -0

Will you respin a new version?

Thanks,

Alex

author
#3 lore raw

Hi,

Thanks for the test and review, and sorry for not giving more attentions to alignment issues when made the patch. But if alignment should not be changed, simply appending a [space] is not enough: the patch change
'%10u[space]" to "[space]%10u", one [space] is moved from tail to the front, and to restore to its original state
, one [space] should be removed from front. and It would make the code ugly and unpleasant to remove a [space] from this line

        seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, prec >= 4 ? " " : "");

( or make changes to seq_put_decimal_ull_width)

Kind of think that it does not worth the effort if code changes are way too unpleasant....

Thanks
David

Quoted 44 lines · Alexandre Ghiti

Hi David,

Quoted 12 lines · David Wang

Performance improvement for reading /proc/interrupts on arch riscv

---
  arch/riscv/kernel/smp.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/smp.c +0 -0
index c180a647a30e..f1e9c3db094c 100644

arch/riscv/kernel/smp.c void show_ipi_stats(struct seq_file *p, int prec) · line 233

Quoted 9 lines
arch/riscv/kernel/smp.c +2 -1
@@ -226,7 +226,8 @@ void show_ipi_stats(struct seq_file *p, int prec)
  		seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i,
  			   prec >= 4 ? " " : "");
  		for_each_online_cpu(cpu)
-			seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu));
+			seq_put_decimal_ull_width(p, " ",
+						  irq_desc_kstat_cpu(ipi_desc[i], cpu), 10);
  		seq_printf(p, " %s\n", ipi_names[i]);
  	}
  }

Very late answer sorry!

I don't have the same output before and after your patch because seq_put_decimal_ull_width() second argument is placed *before* the number, not after as it was before.

The following diff fixes the issue:

arch/riscv/kernel/smp.c index renamed from arch/riscv/kernel/smp.c +0 -0

f1e9c3db094c3..4b80ee4e5b2c0 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -225,9 +225,11 @@ void show_ipi_stats(struct seq_file *p, int prec) for (i = 0; i < IPI_MAX; i++) { seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, prec >= 4 ? " " :
""); - for_each_online_cpu(cpu) - seq_put_decimal_ull_width(p, " ", + for_each_online_cpu(cpu) { + seq_put_decimal_ull_width(p, NULL, irq_desc_kstat_cpu(ipi_desc[i], cpu), 10); + seq_putc(p, ' '); + } seq_printf(p, " %s\n", ipi_names[i]); } }

Quoted 5 lines

Will you respin a new version?

Thanks,

Alex

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv