]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/vtime.h
Merge remote-tracking branches 'regulator/fix/axp20x', 'regulator/fix/cpcap' and...
[mirror_ubuntu-bionic-kernel.git] / include / linux / vtime.h
CommitLineData
dcbf832e
FW
1#ifndef _LINUX_KERNEL_VTIME_H
2#define _LINUX_KERNEL_VTIME_H
3
b0493406 4#include <linux/context_tracking_state.h>
a5725ac2
FW
5#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
6#include <asm/vtime.h>
7#endif
8
b0493406 9
dcbf832e
FW
10struct task_struct;
11
b0493406 12/*
55dbdcfa 13 * vtime_accounting_cpu_enabled() definitions/declarations
b0493406 14 */
8612f17a 15#if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE)
55dbdcfa 16static inline bool vtime_accounting_cpu_enabled(void) { return true; }
8612f17a 17#elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN)
e5925394
FW
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
55dbdcfa 29static inline bool vtime_accounting_cpu_enabled(void)
b0493406 30{
e5925394 31 if (vtime_accounting_enabled()) {
d0df09eb 32 if (context_tracking_cpu_is_enabled())
b0493406
FW
33 return true;
34 }
35
36 return false;
37}
8612f17a 38#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
55dbdcfa 39static inline bool vtime_accounting_cpu_enabled(void) { return false; }
8612f17a 40#endif
b0493406
FW
41
42
43/*
44 * Common vtime APIs
45 */
dcbf832e 46#ifdef CONFIG_VIRT_CPU_ACCOUNTING
b0493406
FW
47
48#ifdef __ARCH_HAS_VTIME_TASK_SWITCH
dcbf832e 49extern void vtime_task_switch(struct task_struct *prev);
b0493406
FW
50#else
51extern void vtime_common_task_switch(struct task_struct *prev);
52static inline void vtime_task_switch(struct task_struct *prev)
53{
55dbdcfa 54 if (vtime_accounting_cpu_enabled())
b0493406
FW
55 vtime_common_task_switch(prev);
56}
57#endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
58
dcbf832e 59extern void vtime_account_system(struct task_struct *tsk);
fd25b4c2 60extern void vtime_account_idle(struct task_struct *tsk);
3f4724ea 61
3f4724ea 62#else /* !CONFIG_VIRT_CPU_ACCOUNTING */
6a61671b 63
dcbf832e 64static inline void vtime_task_switch(struct task_struct *prev) { }
11113334 65static inline void vtime_account_system(struct task_struct *tsk) { }
b0493406 66#endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
abf917cd
FW
67
68#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
6a61671b 69extern void arch_vtime_task_switch(struct task_struct *tsk);
6a61671b 70extern void vtime_user_enter(struct task_struct *tsk);
1c3eda01 71extern void vtime_user_exit(struct task_struct *tsk);
6a61671b
FW
72extern void vtime_guest_enter(struct task_struct *tsk);
73extern void vtime_guest_exit(struct task_struct *tsk);
45eacc69 74extern void vtime_init_idle(struct task_struct *tsk, int cpu);
b0493406 75#else /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */
abf917cd
FW
76static inline void vtime_user_enter(struct task_struct *tsk) { }
77static inline void vtime_user_exit(struct task_struct *tsk) { }
6a61671b
FW
78static inline void vtime_guest_enter(struct task_struct *tsk) { }
79static inline void vtime_guest_exit(struct task_struct *tsk) { }
45eacc69 80static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
dcbf832e
FW
81#endif
82
8612f17a
FW
83#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
84extern void vtime_account_irq_enter(struct task_struct *tsk);
85static inline void vtime_account_irq_exit(struct task_struct *tsk)
86{
87 /* On hard|softirq exit we always account to hard|softirq cputime */
88 vtime_account_system(tsk);
89}
c8d7dabf 90extern void vtime_flush(struct task_struct *tsk);
8612f17a
FW
91#else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
92static inline void vtime_account_irq_enter(struct task_struct *tsk) { }
93static inline void vtime_account_irq_exit(struct task_struct *tsk) { }
c8d7dabf 94static inline void vtime_flush(struct task_struct *tsk) { }
8612f17a
FW
95#endif
96
97
3e1df4f5
FW
98#ifdef CONFIG_IRQ_TIME_ACCOUNTING
99extern void irqtime_account_irq(struct task_struct *tsk);
dcbf832e 100#else
3e1df4f5 101static inline void irqtime_account_irq(struct task_struct *tsk) { }
dcbf832e
FW
102#endif
103
6a61671b 104static inline void account_irq_enter_time(struct task_struct *tsk)
fa5058f3 105{
6a61671b 106 vtime_account_irq_enter(tsk);
3e1df4f5 107 irqtime_account_irq(tsk);
fa5058f3
FW
108}
109
6a61671b 110static inline void account_irq_exit_time(struct task_struct *tsk)
fa5058f3 111{
6a61671b 112 vtime_account_irq_exit(tsk);
3e1df4f5 113 irqtime_account_irq(tsk);
fa5058f3
FW
114}
115
dcbf832e 116#endif /* _LINUX_KERNEL_VTIME_H */