Frederic Weisbecker | dcbf832 | 2012-10-05 23:07:19 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_KERNEL_VTIME_H |
| 2 | #define _LINUX_KERNEL_VTIME_H |
| 3 | |
| 4 | struct task_struct; |
| 5 | |
| 6 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
| 7 | extern void vtime_task_switch(struct task_struct *prev); |
| 8 | extern void vtime_account_system(struct task_struct *tsk); |
Frederic Weisbecker | fd25b4c | 2012-11-13 18:21:22 +0100 | [diff] [blame] | 9 | extern void vtime_account_idle(struct task_struct *tsk); |
Frederic Weisbecker | bcebdf8 | 2012-11-13 23:51:06 +0100 | [diff] [blame] | 10 | extern void vtime_account_user(struct task_struct *tsk); |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 11 | extern void vtime_account_irq_enter(struct task_struct *tsk); |
Frederic Weisbecker | 3f4724e | 2012-07-16 18:00:34 +0200 | [diff] [blame] | 12 | |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 13 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE |
Frederic Weisbecker | 3f4724e | 2012-07-16 18:00:34 +0200 | [diff] [blame] | 14 | static inline bool vtime_accounting_enabled(void) { return true; } |
| 15 | #endif |
| 16 | |
| 17 | #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 18 | |
Frederic Weisbecker | dcbf832 | 2012-10-05 23:07:19 +0200 | [diff] [blame] | 19 | static inline void vtime_task_switch(struct task_struct *prev) { } |
Frederic Weisbecker | 1111333 | 2012-10-24 18:05:51 +0200 | [diff] [blame] | 20 | static inline void vtime_account_system(struct task_struct *tsk) { } |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 21 | static inline void vtime_account_user(struct task_struct *tsk) { } |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 22 | static inline void vtime_account_irq_enter(struct task_struct *tsk) { } |
Frederic Weisbecker | 3f4724e | 2012-07-16 18:00:34 +0200 | [diff] [blame] | 23 | static inline bool vtime_accounting_enabled(void) { return false; } |
Frederic Weisbecker | dcbf832 | 2012-10-05 23:07:19 +0200 | [diff] [blame] | 24 | #endif |
| 25 | |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 26 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 27 | extern void arch_vtime_task_switch(struct task_struct *tsk); |
| 28 | extern void vtime_account_irq_exit(struct task_struct *tsk); |
| 29 | extern bool vtime_accounting_enabled(void); |
| 30 | extern void vtime_user_enter(struct task_struct *tsk); |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 31 | static inline void vtime_user_exit(struct task_struct *tsk) |
| 32 | { |
| 33 | vtime_account_user(tsk); |
| 34 | } |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 35 | extern void vtime_guest_enter(struct task_struct *tsk); |
| 36 | extern void vtime_guest_exit(struct task_struct *tsk); |
Frederic Weisbecker | 45eacc6 | 2013-05-15 22:16:32 +0200 | [diff] [blame] | 37 | extern void vtime_init_idle(struct task_struct *tsk, int cpu); |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 38 | #else |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 39 | static 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 Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 44 | static inline void vtime_user_enter(struct task_struct *tsk) { } |
| 45 | static inline void vtime_user_exit(struct task_struct *tsk) { } |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 46 | static inline void vtime_guest_enter(struct task_struct *tsk) { } |
| 47 | static inline void vtime_guest_exit(struct task_struct *tsk) { } |
Frederic Weisbecker | 45eacc6 | 2013-05-15 22:16:32 +0200 | [diff] [blame] | 48 | static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { } |
Frederic Weisbecker | abf917c | 2012-07-25 07:56:04 +0200 | [diff] [blame] | 49 | #endif |
| 50 | |
Frederic Weisbecker | 3e1df4f5 | 2012-10-06 05:23:22 +0200 | [diff] [blame] | 51 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING |
| 52 | extern void irqtime_account_irq(struct task_struct *tsk); |
Frederic Weisbecker | dcbf832 | 2012-10-05 23:07:19 +0200 | [diff] [blame] | 53 | #else |
Frederic Weisbecker | 3e1df4f5 | 2012-10-06 05:23:22 +0200 | [diff] [blame] | 54 | static inline void irqtime_account_irq(struct task_struct *tsk) { } |
Frederic Weisbecker | dcbf832 | 2012-10-05 23:07:19 +0200 | [diff] [blame] | 55 | #endif |
| 56 | |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 57 | static inline void account_irq_enter_time(struct task_struct *tsk) |
Frederic Weisbecker | fa5058f | 2012-10-06 04:07:19 +0200 | [diff] [blame] | 58 | { |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 59 | vtime_account_irq_enter(tsk); |
Frederic Weisbecker | 3e1df4f5 | 2012-10-06 05:23:22 +0200 | [diff] [blame] | 60 | irqtime_account_irq(tsk); |
Frederic Weisbecker | fa5058f | 2012-10-06 04:07:19 +0200 | [diff] [blame] | 61 | } |
| 62 | |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 63 | static inline void account_irq_exit_time(struct task_struct *tsk) |
Frederic Weisbecker | fa5058f | 2012-10-06 04:07:19 +0200 | [diff] [blame] | 64 | { |
Frederic Weisbecker | 6a61671 | 2012-12-16 20:00:34 +0100 | [diff] [blame] | 65 | vtime_account_irq_exit(tsk); |
Frederic Weisbecker | 3e1df4f5 | 2012-10-06 05:23:22 +0200 | [diff] [blame] | 66 | irqtime_account_irq(tsk); |
Frederic Weisbecker | fa5058f | 2012-10-06 04:07:19 +0200 | [diff] [blame] | 67 | } |
| 68 | |
Frederic Weisbecker | dcbf832 | 2012-10-05 23:07:19 +0200 | [diff] [blame] | 69 | #endif /* _LINUX_KERNEL_VTIME_H */ |