From 3e736d509921e5071a688f5676c129762eda9909 Mon Sep 17 00:00:00 2001 From: John Stultz Date: Wed, 20 Aug 2008 16:37:28 -0700 Subject: [PATCH] --- yaml --- r: 116337 b: refs/heads/master c: 1aa5dfb751d275ae7117d3b73ac423b4a46f2a73 h: refs/heads/master i: 116335: cbcada497c7df7a777fb9273f1e84a833c5ac4f7 v: v3 --- [refs] | 2 +- trunk/include/linux/clocksource.h | 11 +++++++---- trunk/kernel/time/clocksource.c | 3 +++ trunk/kernel/time/jiffies.c | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index ff8638fdac8b..8b647645f6a9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ee974e01e5ef2914036f08c8e41d1a3fa8bfc9d9 +refs/heads/master: 1aa5dfb751d275ae7117d3b73ac423b4a46f2a73 diff --git a/trunk/include/linux/clocksource.h b/trunk/include/linux/clocksource.h index 55e434feec99..f0a7fb984413 100644 --- a/trunk/include/linux/clocksource.h +++ b/trunk/include/linux/clocksource.h @@ -45,7 +45,8 @@ struct clocksource; * @read: returns a cycle value * @mask: bitmask for two's complement * subtraction of non 64 bit counters - * @mult: cycle to nanosecond multiplier + * @mult: cycle to nanosecond multiplier (adjusted by NTP) + * @mult_orig: cycle to nanosecond multiplier (unadjusted by NTP) * @shift: cycle to nanosecond divisor (power of two) * @flags: flags describing special properties * @vread: vsyscall based read @@ -63,6 +64,7 @@ struct clocksource { cycle_t (*read)(void); cycle_t mask; u32 mult; + u32 mult_orig; u32 shift; unsigned long flags; cycle_t (*vread)(void); @@ -201,16 +203,17 @@ static inline void clocksource_calculate_interval(struct clocksource *c, { u64 tmp; - /* XXX - All of this could use a whole lot of optimization */ + /* Do the ns -> cycle conversion first, using original mult */ tmp = length_nsec; tmp <<= c->shift; - tmp += c->mult/2; - do_div(tmp, c->mult); + tmp += c->mult_orig/2; + do_div(tmp, c->mult_orig); c->cycle_interval = (cycle_t)tmp; if (c->cycle_interval == 0) c->cycle_interval = 1; + /* Go back from cycles -> shifted ns, this time use ntp adjused mult */ c->xtime_interval = (u64)c->cycle_interval * c->mult; } diff --git a/trunk/kernel/time/clocksource.c b/trunk/kernel/time/clocksource.c index 093d4acf993b..9ed2eec97526 100644 --- a/trunk/kernel/time/clocksource.c +++ b/trunk/kernel/time/clocksource.c @@ -325,6 +325,9 @@ int clocksource_register(struct clocksource *c) unsigned long flags; int ret; + /* save mult_orig on registration */ + c->mult_orig = c->mult; + spin_lock_irqsave(&clocksource_lock, flags); ret = clocksource_enqueue(c); if (!ret) diff --git a/trunk/kernel/time/jiffies.c b/trunk/kernel/time/jiffies.c index 4c256fdb8875..1ca99557e929 100644 --- a/trunk/kernel/time/jiffies.c +++ b/trunk/kernel/time/jiffies.c @@ -61,6 +61,7 @@ struct clocksource clocksource_jiffies = { .read = jiffies_read, .mask = 0xffffffff, /*32bits*/ .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ + .mult_orig = NSEC_PER_JIFFY << JIFFIES_SHIFT, .shift = JIFFIES_SHIFT, };