1 #ifndef _LINUX_KERNEL_STAT_H
2 #define _LINUX_KERNEL_STAT_H
3 
4 #include <linux/config.h>
5 #include <asm/irq.h>
6 #include <linux/smp.h>
7 #include <linux/threads.h>
8 
9 /*
10  * 'kernel_stat.h' contains the definitions needed for doing
11  * some kernel statistics (CPU usage, context switches ...),
12  * used by rstatd/perfmeter
13  */
14 
15 #define DK_MAX_MAJOR 16
16 #define DK_MAX_DISK 16
17 
18 struct kernel_stat {
19 	unsigned int per_cpu_user[NR_CPUS],
20 	             per_cpu_nice[NR_CPUS],
21 	             per_cpu_system[NR_CPUS];
22 	unsigned int dk_drive[DK_MAX_MAJOR][DK_MAX_DISK];
23 	unsigned int dk_drive_rio[DK_MAX_MAJOR][DK_MAX_DISK];
24 	unsigned int dk_drive_wio[DK_MAX_MAJOR][DK_MAX_DISK];
25 	unsigned int dk_drive_rblk[DK_MAX_MAJOR][DK_MAX_DISK];
26 	unsigned int dk_drive_wblk[DK_MAX_MAJOR][DK_MAX_DISK];
27 	unsigned int pgpgin, pgpgout;
28 	unsigned int pswpin, pswpout;
29 #if defined (__hppa__)
30 	unsigned int irqs[NR_CPUS][NR_IRQ_REGS][IRQ_PER_REGION];
31 #elif !defined(CONFIG_ARCH_S390)
32 	unsigned int irqs[NR_CPUS][NR_IRQS];
33 #endif
34 	unsigned int context_swtch;
35 };
36 
37 extern struct kernel_stat kstat;
38 
39 extern unsigned long nr_context_switches(void);
40 
41 #if defined (__hppa__)
42 /*
43  * Number of interrupts per specific IRQ source, since bootup
44  */
kstat_irqs(int irq)45 static inline int kstat_irqs (int irq)
46 {
47 	int i, sum=0;
48 
49 	for (i = 0 ; i < smp_num_cpus ; i++)
50 		sum += kstat.irqs[i][IRQ_REGION(irq)][IRQ_OFFSET(irq)];
51 
52 	return sum;
53 }
54 #elif !defined(CONFIG_ARCH_S390)
55 /*
56  * Number of interrupts per specific IRQ source, since bootup
57  */
kstat_irqs(int irq)58 extern inline int kstat_irqs (int irq)
59 {
60 	int i, sum=0;
61 
62 	for (i = 0 ; i < smp_num_cpus ; i++)
63 		sum += kstat.irqs[cpu_logical_map(i)][irq];
64 
65 	return sum;
66 }
67 #endif
68 
69 #endif /* _LINUX_KERNEL_STAT_H */
70