summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/context_tracking.h19
-rw-r--r--kernel/context_tracking.c23
-rw-r--r--kernel/sched/cputime.c2
3 files changed, 21 insertions, 23 deletions
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index 38ab60b3f3a6..8854eadb2142 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -95,8 +95,23 @@ static inline void context_tracking_init(void) { }
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
-extern void guest_enter(void);
-extern void guest_exit(void);
+static inline void guest_enter(void)
+{
+ if (static_key_false(&context_tracking_enabled) &&
+ vtime_accounting_enabled())
+ vtime_guest_enter(current);
+ else
+ current->flags |= PF_VCPU;
+}
+
+static inline void guest_exit(void)
+{
+ if (static_key_false(&context_tracking_enabled) &&
+ vtime_accounting_enabled())
+ vtime_guest_exit(current);
+ else
+ current->flags &= ~PF_VCPU;
+}
#else
static inline void guest_enter(void)
{
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 6e89e094c80e..b6a186c4b886 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -21,8 +21,10 @@
#include <linux/export.h>
struct static_key context_tracking_enabled = STATIC_KEY_INIT_FALSE;
+EXPORT_SYMBOL_GPL(context_tracking_enabled);
DEFINE_PER_CPU(struct context_tracking, context_tracking);
+EXPORT_SYMBOL_GPL(context_tracking);
void context_tracking_cpu_set(int cpu)
{
@@ -163,27 +165,6 @@ void context_tracking_user_exit(void)
local_irq_restore(flags);
}
-#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
-void guest_enter(void)
-{
- if (vtime_accounting_enabled())
- vtime_guest_enter(current);
- else
- current->flags |= PF_VCPU;
-}
-EXPORT_SYMBOL_GPL(guest_enter);
-
-void guest_exit(void)
-{
- if (vtime_accounting_enabled())
- vtime_guest_exit(current);
- else
- current->flags &= ~PF_VCPU;
-}
-EXPORT_SYMBOL_GPL(guest_exit);
-#endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */
-
-
/**
* context_tracking_task_switch - context switch the syscall callbacks
* @prev: the task that is being switched out
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 223a35efa0a6..bb6b29a3067c 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -724,6 +724,7 @@ void vtime_guest_enter(struct task_struct *tsk)
current->flags |= PF_VCPU;
write_sequnlock(&tsk->vtime_seqlock);
}
+EXPORT_SYMBOL_GPL(vtime_guest_enter);
void vtime_guest_exit(struct task_struct *tsk)
{
@@ -732,6 +733,7 @@ void vtime_guest_exit(struct task_struct *tsk)
current->flags &= ~PF_VCPU;
write_sequnlock(&tsk->vtime_seqlock);
}
+EXPORT_SYMBOL_GPL(vtime_guest_exit);
void vtime_account_idle(struct task_struct *tsk)
{