]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/kernel_stat.h
1 #ifndef _LINUX_KERNEL_STAT_H
2 #define _LINUX_KERNEL_STAT_H
5 #include <linux/threads.h>
6 #include <linux/percpu.h>
7 #include <linux/cpumask.h>
8 #include <linux/interrupt.h>
9 #include <linux/sched.h>
10 #include <linux/vtime.h>
14 * 'kernel_stat.h' contains the definitions needed for doing
15 * some kernel statistics (CPU usage, context switches ...),
16 * used by rstatd/perfmeter
33 struct kernel_cpustat
{
34 u64 cpustat
[NR_STATS
];
38 unsigned long irqs_sum
;
39 unsigned int softirqs
[NR_SOFTIRQS
];
42 DECLARE_PER_CPU(struct kernel_stat
, kstat
);
43 DECLARE_PER_CPU(struct kernel_cpustat
, kernel_cpustat
);
45 /* Must have preemption disabled for this to be meaningful. */
46 #define kstat_this_cpu this_cpu_ptr(&kstat)
47 #define kcpustat_this_cpu this_cpu_ptr(&kernel_cpustat)
48 #define kstat_cpu(cpu) per_cpu(kstat, cpu)
49 #define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu)
51 extern unsigned long long nr_context_switches(void);
53 extern unsigned int kstat_irqs_cpu(unsigned int irq
, int cpu
);
54 extern void kstat_incr_irq_this_cpu(unsigned int irq
);
56 static inline void kstat_incr_softirqs_this_cpu(unsigned int irq
)
58 __this_cpu_inc(kstat
.softirqs
[irq
]);
61 static inline unsigned int kstat_softirqs_cpu(unsigned int irq
, int cpu
)
63 return kstat_cpu(cpu
).softirqs
[irq
];
67 * Number of interrupts per specific IRQ source, since bootup
69 extern unsigned int kstat_irqs(unsigned int irq
);
70 extern unsigned int kstat_irqs_usr(unsigned int irq
);
73 * Number of interrupts per cpu, since bootup
75 static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu
)
77 return kstat_cpu(cpu
).irqs_sum
;
80 extern void account_user_time(struct task_struct
*, u64
);
81 extern void account_guest_time(struct task_struct
*, u64
);
82 extern void account_system_time(struct task_struct
*, int, u64
);
83 extern void account_system_index_time(struct task_struct
*, u64
,
85 extern void account_steal_time(u64
);
86 extern void account_idle_time(u64
);
88 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
89 static inline void account_process_tick(struct task_struct
*tsk
, int user
)
94 extern void account_process_tick(struct task_struct
*, int user
);
97 extern void account_idle_ticks(unsigned long ticks
);
99 #endif /* _LINUX_KERNEL_STAT_H */