mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] proc/softirqs: replace seq_printf with seq_put_decimal_ull_width
@ 2024-11-06  2:12 David Wang
  2024-11-07 17:47 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: David Wang @ 2024-11-06  2:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, torvalds, David Wang

seq_printf is costy, on a system with n CPUs, reading /proc/softirqs
would yield 10*n decimal values, and the extra cost parsing format string
grows linearly with number of cpus. Replace seq_printf with
seq_put_decimal_ull_width have significant performance improvement.
On an 8CPUs system, reading /proc/softirqs show ~40% performance
gain with this patch.

Signed-off-by: David Wang <00107082@163.com>
---
 fs/proc/softirqs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/softirqs.c b/fs/proc/softirqs.c
index f4616083faef..04bb29721419 100644
--- a/fs/proc/softirqs.c
+++ b/fs/proc/softirqs.c
@@ -20,7 +20,7 @@ static int show_softirqs(struct seq_file *p, void *v)
 	for (i = 0; i < NR_SOFTIRQS; i++) {
 		seq_printf(p, "%12s:", softirq_to_name[i]);
 		for_each_possible_cpu(j)
-			seq_printf(p, " %10u", kstat_softirqs_cpu(i, j));
+			seq_put_decimal_ull_width(p, " ", kstat_softirqs_cpu(i, j), 10);
 		seq_putc(p, '\n');
 	}
 	return 0;
-- 
2.39.2


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

* Re: [PATCH] proc/softirqs: replace seq_printf with seq_put_decimal_ull_width
  2024-11-06  2:12 [PATCH] proc/softirqs: replace seq_printf with seq_put_decimal_ull_width David Wang
@ 2024-11-07 17:47 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2024-11-07 17:47 UTC (permalink / raw)
  To: David Wang; +Cc: linux-kernel, tglx

On Tue, 5 Nov 2024 at 16:13, David Wang <00107082@163.com> wrote:
>
> seq_printf is costy, on a system with n CPUs, reading /proc/softirqs
> would yield 10*n decimal values, and the extra cost parsing format string
> grows linearly with number of cpus. Replace seq_printf with
> seq_put_decimal_ull_width have significant performance improvement.

Applied.

               Linus

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

end of thread, other threads:[~2024-11-07 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-06  2:12 [PATCH] proc/softirqs: replace seq_printf with seq_put_decimal_ull_width David Wang
2024-11-07 17:47 ` Linus Torvalds

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

all inboxes | Powered by JetHome®