]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/vtime.h
cputime: Generic on-demand virtual cputime accounting
[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
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);
fd25b4c2
FW
9extern void vtime_account_system_irqsafe(struct task_struct *tsk);
10extern void vtime_account_idle(struct task_struct *tsk);
bcebdf84 11extern void vtime_account_user(struct task_struct *tsk);
3e1df4f5 12extern void vtime_account(struct task_struct *tsk);
dcbf832e
FW
13#else
14static inline void vtime_task_switch(struct task_struct *prev) { }
11113334 15static inline void vtime_account_system(struct task_struct *tsk) { }
fd25b4c2 16static inline void vtime_account_system_irqsafe(struct task_struct *tsk) { }
abf917cd 17static inline void vtime_account_user(struct task_struct *tsk) { }
3e1df4f5 18static inline void vtime_account(struct task_struct *tsk) { }
abf917cd
FW
19#endif
20
21#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
22static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
23static inline void vtime_user_enter(struct task_struct *tsk)
24{
25 vtime_account_system(tsk);
26}
27static inline void vtime_user_exit(struct task_struct *tsk)
28{
29 vtime_account_user(tsk);
30}
31#else
32static inline void vtime_user_enter(struct task_struct *tsk) { }
33static inline void vtime_user_exit(struct task_struct *tsk) { }
dcbf832e
FW
34#endif
35
3e1df4f5
FW
36#ifdef CONFIG_IRQ_TIME_ACCOUNTING
37extern void irqtime_account_irq(struct task_struct *tsk);
dcbf832e 38#else
3e1df4f5 39static inline void irqtime_account_irq(struct task_struct *tsk) { }
dcbf832e
FW
40#endif
41
fa5058f3
FW
42static inline void vtime_account_irq_enter(struct task_struct *tsk)
43{
44 /*
45 * Hardirq can interrupt idle task anytime. So we need vtime_account()
46 * that performs the idle check in CONFIG_VIRT_CPU_ACCOUNTING.
47 * Softirq can also interrupt idle task directly if it calls
48 * local_bh_enable(). Such case probably don't exist but we never know.
49 * Ksoftirqd is not concerned because idle time is flushed on context
50 * switch. Softirqs in the end of hardirqs are also not a problem because
51 * the idle time is flushed on hardirq time already.
52 */
53 vtime_account(tsk);
3e1df4f5 54 irqtime_account_irq(tsk);
fa5058f3
FW
55}
56
57static inline void vtime_account_irq_exit(struct task_struct *tsk)
58{
fa5058f3 59 /* On hard|softirq exit we always account to hard|softirq cputime */
fd25b4c2 60 vtime_account_system(tsk);
3e1df4f5 61 irqtime_account_irq(tsk);
fa5058f3
FW
62}
63
dcbf832e 64#endif /* _LINUX_KERNEL_VTIME_H */