vtime.h 1.7 KB

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