[RFC PATCH 5/7] KVM: Move vtime accounting of guest exit to separate helper

From: Sean Christopherson
Date: Tue Apr 13 2021 - 14:30:08 EST


Provide a standalone helper for guest exit vtime accounting so that x86
can defer tick-based accounting until the appropriate time, while still
updating context tracking immediately after VM-Exit.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
include/linux/kvm_host.h | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 444d5f0225cb..20604bfae5a8 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -358,16 +358,21 @@ static __always_inline void guest_enter_irqoff(void)
}
}

-static __always_inline void guest_exit_irqoff(void)
+static __always_inline void kvm_vtime_account_guest_exit(void)
{
- context_tracking_guest_exit_irqoff();
-
instrumentation_begin();
/* Flush the guest cputime we spent on the guest */
vtime_account_guest_exit();
instrumentation_end();
}

+static __always_inline void guest_exit_irqoff(void)
+{
+ context_tracking_guest_exit_irqoff();
+
+ kvm_vtime_account_guest_exit();
+}
+
static inline void guest_exit(void)
{
unsigned long flags;
--
2.31.1.295.g9ea45b61b8-goog