vtime.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _LINUX_KERNEL_VTIME_H
  2. #define _LINUX_KERNEL_VTIME_H
  3. struct task_struct;
  4. #ifdef CONFIG_VIRT_CPU_ACCOUNTING
  5. extern void vtime_task_switch(struct task_struct *prev);
  6. extern void vtime_account_system(struct task_struct *tsk);
  7. extern void vtime_account_system_irqsafe(struct task_struct *tsk);
  8. extern void vtime_account_idle(struct task_struct *tsk);
  9. extern void vtime_account_user(struct task_struct *tsk);
  10. extern void vtime_account(struct task_struct *tsk);
  11. #else
  12. static inline void vtime_task_switch(struct task_struct *prev) { }
  13. static inline void vtime_account_system(struct task_struct *tsk) { }
  14. static inline void vtime_account_system_irqsafe(struct task_struct *tsk) { }
  15. static inline void vtime_account_user(struct task_struct *tsk) { }
  16. static inline void vtime_account(struct task_struct *tsk) { }
  17. #endif
  18. #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
  19. static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
  20. static inline void vtime_user_enter(struct task_struct *tsk)
  21. {
  22. vtime_account_system(tsk);
  23. }
  24. static inline void vtime_user_exit(struct task_struct *tsk)
  25. {
  26. vtime_account_user(tsk);
  27. }
  28. #else
  29. static inline void vtime_user_enter(struct task_struct *tsk) { }
  30. static inline void vtime_user_exit(struct task_struct *tsk) { }
  31. #endif
  32. #ifdef CONFIG_IRQ_TIME_ACCOUNTING
  33. extern void irqtime_account_irq(struct task_struct *tsk);
  34. #else
  35. static inline void irqtime_account_irq(struct task_struct *tsk) { }
  36. #endif
  37. static inline void vtime_account_irq_enter(struct task_struct *tsk)
  38. {
  39. /*
  40. * Hardirq can interrupt idle task anytime. So we need vtime_account()
  41. * that performs the idle check in CONFIG_VIRT_CPU_ACCOUNTING.
  42. * Softirq can also interrupt idle task directly if it calls
  43. * local_bh_enable(). Such case probably don't exist but we never know.
  44. * Ksoftirqd is not concerned because idle time is flushed on context
  45. * switch. Softirqs in the end of hardirqs are also not a problem because
  46. * the idle time is flushed on hardirq time already.
  47. */
  48. vtime_account(tsk);
  49. irqtime_account_irq(tsk);
  50. }
  51. static inline void vtime_account_irq_exit(struct task_struct *tsk)
  52. {
  53. /* On hard|softirq exit we always account to hard|softirq cputime */
  54. vtime_account_system(tsk);
  55. irqtime_account_irq(tsk);
  56. }
  57. #endif /* _LINUX_KERNEL_VTIME_H */