Skip to content

Commit 88d8220

Browse files
Wanpeng LiKAGA-KOKO
authored andcommitted
context_tracking: Move guest exit vtime accounting to separate helpers
Provide separate vtime accounting functions for guest exit instead of open coding the logic within the context tracking code. This will allow KVM x86 to handle vtime accounting slightly differently when using tick-based accounting. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Wanpeng Li <wanpengli@tencent.com> Co-developed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Link: https://lore.kernel.org/r/20210505002735.1684165-3-seanjc@google.com
1 parent 866a6da commit 88d8220

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

include/linux/context_tracking.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,20 @@ static __always_inline void context_tracking_guest_exit(void)
137137
__context_tracking_exit(CONTEXT_GUEST);
138138
}
139139

140-
static __always_inline void guest_exit_irqoff(void)
140+
static __always_inline void vtime_account_guest_exit(void)
141141
{
142-
context_tracking_guest_exit();
143-
144-
instrumentation_begin();
145142
if (vtime_accounting_enabled_this_cpu())
146143
vtime_guest_exit(current);
147144
else
148145
current->flags &= ~PF_VCPU;
146+
}
147+
148+
static __always_inline void guest_exit_irqoff(void)
149+
{
150+
context_tracking_guest_exit();
151+
152+
instrumentation_begin();
153+
vtime_account_guest_exit();
149154
instrumentation_end();
150155
}
151156

@@ -166,12 +171,17 @@ static __always_inline void guest_enter_irqoff(void)
166171

167172
static __always_inline void context_tracking_guest_exit(void) { }
168173

174+
static __always_inline void vtime_account_guest_exit(void)
175+
{
176+
vtime_account_kernel(current);
177+
current->flags &= ~PF_VCPU;
178+
}
179+
169180
static __always_inline void guest_exit_irqoff(void)
170181
{
171182
instrumentation_begin();
172183
/* Flush the guest cputime we spent on the guest */
173-
vtime_account_kernel(current);
174-
current->flags &= ~PF_VCPU;
184+
vtime_account_guest_exit();
175185
instrumentation_end();
176186
}
177187
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */

0 commit comments

Comments
 (0)