1 #ifndef _LINUX_KERNEL_VTIME_H
2 #define _LINUX_KERNEL_VTIME_H
4 #include <linux/context_tracking_state.h>
5 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
13 * vtime_accounting_enabled() definitions/declarations
15 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
16 static inline bool vtime_accounting_enabled(void) { return true; }
17 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
19 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
20 static inline bool vtime_accounting_enabled(void)
22 if (context_tracking_is_enabled()) {
23 if (context_tracking_cpu_is_enabled())
29 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */
31 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
32 static inline bool vtime_accounting_enabled(void) { return false; }
33 #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
39 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
41 #ifdef __ARCH_HAS_VTIME_TASK_SWITCH
42 extern void vtime_task_switch(struct task_struct *prev);
44 extern void vtime_common_task_switch(struct task_struct *prev);
45 static inline void vtime_task_switch(struct task_struct *prev)
47 if (vtime_accounting_enabled())
48 vtime_common_task_switch(prev);
50 #endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
52 extern void vtime_account_system(struct task_struct *tsk);
53 extern void vtime_account_idle(struct task_struct *tsk);
54 extern void vtime_account_user(struct task_struct *tsk);
56 #ifdef __ARCH_HAS_VTIME_ACCOUNT
57 extern void vtime_account_irq_enter(struct task_struct *tsk);
59 extern void vtime_common_account_irq_enter(struct task_struct *tsk);
60 static inline void vtime_account_irq_enter(struct task_struct *tsk)
62 if (vtime_accounting_enabled())
63 vtime_common_account_irq_enter(tsk);
65 #endif /* __ARCH_HAS_VTIME_ACCOUNT */
67 #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
69 static inline void vtime_task_switch(struct task_struct *prev) { }
70 static inline void vtime_account_system(struct task_struct *tsk) { }
71 static inline void vtime_account_user(struct task_struct *tsk) { }
72 static inline void vtime_account_irq_enter(struct task_struct *tsk) { }
73 #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
75 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
76 extern void arch_vtime_task_switch(struct task_struct *tsk);
77 extern void vtime_gen_account_irq_exit(struct task_struct *tsk);
79 static inline void vtime_account_irq_exit(struct task_struct *tsk)
81 if (vtime_accounting_enabled())
82 vtime_gen_account_irq_exit(tsk);
85 extern void vtime_user_enter(struct task_struct *tsk);
87 static inline void vtime_user_exit(struct task_struct *tsk)
89 vtime_account_user(tsk);
91 extern void vtime_guest_enter(struct task_struct *tsk);
92 extern void vtime_guest_exit(struct task_struct *tsk);
93 extern void vtime_init_idle(struct task_struct *tsk, int cpu);
94 #else /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */
95 static inline void vtime_account_irq_exit(struct task_struct *tsk)
97 /* On hard|softirq exit we always account to hard|softirq cputime */
98 vtime_account_system(tsk);
100 static inline void vtime_user_enter(struct task_struct *tsk) { }
101 static inline void vtime_user_exit(struct task_struct *tsk) { }
102 static inline void vtime_guest_enter(struct task_struct *tsk) { }
103 static inline void vtime_guest_exit(struct task_struct *tsk) { }
104 static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
107 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
108 extern void irqtime_account_irq(struct task_struct *tsk);
110 static inline void irqtime_account_irq(struct task_struct *tsk) { }
113 static inline void account_irq_enter_time(struct task_struct *tsk)
115 vtime_account_irq_enter(tsk);
116 irqtime_account_irq(tsk);
119 static inline void account_irq_exit_time(struct task_struct *tsk)
121 vtime_account_irq_exit(tsk);
122 irqtime_account_irq(tsk);
125 #endif /* _LINUX_KERNEL_VTIME_H */