]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/vtime.h
1 #ifndef _LINUX_KERNEL_VTIME_H
2 #define _LINUX_KERNEL_VTIME_H
4 #include <linux/context_tracking_state.h>
5 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
13 * vtime_accounting_cpu_enabled() definitions/declarations
15 #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE)
16 static inline bool vtime_accounting_cpu_enabled(void) { return true; }
17 #elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN)
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.
24 static inline bool vtime_accounting_enabled(void)
26 return context_tracking_is_enabled();
29 static inline bool vtime_accounting_cpu_enabled(void)
31 if (vtime_accounting_enabled()) {
32 if (context_tracking_cpu_is_enabled())
38 #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
39 static inline bool vtime_accounting_cpu_enabled(void) { return false; }
46 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
48 #ifdef __ARCH_HAS_VTIME_TASK_SWITCH
49 extern void vtime_task_switch(struct task_struct
*prev
);
51 extern void vtime_common_task_switch(struct task_struct
*prev
);
52 static inline void vtime_task_switch(struct task_struct
*prev
)
54 if (vtime_accounting_cpu_enabled())
55 vtime_common_task_switch(prev
);
57 #endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
59 extern void vtime_account_system(struct task_struct
*tsk
);
60 extern void vtime_account_idle(struct task_struct
*tsk
);
62 #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
64 static inline void vtime_task_switch(struct task_struct
*prev
) { }
65 static inline void vtime_account_system(struct task_struct
*tsk
) { }
66 #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
68 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
69 extern void arch_vtime_task_switch(struct task_struct
*tsk
);
70 extern void vtime_user_enter(struct task_struct
*tsk
);
71 extern void vtime_user_exit(struct task_struct
*tsk
);
72 extern void vtime_guest_enter(struct task_struct
*tsk
);
73 extern void vtime_guest_exit(struct task_struct
*tsk
);
74 extern void vtime_init_idle(struct task_struct
*tsk
, int cpu
);
75 #else /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */
76 static inline void vtime_user_enter(struct task_struct
*tsk
) { }
77 static inline void vtime_user_exit(struct task_struct
*tsk
) { }
78 static inline void vtime_guest_enter(struct task_struct
*tsk
) { }
79 static inline void vtime_guest_exit(struct task_struct
*tsk
) { }
80 static inline void vtime_init_idle(struct task_struct
*tsk
, int cpu
) { }
83 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
84 extern void vtime_account_irq_enter(struct task_struct
*tsk
);
85 static inline void vtime_account_irq_exit(struct task_struct
*tsk
)
87 /* On hard|softirq exit we always account to hard|softirq cputime */
88 vtime_account_system(tsk
);
90 extern void vtime_flush(struct task_struct
*tsk
);
91 #else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
92 static inline void vtime_account_irq_enter(struct task_struct
*tsk
) { }
93 static inline void vtime_account_irq_exit(struct task_struct
*tsk
) { }
94 static inline void vtime_flush(struct task_struct
*tsk
) { }
98 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
99 extern void irqtime_account_irq(struct task_struct
*tsk
);
101 static inline void irqtime_account_irq(struct task_struct
*tsk
) { }
104 static inline void account_irq_enter_time(struct task_struct
*tsk
)
106 vtime_account_irq_enter(tsk
);
107 irqtime_account_irq(tsk
);
110 static inline void account_irq_exit_time(struct task_struct
*tsk
)
112 vtime_account_irq_exit(tsk
);
113 irqtime_account_irq(tsk
);
116 #endif /* _LINUX_KERNEL_VTIME_H */