context_tracking: Optimize guest APIs off case with static key
[cascardo/linux.git] / include / linux / context_tracking.h
index 38ab60b..8854ead 100644 (file)
@@ -95,8 +95,23 @@ static inline void context_tracking_init(void) { }
 
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
-extern void guest_enter(void);
-extern void guest_exit(void);
+static inline void guest_enter(void)
+{
+       if (static_key_false(&context_tracking_enabled) &&
+           vtime_accounting_enabled())
+               vtime_guest_enter(current);
+       else
+               current->flags |= PF_VCPU;
+}
+
+static inline void guest_exit(void)
+{
+       if (static_key_false(&context_tracking_enabled) &&
+           vtime_accounting_enabled())
+               vtime_guest_exit(current);
+       else
+               current->flags &= ~PF_VCPU;
+}
 #else
 static inline void guest_enter(void)
 {