[patch 03/15] reset of cycle_last for tsc clocksource

From: Martin Schwidefsky
Date: Fri Aug 14 2009 - 09:51:06 EST


From: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>

change_clocksource resets the cycle_last value to zero then sets
it to a value read from the clocksource. The reset to zero is
required only for the TSC clocksource to make the read_tsc function
work. This is subtle and surprising. Move the reset to a resume
function in the tsc code.

Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Daniel Walker <dwalker@xxxxxxxxxx>
Cc: John Stultz <johnstul@xxxxxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
---
arch/x86/kernel/tsc.c | 6 ++++++
kernel/time/timekeeping.c | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)

Index: linux-2.6/arch/x86/kernel/tsc.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/tsc.c
+++ linux-2.6/arch/x86/kernel/tsc.c
@@ -744,10 +744,16 @@ static cycle_t __vsyscall_fn vread_tsc(v
}
#endif

+static void resume_tsc(void)
+{
+ clocksource_tsc.cycle_last = 0;
+}
+
static struct clocksource clocksource_tsc = {
.name = "tsc",
.rating = 300,
.read = read_tsc,
+ .resume = resume_tsc,
.mask = CLOCKSOURCE_MASK(64),
.shift = 22,
.flags = CLOCK_SOURCE_IS_CONTINUOUS |
Index: linux-2.6/kernel/time/timekeeping.c
===================================================================
--- linux-2.6.orig/kernel/time/timekeeping.c
+++ linux-2.6/kernel/time/timekeeping.c
@@ -295,7 +295,6 @@ static void change_clocksource(void)
if (old->disable)
old->disable(old);

- clock->cycle_last = 0;
clock->cycle_last = clock->read(clock);
clock->error = 0;
clock->xtime_nsec = 0;

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/