context_tracking: Make guest_enter/exit() .noinstr ready

Force inlining of the helpers and mark the instrumentable parts
accordingly.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200505134341.672545766@linutronix.de
This commit is contained in:
Thomas Gleixner
2020-03-19 14:53:56 +01:00
parent c86e9b987c
commit af1e56b785

View File

@@ -101,12 +101,14 @@ static inline void context_tracking_init(void) { }
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
/* must be called with irqs disabled */ /* must be called with irqs disabled */
static inline void guest_enter_irqoff(void) static __always_inline void guest_enter_irqoff(void)
{ {
instrumentation_begin();
if (vtime_accounting_enabled_this_cpu()) if (vtime_accounting_enabled_this_cpu())
vtime_guest_enter(current); vtime_guest_enter(current);
else else
current->flags |= PF_VCPU; current->flags |= PF_VCPU;
instrumentation_end();
if (context_tracking_enabled()) if (context_tracking_enabled())
__context_tracking_enter(CONTEXT_GUEST); __context_tracking_enter(CONTEXT_GUEST);
@@ -118,39 +120,48 @@ static inline void guest_enter_irqoff(void)
* one time slice). Lets treat guest mode as quiescent state, just like * one time slice). Lets treat guest mode as quiescent state, just like
* we do with user-mode execution. * we do with user-mode execution.
*/ */
if (!context_tracking_enabled_this_cpu()) if (!context_tracking_enabled_this_cpu()) {
instrumentation_begin();
rcu_virt_note_context_switch(smp_processor_id()); rcu_virt_note_context_switch(smp_processor_id());
instrumentation_end();
}
} }
static inline void guest_exit_irqoff(void) static __always_inline void guest_exit_irqoff(void)
{ {
if (context_tracking_enabled()) if (context_tracking_enabled())
__context_tracking_exit(CONTEXT_GUEST); __context_tracking_exit(CONTEXT_GUEST);
instrumentation_begin();
if (vtime_accounting_enabled_this_cpu()) if (vtime_accounting_enabled_this_cpu())
vtime_guest_exit(current); vtime_guest_exit(current);
else else
current->flags &= ~PF_VCPU; current->flags &= ~PF_VCPU;
instrumentation_end();
} }
#else #else
static inline void guest_enter_irqoff(void) static __always_inline void guest_enter_irqoff(void)
{ {
/* /*
* This is running in ioctl context so its safe * This is running in ioctl context so its safe
* to assume that it's the stime pending cputime * to assume that it's the stime pending cputime
* to flush. * to flush.
*/ */
instrumentation_begin();
vtime_account_kernel(current); vtime_account_kernel(current);
current->flags |= PF_VCPU; current->flags |= PF_VCPU;
rcu_virt_note_context_switch(smp_processor_id()); rcu_virt_note_context_switch(smp_processor_id());
instrumentation_end();
} }
static inline void guest_exit_irqoff(void) static __always_inline void guest_exit_irqoff(void)
{ {
instrumentation_begin();
/* Flush the guest cputime we spent on the guest */ /* Flush the guest cputime we spent on the guest */
vtime_account_kernel(current); vtime_account_kernel(current);
current->flags &= ~PF_VCPU; current->flags &= ~PF_VCPU;
instrumentation_end();
} }
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */ #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */