Blame view
include/linux/vtime.h
3.57 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
dcbf832e5 vtime: Gather vti... |
2 3 |
#ifndef _LINUX_KERNEL_VTIME_H #define _LINUX_KERNEL_VTIME_H |
b04934061 vtime: Optimize f... |
4 |
#include <linux/context_tracking_state.h> |
a5725ac23 vtime: Describe o... |
5 6 7 |
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE #include <asm/vtime.h> #endif |
b04934061 vtime: Optimize f... |
8 |
|
dcbf832e5 vtime: Gather vti... |
9 |
struct task_struct; |
b04934061 vtime: Optimize f... |
10 |
/* |
55dbdcfa0 sched/cputime: Re... |
11 |
* vtime_accounting_cpu_enabled() definitions/declarations |
b04934061 vtime: Optimize f... |
12 |
*/ |
8612f17ab sched/cputime: Re... |
13 |
#if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) |
55dbdcfa0 sched/cputime: Re... |
14 |
static inline bool vtime_accounting_cpu_enabled(void) { return true; } |
8612f17ab sched/cputime: Re... |
15 |
#elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN) |
e59253946 sched/cputime: In... |
16 17 18 19 20 21 22 23 24 25 |
/* * Checks if vtime is enabled on some CPU. Cputime readers want to be careful * in that case and compute the tickless cputime. * For now vtime state is tied to context tracking. We might want to decouple * those later if necessary. */ static inline bool vtime_accounting_enabled(void) { return context_tracking_is_enabled(); } |
55dbdcfa0 sched/cputime: Re... |
26 |
static inline bool vtime_accounting_cpu_enabled(void) |
b04934061 vtime: Optimize f... |
27 |
{ |
e59253946 sched/cputime: In... |
28 |
if (vtime_accounting_enabled()) { |
d0df09ebf context_tracking:... |
29 |
if (context_tracking_cpu_is_enabled()) |
b04934061 vtime: Optimize f... |
30 31 32 33 34 |
return true; } return false; } |
8612f17ab sched/cputime: Re... |
35 |
#else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
55dbdcfa0 sched/cputime: Re... |
36 |
static inline bool vtime_accounting_cpu_enabled(void) { return false; } |
8612f17ab sched/cputime: Re... |
37 |
#endif |
b04934061 vtime: Optimize f... |
38 39 40 41 42 |
/* * Common vtime APIs */ |
dcbf832e5 vtime: Gather vti... |
43 |
#ifdef CONFIG_VIRT_CPU_ACCOUNTING |
b04934061 vtime: Optimize f... |
44 45 |
#ifdef __ARCH_HAS_VTIME_TASK_SWITCH |
dcbf832e5 vtime: Gather vti... |
46 |
extern void vtime_task_switch(struct task_struct *prev); |
b04934061 vtime: Optimize f... |
47 48 49 50 |
#else extern void vtime_common_task_switch(struct task_struct *prev); static inline void vtime_task_switch(struct task_struct *prev) { |
55dbdcfa0 sched/cputime: Re... |
51 |
if (vtime_accounting_cpu_enabled()) |
b04934061 vtime: Optimize f... |
52 53 54 |
vtime_common_task_switch(prev); } #endif /* __ARCH_HAS_VTIME_TASK_SWITCH */ |
dcbf832e5 vtime: Gather vti... |
55 |
extern void vtime_account_system(struct task_struct *tsk); |
fd25b4c2f vtime: Remove the... |
56 |
extern void vtime_account_idle(struct task_struct *tsk); |
3f4724ea8 cputime: Allow dy... |
57 |
|
3f4724ea8 cputime: Allow dy... |
58 |
#else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
6a61671bb cputime: Safely r... |
59 |
|
dcbf832e5 vtime: Gather vti... |
60 |
static inline void vtime_task_switch(struct task_struct *prev) { } |
11113334d vtime: Make vtime... |
61 |
static inline void vtime_account_system(struct task_struct *tsk) { } |
b04934061 vtime: Optimize f... |
62 |
#endif /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
abf917cd9 cputime: Generic ... |
63 64 |
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN |
6a61671bb cputime: Safely r... |
65 |
extern void arch_vtime_task_switch(struct task_struct *tsk); |
6a61671bb cputime: Safely r... |
66 |
extern void vtime_user_enter(struct task_struct *tsk); |
1c3eda01a vtime, sched/cput... |
67 |
extern void vtime_user_exit(struct task_struct *tsk); |
6a61671bb cputime: Safely r... |
68 69 |
extern void vtime_guest_enter(struct task_struct *tsk); extern void vtime_guest_exit(struct task_struct *tsk); |
45eacc692 vtime: Use consis... |
70 |
extern void vtime_init_idle(struct task_struct *tsk, int cpu); |
b04934061 vtime: Optimize f... |
71 |
#else /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */ |
abf917cd9 cputime: Generic ... |
72 73 |
static inline void vtime_user_enter(struct task_struct *tsk) { } static inline void vtime_user_exit(struct task_struct *tsk) { } |
6a61671bb cputime: Safely r... |
74 75 |
static inline void vtime_guest_enter(struct task_struct *tsk) { } static inline void vtime_guest_exit(struct task_struct *tsk) { } |
45eacc692 vtime: Use consis... |
76 |
static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { } |
dcbf832e5 vtime: Gather vti... |
77 |
#endif |
8612f17ab sched/cputime: Re... |
78 79 80 81 82 83 84 |
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE extern void vtime_account_irq_enter(struct task_struct *tsk); static inline void vtime_account_irq_exit(struct task_struct *tsk) { /* On hard|softirq exit we always account to hard|softirq cputime */ vtime_account_system(tsk); } |
c8d7dabf8 sched/cputime: Re... |
85 |
extern void vtime_flush(struct task_struct *tsk); |
8612f17ab sched/cputime: Re... |
86 87 88 |
#else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ static inline void vtime_account_irq_enter(struct task_struct *tsk) { } static inline void vtime_account_irq_exit(struct task_struct *tsk) { } |
c8d7dabf8 sched/cputime: Re... |
89 |
static inline void vtime_flush(struct task_struct *tsk) { } |
8612f17ab sched/cputime: Re... |
90 |
#endif |
3e1df4f50 cputime: Separate... |
91 92 |
#ifdef CONFIG_IRQ_TIME_ACCOUNTING extern void irqtime_account_irq(struct task_struct *tsk); |
dcbf832e5 vtime: Gather vti... |
93 |
#else |
3e1df4f50 cputime: Separate... |
94 |
static inline void irqtime_account_irq(struct task_struct *tsk) { } |
dcbf832e5 vtime: Gather vti... |
95 |
#endif |
6a61671bb cputime: Safely r... |
96 |
static inline void account_irq_enter_time(struct task_struct *tsk) |
fa5058f3b cputime: Speciali... |
97 |
{ |
6a61671bb cputime: Safely r... |
98 |
vtime_account_irq_enter(tsk); |
3e1df4f50 cputime: Separate... |
99 |
irqtime_account_irq(tsk); |
fa5058f3b cputime: Speciali... |
100 |
} |
6a61671bb cputime: Safely r... |
101 |
static inline void account_irq_exit_time(struct task_struct *tsk) |
fa5058f3b cputime: Speciali... |
102 |
{ |
6a61671bb cputime: Safely r... |
103 |
vtime_account_irq_exit(tsk); |
3e1df4f50 cputime: Separate... |
104 |
irqtime_account_irq(tsk); |
fa5058f3b cputime: Speciali... |
105 |
} |
dcbf832e5 vtime: Gather vti... |
106 |
#endif /* _LINUX_KERNEL_VTIME_H */ |