blob: c35c02223da8e22c112f9c8862a3231065fcfd45 [file] [log] [blame]
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +02001#ifndef _LINUX_KERNEL_VTIME_H
2#define _LINUX_KERNEL_VTIME_H
3
4struct task_struct;
5
6#ifdef CONFIG_VIRT_CPU_ACCOUNTING
7extern void vtime_task_switch(struct task_struct *prev);
Frederic Weisbecker11113332012-10-24 18:05:51 +02008extern void __vtime_account_system(struct task_struct *tsk);
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +02009extern void vtime_account_system(struct task_struct *tsk);
Frederic Weisbecker11113332012-10-24 18:05:51 +020010extern void __vtime_account_idle(struct task_struct *tsk);
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020011#else
12static inline void vtime_task_switch(struct task_struct *prev) { }
Frederic Weisbecker11113332012-10-24 18:05:51 +020013static inline void vtime_account_system(struct task_struct *tsk) { }
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020014#endif
15
16#if !defined(CONFIG_VIRT_CPU_ACCOUNTING) && !defined(CONFIG_IRQ_TIME_ACCOUNTING)
17static inline void vtime_account(struct task_struct *tsk)
18{
19}
20#else
21extern void vtime_account(struct task_struct *tsk);
22#endif
23
Frederic Weisbeckerfa5058f2012-10-06 04:07:19 +020024static inline void vtime_account_irq_enter(struct task_struct *tsk)
25{
26 /*
27 * Hardirq can interrupt idle task anytime. So we need vtime_account()
28 * that performs the idle check in CONFIG_VIRT_CPU_ACCOUNTING.
29 * Softirq can also interrupt idle task directly if it calls
30 * local_bh_enable(). Such case probably don't exist but we never know.
31 * Ksoftirqd is not concerned because idle time is flushed on context
32 * switch. Softirqs in the end of hardirqs are also not a problem because
33 * the idle time is flushed on hardirq time already.
34 */
35 vtime_account(tsk);
36}
37
38static inline void vtime_account_irq_exit(struct task_struct *tsk)
39{
40#ifdef CONFIG_VIRT_CPU_ACCOUNTING
41 /* On hard|softirq exit we always account to hard|softirq cputime */
42 __vtime_account_system(tsk);
43#endif
44#ifdef CONFIG_IRQ_TIME_ACCOUNTING
45 vtime_account(tsk);
46#endif
47}
48
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020049#endif /* _LINUX_KERNEL_VTIME_H */