path: root/kernel/context_tracking.c
diff options
authorFrederic Weisbecker <>2012-12-16 20:00:34 +0100
committerFrederic Weisbecker <>2013-01-27 20:35:47 +0100
commit6a61671bb2f3a1bd12cd17b8fca811a624782632 (patch)
tree0afc2915fb7e517472710a49a524510322dd5baa /kernel/context_tracking.c
parentc11f11fcbdb5be790c565aed46411486a7586afc (diff)
cputime: Safely read cputime of full dynticks CPUs
While remotely reading the cputime of a task running in a full dynticks CPU, the values stored in utime/stime fields of struct task_struct may be stale. Its values may be those of the last kernel <-> user transition time snapshot and we need to add the tickless time spent since this snapshot. To fix this, flush the cputime of the dynticks CPUs on kernel <-> user transition and record the time / context where we did this. Then on top of this snapshot and the current time, perform the fixup on the reader side from task_times() accessors. Signed-off-by: Frederic Weisbecker <> Cc: Andrew Morton <> Cc: Ingo Molnar <> Cc: Li Zhong <> Cc: Namhyung Kim <> Cc: Paul E. McKenney <> Cc: Paul Gortmaker <> Cc: Peter Zijlstra <> Cc: Steven Rostedt <> Cc: Thomas Gleixner <> [fixed kvm module related build errors] Signed-off-by: Sedat Dilek <>
Diffstat (limited to 'kernel/context_tracking.c')
1 files changed, 20 insertions, 1 deletions
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 9002e92e6372..74f68f4dc6c2 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -1,8 +1,9 @@
#include <linux/context_tracking.h>
+#include <linux/kvm_host.h>
#include <linux/rcupdate.h>
#include <linux/sched.h>
#include <linux/hardirq.h>
+#include <linux/export.h>
DEFINE_PER_CPU(struct context_tracking, context_tracking) = {
@@ -61,6 +62,24 @@ void user_exit(void)
+void guest_enter(void)
+ if (vtime_accounting_enabled())
+ vtime_guest_enter(current);
+ else
+ __guest_enter();
+void guest_exit(void)
+ if (vtime_accounting_enabled())
+ vtime_guest_exit(current);
+ else
+ __guest_exit();
void context_tracking_task_switch(struct task_struct *prev,
struct task_struct *next)