[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20101012113958.058d68e3.kamezawa.hiroyu@jp.fujitsu.com>
Date: Tue, 12 Oct 2010 11:39:58 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Jack Steiner <steiner@....com>, yinghai@...nel.org,
mingo@...e.hu, linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] improve footprint of kstat_irqs() for large system's
/proc/stat
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Problem: 'cat /proc/stat' takes too long in verrrry big system.
In /proc/stat, the number of per-IRQ event is shown by making a sum
each irq's events on all cpus. We can make use of kstat_irqs().
This patch replaces it, at first.
Here, performance of kstat_irqs() is a problem.
If !CONFIG_GENERIC_HARDIRQ, it's not very slow, but if CONFIG_GENERIC_HARDIRQ,
it's slow because the logic is not efficient.
If CONFIG_GENERIC_HARDIRQ, it does
for_each_irq()
for_each_cpu()
- look up a radix tree
- read desc->irq_stat[cpu]
This seems not efficient. This patch adds kstat_irqs() for
CONFIG_GENRIC_HARDIRQ and change the calculation as
for_each_irq()
look up radix tree
for_each_cpu()
- read desc->irq_stat[cpu]
This reduces cost of scanning.
A test on (4096cpusp, 256 nodes, 4592 irqs) host (by Jack Steiner)
%time cat /proc/stat > /dev/null
Before Patch: 2.459 sec
After Patch : .561 sec
Tested-by: Jack Steiner <steiner@....com>
Acked-by: Jack Steiner <steiner@....com>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
---
fs/proc/stat.c | 9 ++-------
include/linux/kernel_stat.h | 4 ++++
kernel/irq/handle.c | 16 ++++++++++++++++
3 files changed, 22 insertions(+), 7 deletions(-)
Index: linux-2.6.36-rc7/fs/proc/stat.c
===================================================================
--- linux-2.6.36-rc7.orig/fs/proc/stat.c
+++ linux-2.6.36-rc7/fs/proc/stat.c
@@ -108,13 +108,8 @@ static int show_stat(struct seq_file *p,
seq_printf(p, "intr %llu", (unsigned long long)sum);
/* sum again ? it could be updated? */
- for_each_irq_nr(j) {
- per_irq_sum = 0;
- for_each_possible_cpu(i)
- per_irq_sum += kstat_irqs_cpu(j, i);
-
- seq_printf(p, " %u", per_irq_sum);
- }
+ for_each_irq_nr(j)
+ seq_printf(p, " %u", kstat_irqs(j));
seq_printf(p,
"\nctxt %llu\n"
Index: linux-2.6.36-rc7/include/linux/kernel_stat.h
===================================================================
--- linux-2.6.36-rc7.orig/include/linux/kernel_stat.h
+++ linux-2.6.36-rc7/include/linux/kernel_stat.h
@@ -86,6 +86,7 @@ static inline unsigned int kstat_softirq
/*
* Number of interrupts per specific IRQ source, since bootup
*/
+#ifndef CONFIG_GENERIC_HARDIRQS
static inline unsigned int kstat_irqs(unsigned int irq)
{
unsigned int sum = 0;
@@ -96,6 +97,9 @@ static inline unsigned int kstat_irqs(un
return sum;
}
+#else
+extern unsigned int kstat_irqs(unsigned int irq);
+#endif
/*
* Number of interrupts per cpu, since bootup
Index: linux-2.6.36-rc7/kernel/irq/handle.c
===================================================================
--- linux-2.6.36-rc7.orig/kernel/irq/handle.c
+++ linux-2.6.36-rc7/kernel/irq/handle.c
@@ -554,3 +554,19 @@ unsigned int kstat_irqs_cpu(unsigned int
}
EXPORT_SYMBOL(kstat_irqs_cpu);
+#ifdef CONFIG_GENERIC_HARDIRQS
+unsigned int kstat_irqs(unsigned int irq)
+{
+ struct irq_desc *desc = irq_to_desc(irq);
+ int cpu;
+ int sum = 0;
+
+ if (!desc)
+ return 0;
+
+ for_each_possible_cpu(cpu)
+ sum += desc->kstat_irqs[cpu];
+ return sum;
+}
+EXPORT_SYMBOL(kstat_irqs);
+#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists