From 7488fd98b3603b7608fd9c5a7ce2881c2d280b1a Mon Sep 17 00:00:00 2001 From: john stultz Date: Wed, 1 Feb 2006 03:05:19 -0800 Subject: [PATCH] --- yaml --- r: 19357 b: refs/heads/master c: bfaa1deeb982c985d8e0435e835baeaae63b57fd h: refs/heads/master i: 19355: eb9fd47f3b4249756690deecad6b8c8312e72ec1 v: v3 --- [refs] | 2 +- trunk/arch/i386/kernel/timers/timer_tsc.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index e7da81bf5986..2d988b1f8f45 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2f7016d917faef8f1e016b4a7bd7f594694480b6 +refs/heads/master: bfaa1deeb982c985d8e0435e835baeaae63b57fd diff --git a/trunk/arch/i386/kernel/timers/timer_tsc.c b/trunk/arch/i386/kernel/timers/timer_tsc.c index 47675bbbb316..7c86e3c5f1c1 100644 --- a/trunk/arch/i386/kernel/timers/timer_tsc.c +++ b/trunk/arch/i386/kernel/timers/timer_tsc.c @@ -45,6 +45,15 @@ static unsigned long last_tsc_high; /* msb 32 bits of Time Stamp Counter */ static unsigned long long monotonic_base; static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED; +/* Avoid compensating for lost ticks before TSCs are synched */ +static int detect_lost_ticks; +static int __init start_lost_tick_compensation(void) +{ + detect_lost_ticks = 1; + return 0; +} +late_initcall(start_lost_tick_compensation); + /* convert from cycles(64bits) => nanoseconds (64bits) * basic equation: * ns = cycles / (freq / ns_per_sec) @@ -196,7 +205,8 @@ static void mark_offset_tsc_hpet(void) /* lost tick compensation */ offset = hpet_readl(HPET_T0_CMP) - hpet_tick; - if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0))) { + if (unlikely(((offset - hpet_last) > hpet_tick) && (hpet_last != 0)) + && detect_lost_ticks) { int lost_ticks = (offset - hpet_last) / hpet_tick; jiffies_64 += lost_ticks; } @@ -421,7 +431,7 @@ static void mark_offset_tsc(void) delta += delay_at_last_interrupt; lost = delta/(1000000/HZ); delay = delta%(1000000/HZ); - if (lost >= 2) { + if (lost >= 2 && detect_lost_ticks) { jiffies_64 += lost-1; /* sanity check to ensure we're not always losing ticks */