]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
proc/softirqs: replace seq_printf with seq_put_decimal_ull_width
authorDavid Wang <00107082@163.com>
Wed, 6 Nov 2024 02:12:28 +0000 (10:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:47:42 +0000 (19:47 +0100)
[ Upstream commit 84b9749a3a704dcc824a88aa8267247c801d51e4 ]

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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/proc/softirqs.c

index 12901dcf57e2bdce9610e8979f1f1d3781e55bc1..d8f4e7d54d002df251a71d3c591253d649dbb1ac 100644 (file)
@@ -19,7 +19,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;