Skip to content

Commit 7706830

Browse files
Wanpeng Ligregkh
authored andcommitted
context_tracking: Move guest exit vtime accounting to separate helpers
commit 88d8220 upstream. 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 <[email protected]> Signed-off-by: Wanpeng Li <[email protected]> Co-developed-by: Sean Christopherson <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Christian Borntraeger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5ae5e3f commit 7706830

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

include/linux/context_tracking.h

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

138-
static __always_inline void guest_exit_irqoff(void)
138+
static __always_inline void vtime_account_guest_exit(void)
139139
{
140-
context_tracking_guest_exit();
141-
142-
instrumentation_begin();
143140
if (vtime_accounting_enabled_this_cpu())
144141
vtime_guest_exit(current);
145142
else
146143
current->flags &= ~PF_VCPU;
144+
}
145+
146+
static __always_inline void guest_exit_irqoff(void)
147+
{
148+
context_tracking_guest_exit();
149+
150+
instrumentation_begin();
151+
vtime_account_guest_exit();
147152
instrumentation_end();
148153
}
149154

@@ -164,12 +169,17 @@ static __always_inline void guest_enter_irqoff(void)
164169

165170
static __always_inline void context_tracking_guest_exit(void) { }
166171

172+
static __always_inline void vtime_account_guest_exit(void)
173+
{
174+
vtime_account_kernel(current);
175+
current->flags &= ~PF_VCPU;
176+
}
177+
167178
static __always_inline void guest_exit_irqoff(void)
168179
{
169180
instrumentation_begin();
170181
/* Flush the guest cputime we spent on the guest */
171-
vtime_account_kernel(current);
172-
current->flags &= ~PF_VCPU;
182+
vtime_account_guest_exit();
173183
instrumentation_end();
174184
}
175185
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */

0 commit comments

Comments
 (0)