mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
84b9749a3a
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>
38 lines
840 B
C
38 lines
840 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/init.h>
|
|
#include <linux/kernel_stat.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include "internal.h"
|
|
|
|
/*
|
|
* /proc/softirqs ... display the number of softirqs
|
|
*/
|
|
static int show_softirqs(struct seq_file *p, void *v)
|
|
{
|
|
int i, j;
|
|
|
|
seq_puts(p, " ");
|
|
for_each_possible_cpu(i)
|
|
seq_printf(p, "CPU%-8d", i);
|
|
seq_putc(p, '\n');
|
|
|
|
for (i = 0; i < NR_SOFTIRQS; i++) {
|
|
seq_printf(p, "%12s:", softirq_to_name[i]);
|
|
for_each_possible_cpu(j)
|
|
seq_put_decimal_ull_width(p, " ", kstat_softirqs_cpu(i, j), 10);
|
|
seq_putc(p, '\n');
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int __init proc_softirqs_init(void)
|
|
{
|
|
struct proc_dir_entry *pde;
|
|
|
|
pde = proc_create_single("softirqs", 0, NULL, show_softirqs);
|
|
pde_make_permanent(pde);
|
|
return 0;
|
|
}
|
|
fs_initcall(proc_softirqs_init);
|