Merge remote-tracking branches 'asoc/topic/sta529', 'asoc/topic/sti', 'asoc/topic...
[linux-2.6-block.git] / include / linux / vtime.h
... / ...
CommitLineData
1#ifndef _LINUX_KERNEL_VTIME_H
2#define _LINUX_KERNEL_VTIME_H
3
4#include <linux/context_tracking_state.h>
5#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
6#include <asm/vtime.h>
7#endif
8
9
10struct task_struct;
11
12/*
13 * vtime_accounting_cpu_enabled() definitions/declarations
14 */
15#if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE)
16static inline bool vtime_accounting_cpu_enabled(void) { return true; }
17#elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN)
18/*
19 * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
20 * in that case and compute the tickless cputime.
21 * For now vtime state is tied to context tracking. We might want to decouple
22 * those later if necessary.
23 */
24static inline bool vtime_accounting_enabled(void)
25{
26 return context_tracking_is_enabled();
27}
28
29static inline bool vtime_accounting_cpu_enabled(void)
30{
31 if (vtime_accounting_enabled()) {
32 if (context_tracking_cpu_is_enabled())
33 return true;
34 }
35
36 return false;
37}
38#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
39static inline bool vtime_accounting_cpu_enabled(void) { return false; }
40#endif
41
42
43/*
44 * Common vtime APIs
45 */
46#ifdef CONFIG_VIRT_CPU_ACCOUNTING
47
48#ifdef __ARCH_HAS_VTIME_TASK_SWITCH
49extern void vtime_task_switch(struct task_struct *prev);
50#else
51extern void vtime_common_task_switch(struct task_struct *prev);
52static inline void vtime_task_switch(struct task_struct *prev)
53{
54 if (vtime_accounting_cpu_enabled())
55 vtime_common_task_switch(prev);
56}
57#endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
58
59extern void vtime_account_system(struct task_struct *tsk);
60extern void vtime_account_idle(struct task_struct *tsk);
61
62#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
63
64static inline void vtime_task_switch(struct task_struct *prev) { }
65static inline void vtime_account_system(struct task_struct *tsk) { }
66#endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
67
68#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
69extern void arch_vtime_task_switch(struct task_struct *tsk);
70extern void vtime_account_user(struct task_struct *tsk);
71extern void vtime_user_enter(struct task_struct *tsk);
72
73static inline void vtime_user_exit(struct task_struct *tsk)
74{
75 vtime_account_user(tsk);
76}
77
78extern void vtime_guest_enter(struct task_struct *tsk);
79extern void vtime_guest_exit(struct task_struct *tsk);
80extern void vtime_init_idle(struct task_struct *tsk, int cpu);
81#else /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */
82static inline void vtime_account_user(struct task_struct *tsk) { }
83static inline void vtime_user_enter(struct task_struct *tsk) { }
84static inline void vtime_user_exit(struct task_struct *tsk) { }
85static inline void vtime_guest_enter(struct task_struct *tsk) { }
86static inline void vtime_guest_exit(struct task_struct *tsk) { }
87static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
88#endif
89
90#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
91extern void vtime_account_irq_enter(struct task_struct *tsk);
92static inline void vtime_account_irq_exit(struct task_struct *tsk)
93{
94 /* On hard|softirq exit we always account to hard|softirq cputime */
95 vtime_account_system(tsk);
96}
97extern void vtime_flush(struct task_struct *tsk);
98#else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
99static inline void vtime_account_irq_enter(struct task_struct *tsk) { }
100static inline void vtime_account_irq_exit(struct task_struct *tsk) { }
101static inline void vtime_flush(struct task_struct *tsk) { }
102#endif
103
104
105#ifdef CONFIG_IRQ_TIME_ACCOUNTING
106extern void irqtime_account_irq(struct task_struct *tsk);
107#else
108static inline void irqtime_account_irq(struct task_struct *tsk) { }
109#endif
110
111static inline void account_irq_enter_time(struct task_struct *tsk)
112{
113 vtime_account_irq_enter(tsk);
114 irqtime_account_irq(tsk);
115}
116
117static inline void account_irq_exit_time(struct task_struct *tsk)
118{
119 vtime_account_irq_exit(tsk);
120 irqtime_account_irq(tsk);
121}
122
123#endif /* _LINUX_KERNEL_VTIME_H */