remove clocksource inline functions
Quoted 25 lines · Martin Schwidefsky
plain text document attachment (clocksource-inline.diff)
From: Martin Schwidefsky <[email protected]>The three inline functions
clocksource_read,clocksource_enableandclocksource_disableare simple wrappers of an indirect call plus the copy from and to themult_origvalue. The functions are exclusively used by the timekeeping code which has intimate knowledge of the clocksource anyway. Therefore remove the inline functions. No functional change.Cc Ingo Molnar <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Daniel Walker <[email protected]>Acked-by John Stultz <[email protected]>Signed-off-by Martin Schwidefsky <[email protected]>--- include/linux/clocksource.h | 58 -------------------------------------------- kernel/time/timekeeping.c | 42 +++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 72 deletions(-)Index:
linux-2.6/kernel/time/timekeeping.c
===================================================================kernel/time/timekeeping.c +0
-0
[snip]
kernel/time/timekeeping.c static int timekeeping_resume(struct sys · line 495
Quoted 7 lines
kernel/time/timekeeping.c +1
-2@@ -477,8 +492,7 @@ static int timekeeping_resume(struct sys }update_xtime_cache (0 );/* re-base the last cycle value */ - clock->cycle_last =0 ; - clock->cycle_last =clocksource_read (clock); + clock->cycle_last = clock->read (clock);
Minor bug here, the clearing of cycle_last has a side-effect of making sure the TSC doesn't trip over its own cycle_last checking in the read() function. This is part of the uglyness of the TSC pulling this internal timeekping state to avoid minor inconsistencies, but until we find a better way, we have to live with it.
So you'll need to preserve the cycle_last = 0 line.
thanks
-john
Re: [patch 11/14] timekeeper read clock helper functions
In reply to a message not in the archiveQuoted 30 lines · Martin Schwidefsky
plain text document attachment (timekeeper-helper.diff)
From: Martin Schwidefsky <[email protected]>Add
timekeeper_read_clock_ntpandtimekeeper_read_clock_rawand use them for getnstimeofday,ktime_get,ktime_get_tsand getrawmonotonic.Cc Ingo Molnar <[email protected]>Cc Thomas Gleixner <[email protected]>Cc john stultz <[email protected]>Cc Daniel Walker <[email protected]>Signed-off-by Martin Schwidefsky <[email protected]>--- kernel/time/timekeeping.c | 91 +++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 53 deletions(-)Index:
linux-2.6/kernel/time/timekeeping.c
===================================================================kernel/time/timekeeping.c +7
-0@@ -95,6 +95,40 @@ static void timekeeper_setup_internals(s timekeeper.mult = clock->mult; } +/* Timekeeper helper functions. */ +static inline s64 timekeeping_get_ns (void ) +{ +cycle_t cycle_now, cycle_delta; +struct clocksource *clock; + +/* read clocksource: */
kernel/time/timekeeping.c static void timekeeper_setup_internals(s · line 114
Quoted 10 lines
kernel/time/timekeeping.c +10
-0+ clock = timekeeper.clock; + cycle_now = clock->read (clock); + +/* calculate the delta since the last update_wall_time: */ + cycle_delta = (cycle_now - clock->cycle_last) & clock->mask; + +/* return delta convert to nanoseconds using ntp adjusted mult. */ +return clocksource_cyc2ns (cycle_delta, timekeeper.mult, + timekeeper.shift); +}
Again, not a huge issue, but if we kept the read() out of this function and instead passed the cycle_now value in as a argument, we could also use this function in timekeeping_forward_now()
thanks
-john
Re: [patch 00/14] clocksource / timekeeping rework V3
In reply to a message not in the archiveQuoted 10 lines · Martin Schwidefsky
Greetings,
version 3 of the clocksource / timekeeping cleanup patches. As far as I'm concerned this is the final version, modulo bugs and review results. All the things I want to have in there are done.The latest additions are:
1) Changeread_persistent_clockto return a struct timespec instead of an unsigned long with the number of seconds.
2) Introduceread_boot_clockto initializewall_to_monotonic.
Quoted 4 lines
The patch set is based on todays upstream tree plus the patches from the tip tree, if anyone wants to try them you need to pull from the master branch of
git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-tip
So I got the patch queue up and running and it's functioning correctly on the box I tested it with (although its not a super interesting box:
TSC is unstable and it only has ACPI PM).
Although I've not been able to test changing clocksources, I assume you gave that a whirl? I'll test that as soon as I can get access to a TSC friendly box.
Once the "cycles_last = 0" fix is in to make sure TSC boxes work, I think this set should be ok to go in.
thanks
-john
Quoted 20 lines · On Thu, 13 Aug 2009 15:14:34 -0700 john stultz <[email protected]> wrote:
Quoted 4 lines · Martin Schwidefsky
Index:
linux-2.6/kernel/time/timekeeping.c
===================================================================kernel/time/timekeeping.c +0
-0[snip]
kernel/time/timekeeping.c static int timekeeping_resume(struct sys · line 495
Quoted 7 lines
kernel/time/timekeeping.c +1
-2@@ -477,8 +492,7 @@ static int timekeeping_resume(struct sys }update_xtime_cache (0 );/* re-base the last cycle value */ - clock->cycle_last =0 ; - clock->cycle_last =clocksource_read (clock); + clock->cycle_last = clock->read (clock);Minor bug here, the clearing of
cycle_lasthas a side-effect of making sure the TSC doesn't trip over its owncycle_lastchecking in theread()function. This is part of the uglyness of the TSC pulling this internal timeekping state to avoid minor inconsistencies, but until we find a better way, we have to live with it.
Quoted 1 line
So you'll need to preserve the
cycle_last= 0 line.
Whoa, now that is subtle. Good spotting. I would prefer to reset the cycle_last in a resume function though:
arch/x86/kernel/tsc.c +6 -0
@@ -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 |
That puts the subtlety where it belongs.
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
Quoted 29 lines · Martin Schwidefsky
Quoted 1 line · On Thu, 13 Aug 2009 15:14:34 -0700 john stultz <[email protected]> wrote:
So you'll need to preserve the
cycle_last= 0 line.Whoa, now that is subtle. Good spotting. I would prefer to reset the
cycle_lastin a resume function though:Index:
linux-2.6/arch/x86/kernel/tsc.c
===================================================================arch/x86/kernel/tsc.c +6
-0@@ -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 |
Quoted 1 line
That puts the subtlety where it belongs.
Ack.
tglx
Re: [patch 11/14] timekeeper read clock helper functions
In reply to john stultzQuoted 22 lines · On Thu, 13 Aug 2009 16:30:18 -0700 john stultz <[email protected]> wrote:
Quoted 21 lines · Martin Schwidefsky
Index:
linux-2.6/kernel/time/timekeeping.c
===================================================================kernel/time/timekeeping.c +13
-0@@ -95,6 +95,40 @@ static void timekeeper_setup_internals(s timekeeper.mult = clock->mult; } +/* Timekeeper helper functions. */ +static inline s64 timekeeping_get_ns (void ) +{ +cycle_t cycle_now, cycle_delta; +struct clocksource *clock; + +/* read clocksource: */ + clock = timekeeper.clock; + cycle_now = clock->read (clock); + +/* calculate the delta since the last update_wall_time: */ + cycle_delta = (cycle_now - clock->cycle_last) & clock->mask; +
Quoted 8 lines
kernel/time/timekeeping.c static void timekeeper_setup_internals(s · line 114
Quoted 4 lines
kernel/time/timekeeping.c +4
-0+/* return delta convert to nanoseconds using ntp adjusted mult. */ +return clocksource_cyc2ns (cycle_delta, timekeeper.mult, + timekeeper.shift); +}Again, not a huge issue, but if we kept the
read()out of this function and instead passed thecycle_nowvalue in as a argument, we could also use this function intimekeeping_forward_now()
I actually tested how the code would look like if I do that. Didn't like the result. The thing is that timekeeping_get_ns is a helper that is supposed to reduce the number of lines you need in the caller. If you push clock->read(clock) call back into the caller it doesn't help much ..
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.