vtime.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(struct task_struct *tsk);
  10. #else
  11. static inline void vtime_task_switch(struct task_struct *prev) { }
  12. static inline void vtime_account_system(struct task_struct *tsk) { }
  13. static inline void vtime_account_system_irqsafe(struct task_struct *tsk) { }
  14. static inline void vtime_account(struct task_struct *tsk) { }
  15. #endif
  16. #ifdef CONFIG_IRQ_TIME_ACCOUNTING
  17. extern void irqtime_account_irq(struct task_struct *tsk);
  18. #else
  19. static inline void irqtime_account_irq(struct task_struct *tsk) { }
  20. #endif
  21. static inline void vtime_account_irq_enter(struct task_struct *tsk)
  22. {
  23. /*
  24. * Hardirq can interrupt idle task anytime. So we need vtime_account()
  25. * that performs the idle check in CONFIG_VIRT_CPU_ACCOUNTING.
  26. * Softirq can also interrupt idle task directly if it calls
  27. * local_bh_enable(). Such case probably don't exist but we never know.
  28. * Ksoftirqd is not concerned because idle time is flushed on context
  29. * switch. Softirqs in the end of hardirqs are also not a problem because
  30. * the idle time is flushed on hardirq time already.
  31. */
  32. vtime_account(tsk);
  33. irqtime_account_irq(tsk);
  34. }
  35. static inline void vtime_account_irq_exit(struct task_struct *tsk)
  36. {
  37. /* On hard|softirq exit we always account to hard|softirq cputime */
  38. vtime_account_system(tsk);
  39. irqtime_account_irq(tsk);
  40. }
  41. #endif /* _LINUX_KERNEL_VTIME_H */