guest_enter() doesn't call context_tracking_enabled() before calling context_tracking_enabled_this_cpu(). Therefore the guest code doesn't benefit from the static key on the fast path. Just make sure that context_tracking_enabled_*cpu() functions check the static key by themselves to propagate the optimization.
Showing the changes to include/linux (2 of 2 files). Show all
Unified · Split
| @@ -33,12 +33,12 @@ static inline bool context_tracking_enabled(void) · 32 unmodified lines | ||
| 33 | 33 | |
| 34 | 34 | static inline bool context_tracking_enabled_cpu(int cpu) |
| 35 | 35 | { |
| 36 | − return per_cpu(context_tracking.active, cpu); | |
| 36 | + return context_tracking_enabled() && per_cpu(context_tracking.active, cpu); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | static inline bool context_tracking_enabled_this_cpu(void) |
| 40 | 40 | { |
| 41 | − return __this_cpu_read(context_tracking.active); | |
| 41 | + return context_tracking_enabled() && __this_cpu_read(context_tracking.active); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | static inline bool context_tracking_in_user(void) |
| @@ -33,12 +33,12 @@ static inline bool vtime_accounting_enabled(void) · 32 unmodified lines | ||
| 33 | 33 | |
| 34 | 34 | static inline bool vtime_accounting_enabled_cpu(int cpu) |
| 35 | 35 | { |
| 36 | − return (vtime_accounting_enabled() && context_tracking_enabled_cpu(cpu)); | |
| 36 | + return context_tracking_enabled_cpu(cpu); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | static inline bool vtime_accounting_enabled_this_cpu(void) |
| 40 | 40 | { |
| 41 | − return (vtime_accounting_enabled() && context_tracking_enabled_this_cpu()); | |
| 41 | + return context_tracking_enabled_this_cpu(); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | extern void vtime_task_switch_generic(struct task_struct *prev); |