]> git.baikalelectronics.ru Git - kernel.git/commit
sched_clock: fix calculation of other CPU
authorSteven Rostedt <rostedt@goodmis.org>
Mon, 7 Jul 2008 23:49:41 +0000 (19:49 -0400)
committerIngo Molnar <mingo@elte.hu>
Fri, 11 Jul 2008 13:53:26 +0000 (15:53 +0200)
commit6ad1b20e732de1d3ef9ffb88436d7caed84b8a46
treea591ef66a6340bf03e6380b6f2aa76ef2fc45ce2
parenta00429ff8cea1b76e1c32c72955732f343f5e203
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>
kernel/sched_clock.c