aboutsummaryrefslogtreecommitdiff
path: root/kernel/sched_clock.c
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-07-07 19:49:41 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-11 15:53:26 +0200
commit2b8a0cf4890d7537a77b51caa8f508e4a05a0e67 (patch)
treea591ef66a6340bf03e6380b6f2aa76ef2fc45ce2 /kernel/sched_clock.c
parentaf52a90a14cdaa54ecbfb6e6982abb13466a4b56 (diff)
downloadlinux-stericsson-2b8a0cf4890d7537a77b51caa8f508e4a05a0e67.tar.gz
sched_clock: fix calculation of other CPU
The algorithm to calculate the 'now' of another CPU is not correct. At each scheduler tick, each CPU records the last sched_clock and gtod (tick_raw and tick_gtod respectively). If the TSC is somewhat the same in speed between two clocks the algorithm would be: tick_gtod1 + (now1 - tick_raw1) = tick_gtod2 + (now2 - tick_raw2) To calculate now2 we would have: now2 = (tick_gtod1 - tick_gtod2) + (tick_raw2 - tick_raw1) + now1 Currently the algorithm is: now2 = (tick_gtod1 - tick_gtod2) + (tick_raw1 - tick_raw2) + now1 This solves most of the rest of the issues I've had with timestamps in ftace. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: john stultz <johnstul@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched_clock.c')
-rw-r--r--kernel/sched_clock.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index 97159e225a77..55fca1e9e12a 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -203,8 +203,8 @@ u64 sched_clock_cpu(int cpu)
now -= my_scd->tick_raw;
now += scd->tick_raw;
- now -= my_scd->tick_gtod;
- now += scd->tick_gtod;
+ now += my_scd->tick_gtod;
+ now -= scd->tick_gtod;
__raw_spin_unlock(&my_scd->lock);
} else {