linux-2.5.59_getcycles_A0
A message that is not in the archive (sent off-list or not yet received): 1044649542.18673.20.camel@w-jstultz2.beaverton.ibm.com.suse.lists.linux.kernel
Quoted 9 lines · john stultz
Joel, All,
This patch moves the
get_cycles()implementation into thetimer_opts
subsystem. This patch corrects issues between the hangcheck-timer code and systems running withtimer_cyclone. As an extra bonus, it removes theCONFIG_X86_TSC#ifdef inget_cyclesreplacing it withtimer->get_cycles().Comments flames and suggestions welcome.
Is this really a good idea? get_cycles is normally not used to get accurate time, but just to get random numbers for /dev/random or quickly estimate some code (scheduler used to use it for that). I think the TSC even when unsynchronized is better for that than an external timer which potentially lower resolution and long access time.
If you really added it I would at least change the random device to use the old macro.
-Andi
Quoted 7 lines · Andi Kleen
Quoted 5 lines · john stultz
This patch moves the
get_cycles()implementation into thetimer_opts
subsystem. This patch corrects issues between the hangcheck-timer code and systems running withtimer_cyclone. As an extra bonus, it removes theCONFIG_X86_TSC#ifdef inget_cyclesreplacing it withtimer->get_cycles().
Quoted 8 lines
Is this really a good idea?
get_cyclesis normally not used to get accurate time, but just to get random numbers for/dev/randomor quickly estimate some code (scheduler used to use it for that). I think the TSC even when unsynchronized is better for that than an external timer which potentially lower resolution and long access time.If you really added it I would at least change the random device to use the old macro.
I'm sorry, I'm not seeing get_cycles used in /dev/random (although they do make a direct call to rdtsc if its available - which is fine, since the TSCs I deal with daily just give random values anyway :). So I don't believe that is a concern.
Additionally, the hangcheck timer code does calculate time (although, not system time) using get_cycles, and this gives them a good abstraction so the right thing happens on the right box.
Let me know if you have any other concerns.
thanks
-john
Quoted 2 lines
I'm sorry, I'm not seeing
get_cyclesused in/dev/random(although they do make a direct call to rdtsc if its available - which is fine, since
Hmm, perhaps it was only a proposed patch that wasn't merged. Anyways my point stands - get_cycles should be only used when no wall time is needed, so I see no reason to complicate it and slow it down with external timers.
-Andi
Quoted 3 lines · Andi Kleen
Anyways my point stands -
get_cyclesshould be only used when no wall time is needed, so I see no reason to complicate it and slow it down with external timers.
Because it (or some similar form) is needed. The hangcheck timer code needs a method for reading a hard clock.
I've talked it over with Joel and it became obvious that there was no efficient and clean way to get do_gettimeofday to appropriately handle the situation where we loose 60 seconds worth of ticks. Thus Joel needs raw access to a hardware clock, so he used get_cycles() and loops_per_jiffy to calculate a time interval.
However this doesn't work on systems w/o a synced TSC, so by simply making get_cycles() indirect to the TSC or cyclone implementation allows it to do the right thing. It only minorly (extra pointer dereference and call) affects non summit based boxes and returns (albeit slowly) non-random values on summit based boxes.
Now maybe if you'd really rather not change get_cycles, hangcheck_timer could instead use a different interface to do the same indirection. Would you have any gripes with that?
thanks for the feedback.
-john
Quoted 1 line
However this doesn't work on systems w/o a synced TSC, so by simply
Why not? This shouldn't be performance critical and you can make it monotonous with an additional variable + lock if backwards jumps should be a problem.
Also the variations between non synced TSCs should be far below any watchdog's radar screen.
-Andi
Quoted 8 lines
Quoted 1 line
However this doesn't work on systems w/o a synced TSC, so by simply
Why not? This shouldn't be performance critical and you can make it monotonous with an additional variable + lock if backwards jumps should be a problem.
Also the variations between non synced TSCs should be far below any watchdog's radar screen.
Not true. They'll drift further and further apart over time. Even a 0.01% crystal difference will eventually kill you.
And if that isn't bad enough think about what happens when I run 180 MHz processors in one node, and 900MHz in another.
You really can't make any assumptions about TSC sync on boxes where they're not synced.
M.
Quoted 6 lines · Andi Kleen
Quoted 1 line
However this doesn't work on systems w/o a synced TSC, so by simply
Why not? This shouldn't be performance critical and you can make it monotonous with an additional variable + lock if backwards jumps should be a problem.
That sounds horrible! The extra locking and variable reading is going to kill most of the performance concerns you have about reading an alternate time source.
I'm not sure I understand your resistance to using an alternate clock for get_cycles(). Could you better explain your problem with it?
thanks
-john
Quoted 8 lines · john stultz
Quoted 6 lines · Andi Kleen
Quoted 1 line
However this doesn't work on systems w/o a synced TSC, so by simply
Why not? This shouldn't be performance critical and you can make it monotonous with an additional variable + lock if backwards jumps should be a problem.
Quoted 6 lines
That sounds horrible! The extra locking and variable reading is going to kill most of the performance concerns you have about reading an alternate time source.
I'm not sure I understand your resistance to using an alternate clock for
get_cycles(). Could you better explain your problem with it?
I want to keep get_cycles() as a very fast primitive useful for benchmarking etc. and the random device. Accessing the southbridge would make it magnitudes slower.
Regarding the watchdog: what it basically wants is a POSIX CLOCK_MONOTONIC clock. This isn't currently implemented by Linux, but I expect it will be eventually because it's really useful for a lot of applications who just need an increasing time stamp in user space, and who do not want to fight ntpd for this. One example for such an application is the X server who needs this for its internal event sequencing.
Implementing it based on the current time infrastructure is very easy - you just do not add xtime and wall jiffies in, but only jiffies.
I don't think doing any special hacks and complicating get_cycles() for it is the right way. Just implement a new monotonic clock primitive (and eventually export it to user space too)
-Andi
Quoted 7 lines · Andi Kleen
Quoted 2 lines · john stultz
I'm not sure I understand your resistance to using an alternate clock for
get_cycles(). Could you better explain your problem with it?I want to keep
get_cycles()as a very fast primitive useful for benchmarking etc. and the random device. Accessing the southbridge would make it magnitudes slower.
Ok, fair enough. But maybe a comment needs to be added to the get_cycles to notify folks of the issues that surround it on systems without a synced TSC?
Quoted 10 lines
Regarding the watchdog: what it basically wants is a POSIX
CLOCK_MONOTONICclock. This isn't currently implemented by Linux, but I expect it will be eventually because it's really useful for a lot of applications who just need an increasing time stamp in user space, and who do not want to fight ntpd for this. One example for such an application is the X server who needs this for its internal event sequencing.Implementing it based on the current time infrastructure is very easy - you just do not add xtime and wall jiffies in, but only jiffies.
Actually, we can't do this, because if interrupts are being blocked jiffies won't change. That is why I'm trying to provide hardware clock access to hangcheck. It just so happened it was using get_cycles() as an interface and it seemed appropriate for moving to timer_ops.
Quoted 3 lines
I don't think doing any special hacks and complicating
get_cycles()for it is the right way. Just implement a new monotonic clock primitive (and eventually export it to user space too)
Ok, so you're telling me to use another interface. I'm down with that (sometimes I just need it spelled out). Name suggestions? read_hw_timer?
thanks
-john
Quoted 5 lines · john stultz
Quoted 5 lines
of applications who just need an increasing time stamp in user space, and who do not want to fight ntpd for this. One example for such an application is the X server who needs this for its internal event sequencing.
Quoted 7 lines
Quoted 2 lines
Implementing it based on the current time infrastructure is very easy - you just do not add xtime and wall jiffies in, but only jiffies.
Actually, we can't do this, because if interrupts are being blocked jiffies won't change. That is why I'm trying to provide hardware clock access to hangcheck. It just so happened it was using
get_cycles()as an interface and it seemed appropriate for moving totimer_ops.
monotonic clock can use the hw clock too. It just shouldn't use anything manipulated by settimeofday() et.al.
Quoted 8 lines
Quoted 4 lines
I don't think doing any special hacks and complicating
get_cycles()for it is the right way. Just implement a new monotonic clock primitive (and eventually export it to user space too)Ok, so you're telling me to use another interface. I'm down with that (sometimes I just need it spelled out). Name suggestions?
read_hw_timer?
monotonic_clock()
-Andi
Quoted 8 lines · Andi Kleen
Regarding the watchdog: what it basically wants is a POSIX
CLOCK_MONOTONICclock. This isn't currently implemented by Linux, but I expect it will be eventually because it's really useful for a lot of applications who just need an increasing time stamp in user space, and who do not want to fight ntpd for this. One example for such an application is the X server who needs this for its internal event sequencing.
Quoted 6 lines
Implementing it based on the current time infrastructure is very easy - you just do not add xtime and wall jiffies in, but only jiffies.
I don't think doing any special hacks and complicating
get_cycles()for it is the right way. Just implement a new monotonic clock primitive (and eventually export it to user space too)
That seems to be the right way to go, rather than slow get_cycles() have a separate functionality which does what you need. Didn't know about CLOCK_MONOTONIC by that name, but I agree it's useful in various places.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.