diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-01-13 18:45:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 20:32:31 -0500 |
commit | 6c9ae009b298753a3baf71298d676a68b5a10c8f (patch) | |
tree | 95a7e4ca54fe8e96c95cedd4e8d6450659015212 /include/linux/kernel_stat.h | |
parent | 558bbb2fc75fd9676e07e347c021865e326c56db (diff) |
irq: use per_cpu kstat_irqs
Use modern per_cpu API to increment {soft|hard}irq counters, and use
per_cpu allocation for (struct irq_desc)->kstats_irq instead of an array.
This gives better SMP/NUMA locality and saves few instructions per irq.
With small nr_cpuids values (8 for example), kstats_irq was a small array
(less than L1_CACHE_BYTES), potentially source of false sharing.
In the !CONFIG_SPARSE_IRQ case, remove the huge, NUMA/cache unfriendly
kstat_irqs_all[NR_IRQS][NR_CPUS] array.
Note: we still populate kstats_irq for all possible irqs in
early_irq_init(). We probably could use on-demand allocations. (Code
included in alloc_descs()). Problem is not all IRQS are used with a prior
alloc_descs() call.
kstat_irqs_this_cpu() is not used anymore, remove it.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel_stat.h')
-rw-r--r-- | include/linux/kernel_stat.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index 44e83ba12b5..0cce2db580c 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h | |||
@@ -46,16 +46,14 @@ DECLARE_PER_CPU(struct kernel_stat, kstat); | |||
46 | extern unsigned long long nr_context_switches(void); | 46 | extern unsigned long long nr_context_switches(void); |
47 | 47 | ||
48 | #ifndef CONFIG_GENERIC_HARDIRQS | 48 | #ifndef CONFIG_GENERIC_HARDIRQS |
49 | #define kstat_irqs_this_cpu(irq) \ | ||
50 | (this_cpu_read(kstat.irqs[irq]) | ||
51 | 49 | ||
52 | struct irq_desc; | 50 | struct irq_desc; |
53 | 51 | ||
54 | static inline void kstat_incr_irqs_this_cpu(unsigned int irq, | 52 | static inline void kstat_incr_irqs_this_cpu(unsigned int irq, |
55 | struct irq_desc *desc) | 53 | struct irq_desc *desc) |
56 | { | 54 | { |
57 | kstat_this_cpu.irqs[irq]++; | 55 | __this_cpu_inc(kstat.irqs[irq]); |
58 | kstat_this_cpu.irqs_sum++; | 56 | __this_cpu_inc(kstat.irqs_sum); |
59 | } | 57 | } |
60 | 58 | ||
61 | static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) | 59 | static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) |
@@ -65,17 +63,18 @@ static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu) | |||
65 | #else | 63 | #else |
66 | #include <linux/irq.h> | 64 | #include <linux/irq.h> |
67 | extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu); | 65 | extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu); |
68 | #define kstat_irqs_this_cpu(DESC) \ | 66 | |
69 | ((DESC)->kstat_irqs[smp_processor_id()]) | 67 | #define kstat_incr_irqs_this_cpu(irqno, DESC) \ |
70 | #define kstat_incr_irqs_this_cpu(irqno, DESC) do {\ | 68 | do { \ |
71 | ((DESC)->kstat_irqs[smp_processor_id()]++);\ | 69 | __this_cpu_inc(*(DESC)->kstat_irqs); \ |
72 | kstat_this_cpu.irqs_sum++; } while (0) | 70 | __this_cpu_inc(kstat.irqs_sum); \ |
71 | } while (0) | ||
73 | 72 | ||
74 | #endif | 73 | #endif |
75 | 74 | ||
76 | static inline void kstat_incr_softirqs_this_cpu(unsigned int irq) | 75 | static inline void kstat_incr_softirqs_this_cpu(unsigned int irq) |
77 | { | 76 | { |
78 | kstat_this_cpu.softirqs[irq]++; | 77 | __this_cpu_inc(kstat.softirqs[irq]); |
79 | } | 78 | } |
80 | 79 | ||
81 | static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu) | 80 | static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu) |