public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/13] kernel/irq/proc: use seq_put_decimal_ull_width() for decimal values
@ 2024-11-08 16:07 David Wang
  2024-11-13 16:44 ` [tip: irq/core] genirq/proc: Use " tip-bot2 for David Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: David Wang @ 2024-11-08 16:07 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, David Wang

seq_printf() is costy, on a system with m interrupts and n CPUs, there
would be m*n decimal values yield via seq_printf() when reading
/proc/interrupts, the cost parsing format strings grows with number of
CPU. Profiling on a x86 8-core system indicates seq_printf() takes ~47%
samples of show_interrupts(), and replace seq_printf() with
seq_put_decimal_ull_width() could have near 30% performance gain.

The improvement has pratical significance, considering many monitoring
tools would read /proc/interrupts periodically.

Signed-off-by: David Wang <00107082@163.com>
---
 kernel/irq/proc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 9081ada81c3d..988ce781e813 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -494,9 +494,11 @@ int show_interrupts(struct seq_file *p, void *v)
 	if (!desc->action || irq_desc_is_chained(desc) || !desc->kstat_irqs)
 		goto outsparse;
 
-	seq_printf(p, "%*d: ", prec, i);
+	seq_printf(p, "%*d:", prec, i);
 	for_each_online_cpu(j)
-		seq_printf(p, "%10u ", desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt, j) : 0);
+		seq_put_decimal_ull_width(p, " ",
+					  desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt, j) : 0,
+					  10);
 
 	raw_spin_lock_irqsave(&desc->lock, flags);
 	if (desc->irq_data.chip) {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-11-20  9:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 16:07 [PATCH 01/13] kernel/irq/proc: use seq_put_decimal_ull_width() for decimal values David Wang
2024-11-13 16:44 ` [tip: irq/core] genirq/proc: Use " tip-bot2 for David Wang
2024-11-13 19:10 ` [PATCH 01/13] kernel/irq/proc: use " Thomas Gleixner
2024-11-14 12:10   ` David Wang
2024-11-19 19:55 ` Geert Uytterhoeven
2024-11-20  1:20   ` Thomas Gleixner
2024-11-20  1:36     ` David Wang
2024-11-20  4:24     ` David Wang
2024-11-20  8:56     ` Geert Uytterhoeven
2024-11-20  1:37   ` David Wang
2024-11-20  2:08     ` David Wang
2024-11-20  9:00       ` Geert Uytterhoeven
2024-11-20  9:36         ` David Wang
2024-11-20  9:56           ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox