blob: 71a5782d8c592fc027cd1e0ce7c4c5a99787c11f [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);
8extern void vtime_account_system(struct task_struct *tsk);
Frederic Weisbeckerfd25b4c2012-11-13 18:21:22 +01009extern void vtime_account_idle(struct task_struct *tsk);
Frederic Weisbeckerbcebdf82012-11-13 23:51:06 +010010extern void vtime_account_user(struct task_struct *tsk);
Frederic Weisbecker6a616712012-12-16 20:00:34 +010011extern void vtime_account_irq_enter(struct task_struct *tsk);
Frederic Weisbecker3f4724e2012-07-16 18:00:34 +020012
Frederic Weisbecker6a616712012-12-16 20:00:34 +010013#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
Frederic Weisbecker3f4724e2012-07-16 18:00:34 +020014static inline bool vtime_accounting_enabled(void) { return true; }
15#endif
16
17#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
Frederic Weisbecker6a616712012-12-16 20:00:34 +010018
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020019static inline void vtime_task_switch(struct task_struct *prev) { }
Frederic Weisbecker11113332012-10-24 18:05:51 +020020static inline void vtime_account_system(struct task_struct *tsk) { }
Frederic Weisbeckerabf917c2012-07-25 07:56:04 +020021static inline void vtime_account_user(struct task_struct *tsk) { }
Frederic Weisbecker6a616712012-12-16 20:00:34 +010022static inline void vtime_account_irq_enter(struct task_struct *tsk) { }
Frederic Weisbecker3f4724e2012-07-16 18:00:34 +020023static inline bool vtime_accounting_enabled(void) { return false; }
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020024#endif
25
Frederic Weisbeckerabf917c2012-07-25 07:56:04 +020026#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
Frederic Weisbecker6a616712012-12-16 20:00:34 +010027extern void arch_vtime_task_switch(struct task_struct *tsk);
28extern void vtime_account_irq_exit(struct task_struct *tsk);
29extern bool vtime_accounting_enabled(void);
30extern void vtime_user_enter(struct task_struct *tsk);
Frederic Weisbeckerabf917c2012-07-25 07:56:04 +020031static inline void vtime_user_exit(struct task_struct *tsk)
32{
33 vtime_account_user(tsk);
34}
Frederic Weisbecker6a616712012-12-16 20:00:34 +010035extern void vtime_guest_enter(struct task_struct *tsk);
36extern void vtime_guest_exit(struct task_struct *tsk);
37extern void vtime_init_idle(struct task_struct *tsk);
Frederic Weisbeckerabf917c2012-07-25 07:56:04 +020038#else
Frederic Weisbecker6a616712012-12-16 20:00:34 +010039static inline void vtime_account_irq_exit(struct task_struct *tsk)
40{
41 /* On hard|softirq exit we always account to hard|softirq cputime */
42 vtime_account_system(tsk);
43}
Frederic Weisbeckerabf917c2012-07-25 07:56:04 +020044static inline void vtime_user_enter(struct task_struct *tsk) { }
45static inline void vtime_user_exit(struct task_struct *tsk) { }
Frederic Weisbecker6a616712012-12-16 20:00:34 +010046static inline void vtime_guest_enter(struct task_struct *tsk) { }
47static inline void vtime_guest_exit(struct task_struct *tsk) { }
48static inline void vtime_init_idle(struct task_struct *tsk) { }
Frederic Weisbeckerabf917c2012-07-25 07:56:04 +020049#endif
50
Frederic Weisbecker3e1df4f52012-10-06 05:23:22 +020051#ifdef CONFIG_IRQ_TIME_ACCOUNTING
52extern void irqtime_account_irq(struct task_struct *tsk);
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020053#else
Frederic Weisbecker3e1df4f52012-10-06 05:23:22 +020054static inline void irqtime_account_irq(struct task_struct *tsk) { }
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020055#endif
56
Frederic Weisbecker6a616712012-12-16 20:00:34 +010057static inline void account_irq_enter_time(struct task_struct *tsk)
Frederic Weisbeckerfa5058f2012-10-06 04:07:19 +020058{
Frederic Weisbecker6a616712012-12-16 20:00:34 +010059 vtime_account_irq_enter(tsk);
Frederic Weisbecker3e1df4f52012-10-06 05:23:22 +020060 irqtime_account_irq(tsk);
Frederic Weisbeckerfa5058f2012-10-06 04:07:19 +020061}
62
Frederic Weisbecker6a616712012-12-16 20:00:34 +010063static inline void account_irq_exit_time(struct task_struct *tsk)
Frederic Weisbeckerfa5058f2012-10-06 04:07:19 +020064{
Frederic Weisbecker6a616712012-12-16 20:00:34 +010065 vtime_account_irq_exit(tsk);
Frederic Weisbecker3e1df4f52012-10-06 05:23:22 +020066 irqtime_account_irq(tsk);
Frederic Weisbeckerfa5058f2012-10-06 04:07:19 +020067}
68
Frederic Weisbeckerdcbf8322012-10-05 23:07:19 +020069#endif /* _LINUX_KERNEL_VTIME_H */