]>
git.proxmox.com Git - mirror_ubuntu-focal-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 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
16 static inline bool vtime_accounting_cpu_enabled(void) { return true; }
18 #ifdef __ARCH_HAS_VTIME_ACCOUNT
19 extern void vtime_account_irq_enter(struct task_struct
*tsk
);
21 extern void vtime_common_account_irq_enter(struct task_struct
*tsk
);
22 static inline void vtime_account_irq_enter(struct task_struct
*tsk
)
24 if (vtime_accounting_cpu_enabled())
25 vtime_common_account_irq_enter(tsk
);
27 #endif /* __ARCH_HAS_VTIME_ACCOUNT */
29 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
31 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
33 * Checks if vtime is enabled on some CPU. Cputime readers want to be careful
34 * in that case and compute the tickless cputime.
35 * For now vtime state is tied to context tracking. We might want to decouple
36 * those later if necessary.
38 static inline bool vtime_accounting_enabled(void)
40 return context_tracking_is_enabled();
43 static inline bool vtime_accounting_cpu_enabled(void)
45 if (vtime_accounting_enabled()) {
46 if (context_tracking_cpu_is_enabled())
52 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */
54 #ifndef CONFIG_VIRT_CPU_ACCOUNTING
55 static inline bool vtime_accounting_cpu_enabled(void) { return false; }
56 #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
62 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
64 #ifdef __ARCH_HAS_VTIME_TASK_SWITCH
65 extern void vtime_task_switch(struct task_struct
*prev
);
67 extern void vtime_common_task_switch(struct task_struct
*prev
);
68 static inline void vtime_task_switch(struct task_struct
*prev
)
70 if (vtime_accounting_cpu_enabled())
71 vtime_common_task_switch(prev
);
73 #endif /* __ARCH_HAS_VTIME_TASK_SWITCH */
75 extern void vtime_account_system(struct task_struct
*tsk
);
76 extern void vtime_account_idle(struct task_struct
*tsk
);
77 extern void vtime_account_user(struct task_struct
*tsk
);
79 #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
81 static inline void vtime_task_switch(struct task_struct
*prev
) { }
82 static inline void vtime_account_system(struct task_struct
*tsk
) { }
83 static inline void vtime_account_user(struct task_struct
*tsk
) { }
84 static inline void vtime_account_irq_enter(struct task_struct
*tsk
) { }
85 #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */
87 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
88 extern void arch_vtime_task_switch(struct task_struct
*tsk
);
89 static inline void vtime_account_irq_enter(struct task_struct
*tsk
) { }
90 static inline void vtime_account_irq_exit(struct task_struct
*tsk
) { }
92 extern void vtime_user_enter(struct task_struct
*tsk
);
94 static inline void vtime_user_exit(struct task_struct
*tsk
)
96 vtime_account_user(tsk
);
98 extern void vtime_guest_enter(struct task_struct
*tsk
);
99 extern void vtime_guest_exit(struct task_struct
*tsk
);
100 extern void vtime_init_idle(struct task_struct
*tsk
, int cpu
);
101 #else /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */
102 static inline void vtime_account_irq_exit(struct task_struct
*tsk
)
104 /* On hard|softirq exit we always account to hard|softirq cputime */
105 vtime_account_system(tsk
);
107 static inline void vtime_user_enter(struct task_struct
*tsk
) { }
108 static inline void vtime_user_exit(struct task_struct
*tsk
) { }
109 static inline void vtime_guest_enter(struct task_struct
*tsk
) { }
110 static inline void vtime_guest_exit(struct task_struct
*tsk
) { }
111 static inline void vtime_init_idle(struct task_struct
*tsk
, int cpu
) { }
114 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
115 extern void irqtime_account_irq(struct task_struct
*tsk
);
117 static inline void irqtime_account_irq(struct task_struct
*tsk
) { }
120 static inline void account_irq_enter_time(struct task_struct
*tsk
)
122 vtime_account_irq_enter(tsk
);
123 irqtime_account_irq(tsk
);
126 static inline void account_irq_exit_time(struct task_struct
*tsk
)
128 vtime_account_irq_exit(tsk
);
129 irqtime_account_irq(tsk
);
132 #endif /* _LINUX_KERNEL_VTIME_H */