| .. | .. |
|---|
| 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 |
|---|
| .. | .. |
|---|
| 86 | 87 | static inline void vtime_account_irq_exit(struct task_struct *tsk) |
|---|
| 87 | 88 | { |
|---|
| 88 | 89 | /* On hard|softirq exit we always account to hard|softirq cputime */ |
|---|
| 89 | | - vtime_account_system(tsk); |
|---|
| 90 | + vtime_account_kernel(tsk); |
|---|
| 90 | 91 | } |
|---|
| 91 | 92 | extern void vtime_flush(struct task_struct *tsk); |
|---|
| 92 | 93 | #else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ |
|---|