Re: [RFC PATCH 13/22 -v2] handle accurate time keeping over long delays

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Mathieu Desnoyers <mathieu.desnoyers@...>
Cc: Tony Luck <tony.luck@...>, <bob.picco@...>, Steven Rostedt <rostedt@...>, LKML <linux-kernel@...>, Ingo Molnar <mingo@...>, Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, Peter Zijlstra <a.p.zijlstra@...>, Christoph Hellwig <hch@...>, Gregory Haskins <ghaskins@...>, Arnaldo Carvalho de Melo <acme@...>, Thomas Gleixner <tglx@...>, Tim Bird <tim.bird@...>, Sam Ravnborg <sam@...>, Frank Ch. Eigler <fche@...>, Steven Rostedt <srostedt@...>
Date: Thursday, January 10, 2008 - 5:25 pm

On Thu, 2008-01-10 at 15:42 -0500, Mathieu Desnoyers wrote:

Hmm. I know powerpc has had a similar lock-free dual structure method
and for just a raw cycles based method you've shown below (or for some
of the bits Steven is working on), I think it should be fine.

The concern I've had with this method for general timekeeping, is that
I'm not sure it can handle the frequency corrections made by NTP. Since
we have to make sure time does not jump backwards, consider this
exaggerated situation:

time = base + (now - last)*mult;

So we have two structures:
base: 60		base: 180
last: 10		last: 30
mult: 06		mult: 05

Where the second structure has just been updated lock-free, however just
before the atomic pointer switch we were preempted, or somehow delayed,
and some time has past.

Now imagine two cpus now race to get the time. Both read the same now
value, but get different structure pointer values. (Note: You can create
the same race if you reverse the order and grab the pointer first, then
the cycle. However I think this example makes it easier to understand).

now = 50
cpu1:
  60 + (50-10)*6 = 300
cpu2:
  180 + (50-30)*5 = 280


Alternatively:
now=50: 60 + (50-10)*6 = 300
now=51: 180 + (51-30)*5 = 285

Eek. That's not good.

I'm not sure how this can be avoided, but I'd be very interested in
hearing ideas! Bounding the issue is a possibility, but then starts to
run amok with NO_HZ and -rt deferment.

thanks
-john


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RFC PATCH 13/22 -v2] handle accurate time keeping over ..., Mathieu Desnoyers, (Thu Jan 10, 4:42 pm)
Re: [RFC PATCH 13/22 -v2] handle accurate time keeping over ..., john stultz, (Thu Jan 10, 5:25 pm)
Re: [RFC PATCH 13/22 -v2] handle accurate time keeping over ..., Mathieu Desnoyers, (Thu Jan 10, 6:00 pm)