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 <[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]
1 parent 866a6da commit 88d8220

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
@@ -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)