Skip to content

Commit

Permalink
genirq/proc: Use seq_put_decimal_ull_width() for decimal values
Browse files Browse the repository at this point in the history
seq_printf() is more expensive than seq_put_decimal_ull_width() due to the
format string parsing costs.

Profiling on a x86 8-core system indicates seq_printf() takes ~47% samples
of show_interrupts(). Replacing it with seq_put_decimal_ull_width() yields
almost 30% performance gain.

[ tglx: Massaged changelog and fixed up coding style ]

Signed-off-by: David Wang <00107082@163.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241108160717.9547-1-00107082@163.com
  • Loading branch information
David Wang authored and Thomas Gleixner committed Nov 13, 2024
1 parent 49a1763 commit f9ed1f7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/irq/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,12 @@ 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);
for_each_online_cpu(j)
seq_printf(p, "%10u ", desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt, j) : 0);
seq_printf(p, "%*d:", prec, i);
for_each_online_cpu(j) {
unsigned int cnt = desc->kstat_irqs ? per_cpu(desc->kstat_irqs->cnt, j) : 0;

seq_put_decimal_ull_width(p, " ", cnt, 10);
}

raw_spin_lock_irqsave(&desc->lock, flags);
if (desc->irq_data.chip) {
Expand Down

0 comments on commit f9ed1f7

Please sign in to comment.