kernel_stat.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _LINUX_KERNEL_STAT_H
  2. #define _LINUX_KERNEL_STAT_H
  3. #include <linux/smp.h>
  4. #include <linux/threads.h>
  5. #include <linux/percpu.h>
  6. #include <linux/cpumask.h>
  7. #include <asm/irq.h>
  8. #include <asm/cputime.h>
  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. struct cpu_usage_stat {
  15. cputime64_t user;
  16. cputime64_t nice;
  17. cputime64_t system;
  18. cputime64_t softirq;
  19. cputime64_t irq;
  20. cputime64_t idle;
  21. cputime64_t iowait;
  22. cputime64_t steal;
  23. cputime64_t guest;
  24. };
  25. struct kernel_stat {
  26. struct cpu_usage_stat cpustat;
  27. unsigned int irqs[NR_IRQS];
  28. };
  29. DECLARE_PER_CPU(struct kernel_stat, kstat);
  30. #define kstat_cpu(cpu) per_cpu(kstat, cpu)
  31. /* Must have preemption disabled for this to be meaningful. */
  32. #define kstat_this_cpu __get_cpu_var(kstat)
  33. extern unsigned long long nr_context_switches(void);
  34. /*
  35. * Number of interrupts per specific IRQ source, since bootup
  36. */
  37. static inline int kstat_irqs(int irq)
  38. {
  39. int cpu, sum = 0;
  40. for_each_possible_cpu(cpu)
  41. sum += kstat_cpu(cpu).irqs[irq];
  42. return sum;
  43. }
  44. extern unsigned long long task_delta_exec(struct task_struct *);
  45. extern void account_user_time(struct task_struct *, cputime_t);
  46. extern void account_user_time_scaled(struct task_struct *, cputime_t);
  47. extern void account_system_time(struct task_struct *, int, cputime_t);
  48. extern void account_system_time_scaled(struct task_struct *, cputime_t);
  49. extern void account_steal_time(struct task_struct *, cputime_t);
  50. #endif /* _LINUX_KERNEL_STAT_H */