.. | .. |
---|
11 | 11 | struct task_struct; |
---|
12 | 12 | |
---|
13 | 13 | /* |
---|
14 | | - * vtime_accounting_cpu_enabled() definitions/declarations |
---|
| 14 | + * vtime_accounting_enabled_this_cpu() definitions/declarations |
---|
15 | 15 | */ |
---|
16 | 16 | #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) |
---|
17 | | -static inline bool vtime_accounting_cpu_enabled(void) { return true; } |
---|
| 17 | + |
---|
| 18 | +static inline bool vtime_accounting_enabled_this_cpu(void) { return true; } |
---|
| 19 | +extern void vtime_task_switch(struct task_struct *prev); |
---|
| 20 | + |
---|
18 | 21 | #elif defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN) |
---|
| 22 | + |
---|
19 | 23 | /* |
---|
20 | 24 | * Checks if vtime is enabled on some CPU. Cputime readers want to be careful |
---|
21 | 25 | * in that case and compute the tickless cputime. |
---|
.. | .. |
---|
24 | 28 | */ |
---|
25 | 29 | static inline bool vtime_accounting_enabled(void) |
---|
26 | 30 | { |
---|
27 | | - return context_tracking_is_enabled(); |
---|
| 31 | + return context_tracking_enabled(); |
---|
28 | 32 | } |
---|
29 | 33 | |
---|
30 | | -static inline bool vtime_accounting_cpu_enabled(void) |
---|
| 34 | +static inline bool vtime_accounting_enabled_cpu(int cpu) |
---|
31 | 35 | { |
---|
32 | | - if (vtime_accounting_enabled()) { |
---|
33 | | - if (context_tracking_cpu_is_enabled()) |
---|
34 | | - return true; |
---|
35 | | - } |
---|
36 | | - |
---|
37 | | - return false; |
---|
| 36 | + return context_tracking_enabled_cpu(cpu); |
---|
38 | 37 | } |
---|
39 | | -#else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
---|
40 | | -static inline bool vtime_accounting_cpu_enabled(void) { return false; } |
---|
41 | | -#endif |
---|
42 | 38 | |
---|
| 39 | +static inline bool vtime_accounting_enabled_this_cpu(void) |
---|
| 40 | +{ |
---|
| 41 | + return context_tracking_enabled_this_cpu(); |
---|
| 42 | +} |
---|
| 43 | + |
---|
| 44 | +extern void vtime_task_switch_generic(struct task_struct *prev); |
---|
| 45 | + |
---|
| 46 | +static inline void vtime_task_switch(struct task_struct *prev) |
---|
| 47 | +{ |
---|
| 48 | + if (vtime_accounting_enabled_this_cpu()) |
---|
| 49 | + vtime_task_switch_generic(prev); |
---|
| 50 | +} |
---|
| 51 | + |
---|
| 52 | +#else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
---|
| 53 | + |
---|
| 54 | +static inline bool vtime_accounting_enabled_cpu(int cpu) {return false; } |
---|
| 55 | +static inline bool vtime_accounting_enabled_this_cpu(void) { return false; } |
---|
| 56 | +static inline void vtime_task_switch(struct task_struct *prev) { } |
---|
| 57 | + |
---|
| 58 | +#endif |
---|
43 | 59 | |
---|
44 | 60 | /* |
---|
45 | 61 | * Common vtime APIs |
---|
46 | 62 | */ |
---|
47 | 63 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
---|
48 | | - |
---|
49 | | -#ifdef __ARCH_HAS_VTIME_TASK_SWITCH |
---|
50 | | -extern void vtime_task_switch(struct task_struct *prev); |
---|
51 | | -#else |
---|
52 | | -extern void vtime_common_task_switch(struct task_struct *prev); |
---|
53 | | -static inline void vtime_task_switch(struct task_struct *prev) |
---|
54 | | -{ |
---|
55 | | - if (vtime_accounting_cpu_enabled()) |
---|
56 | | - vtime_common_task_switch(prev); |
---|
57 | | -} |
---|
58 | | -#endif /* __ARCH_HAS_VTIME_TASK_SWITCH */ |
---|
59 | | - |
---|
60 | | -extern void vtime_account_system(struct task_struct *tsk); |
---|
| 64 | +extern void vtime_account_kernel(struct task_struct *tsk); |
---|
61 | 65 | extern void vtime_account_idle(struct task_struct *tsk); |
---|
62 | | - |
---|
63 | 66 | #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
---|
64 | | - |
---|
65 | | -static inline void vtime_task_switch(struct task_struct *prev) { } |
---|
66 | | -static inline void vtime_account_system(struct task_struct *tsk) { } |
---|
| 67 | +static inline void vtime_account_kernel(struct task_struct *tsk) { } |
---|
67 | 68 | #endif /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
---|
68 | 69 | |
---|
69 | 70 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN |
---|
.. | .. |
---|
82 | 83 | #endif |
---|
83 | 84 | |
---|
84 | 85 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE |
---|
85 | | -extern void vtime_account_irq_enter(struct task_struct *tsk); |
---|
86 | | -static inline void vtime_account_irq_exit(struct task_struct *tsk) |
---|
87 | | -{ |
---|
88 | | - /* On hard|softirq exit we always account to hard|softirq cputime */ |
---|
89 | | - vtime_account_system(tsk); |
---|
90 | | -} |
---|
| 86 | +extern void vtime_account_irq(struct task_struct *tsk, unsigned int offset); |
---|
| 87 | +extern void vtime_account_softirq(struct task_struct *tsk); |
---|
| 88 | +extern void vtime_account_hardirq(struct task_struct *tsk); |
---|
91 | 89 | extern void vtime_flush(struct task_struct *tsk); |
---|
92 | 90 | #else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ |
---|
93 | | -static inline void vtime_account_irq_enter(struct task_struct *tsk) { } |
---|
94 | | -static inline void vtime_account_irq_exit(struct task_struct *tsk) { } |
---|
| 91 | +static inline void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { } |
---|
| 92 | +static inline void vtime_account_softirq(struct task_struct *tsk) { } |
---|
| 93 | +static inline void vtime_account_hardirq(struct task_struct *tsk) { } |
---|
95 | 94 | static inline void vtime_flush(struct task_struct *tsk) { } |
---|
96 | 95 | #endif |
---|
97 | 96 | |
---|
98 | 97 | |
---|
99 | 98 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING |
---|
100 | | -extern void irqtime_account_irq(struct task_struct *tsk); |
---|
| 99 | +extern void irqtime_account_irq(struct task_struct *tsk, unsigned int offset); |
---|
101 | 100 | #else |
---|
102 | | -static inline void irqtime_account_irq(struct task_struct *tsk) { } |
---|
| 101 | +static inline void irqtime_account_irq(struct task_struct *tsk, unsigned int offset) { } |
---|
103 | 102 | #endif |
---|
104 | 103 | |
---|
105 | | -static inline void account_irq_enter_time(struct task_struct *tsk) |
---|
| 104 | +static inline void account_softirq_enter(struct task_struct *tsk) |
---|
106 | 105 | { |
---|
107 | | - vtime_account_irq_enter(tsk); |
---|
108 | | - irqtime_account_irq(tsk); |
---|
| 106 | + vtime_account_irq(tsk, SOFTIRQ_OFFSET); |
---|
| 107 | + irqtime_account_irq(tsk, SOFTIRQ_OFFSET); |
---|
109 | 108 | } |
---|
110 | 109 | |
---|
111 | | -static inline void account_irq_exit_time(struct task_struct *tsk) |
---|
| 110 | +static inline void account_softirq_exit(struct task_struct *tsk) |
---|
112 | 111 | { |
---|
113 | | - vtime_account_irq_exit(tsk); |
---|
114 | | - irqtime_account_irq(tsk); |
---|
| 112 | + vtime_account_softirq(tsk); |
---|
| 113 | + irqtime_account_irq(tsk, 0); |
---|
| 114 | +} |
---|
| 115 | + |
---|
| 116 | +static inline void account_hardirq_enter(struct task_struct *tsk) |
---|
| 117 | +{ |
---|
| 118 | + vtime_account_irq(tsk, HARDIRQ_OFFSET); |
---|
| 119 | + irqtime_account_irq(tsk, HARDIRQ_OFFSET); |
---|
| 120 | +} |
---|
| 121 | + |
---|
| 122 | +static inline void account_hardirq_exit(struct task_struct *tsk) |
---|
| 123 | +{ |
---|
| 124 | + vtime_account_hardirq(tsk); |
---|
| 125 | + irqtime_account_irq(tsk, 0); |
---|
115 | 126 | } |
---|
116 | 127 | |
---|
117 | 128 | #endif /* _LINUX_KERNEL_VTIME_H */ |
---|