All of lore.kernel.org
 help / color / mirror / Atom feed
* time jumps forward/backwards
@ 2009-08-31 21:53 Ben Gamsa
  2009-08-31 23:45 ` Paul Mackerras
  0 siblings, 1 reply; 10+ messages in thread
From: Ben Gamsa @ 2009-08-31 21:53 UTC (permalink / raw)
  To: linuxppc-dev

Our project is currently using 2.6.27.4 with a patch from Paul Mackerras 
("powerpc: Improve resolution of VDSO clock_gettime") running on a 
MPC8555.  We picked up the patch on the hope that it would fix an 
earlier problem we had with time jumping forwards and backwards shortly 
after boot-up.  It seemed to fix that problem, but it seems we have 
another, similar problem.

It appears to be the case that when the time on the system is around the 
epoch (1970), that time will occasionally jump forward and then backward 
by about 17592 seconds.  When it jumps forward, it always jumps back a 
few milliseconds later.  However, it's not always easy to catch these 
occurrences.  The delta is more specifically about 17592186059 usec, 
give or take a few 10s of microseconds (most of the time), despite the 
fact that the user-level program I have that is testing it only checks 
every 10 milliseconds.

The number seems suspiciously close to 2^44 nanoseconds, which suggests 
some sort of overflow error, perhaps caused by the time being set to 
around time 0.

I'm not really sure where to begin looking (I know that the time code is 
one of the more sensitive bits in the system so I definitely don't want 
to go blindly mucking around), so I was hoping to get some suggestions 
from the list.

Thanks for any help.

-- 
Ben Gamsa       ben@somanetworks.com
SOMA Networks   312 Adelaide St. W. Suite 600 Toronto, Ontario, M5V1R2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-08-31 21:53 time jumps forward/backwards Ben Gamsa
@ 2009-08-31 23:45 ` Paul Mackerras
  2009-09-01  0:01   ` Benjamin Gamsa
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Mackerras @ 2009-08-31 23:45 UTC (permalink / raw)
  To: Ben Gamsa; +Cc: linuxppc-dev

Ben Gamsa writes:

> It appears to be the case that when the time on the system is around the 
> epoch (1970), that time will occasionally jump forward and then backward 
> by about 17592 seconds.  When it jumps forward, it always jumps back a 
> few milliseconds later.  However, it's not always easy to catch these 
> occurrences.  The delta is more specifically about 17592186059 usec, 
> give or take a few 10s of microseconds (most of the time), despite the 
> fact that the user-level program I have that is testing it only checks 
> every 10 milliseconds.

I don't think the time code in the kernel is designed to handle
negative values, i.e., times before the epoch.  If you want it to do
that you'll have to check places like arch/powerpc/kernel/time.c,
kernel/time/timekeeping.c, arch/powerpc/include/asm/time.h, etc., and
make sure that it uses signed types where necessary and that the
arithmetic is correct.

Paul.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-08-31 23:45 ` Paul Mackerras
@ 2009-09-01  0:01   ` Benjamin Gamsa
  2009-09-01  0:09     ` Benjamin Gamsa
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gamsa @ 2009-09-01  0:01 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Paul Mackerras wrote:
> Ben Gamsa writes:
> 
>> It appears to be the case that when the time on the system is around the 
>> epoch (1970), that time will occasionally jump forward and then backward 
>> by about 17592 seconds.  When it jumps forward, it always jumps back a 
>> few milliseconds later.  However, it's not always easy to catch these 
>> occurrences.  The delta is more specifically about 17592186059 usec, 
>> give or take a few 10s of microseconds (most of the time), despite the 
>> fact that the user-level program I have that is testing it only checks 
>> every 10 milliseconds.
> 
> I don't think the time code in the kernel is designed to handle
> negative values, i.e., times before the epoch.  If you want it to do
> that you'll have to check places like arch/powerpc/kernel/time.c,
> kernel/time/timekeeping.c, arch/powerpc/include/asm/time.h, etc., and
> make sure that it uses signed types where necessary and that the
> arithmetic is correct.
> 

The time never goes negative.  It starts off at the epoch and moves 
forward, but sometimes it jumps forward by 17952 seconds, and then 
immediately jumps back.  But it never goes negative (or prior to 1970).

	ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01  0:01   ` Benjamin Gamsa
@ 2009-09-01  0:09     ` Benjamin Gamsa
  2009-09-01  2:20       ` Benjamin Gamsa
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gamsa @ 2009-09-01  0:09 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Benjamin Gamsa wrote:
> Paul Mackerras wrote:
>> Ben Gamsa writes:
>>
>>> It appears to be the case that when the time on the system is around 
>>> the epoch (1970), that time will occasionally jump forward and then 
>>> backward by about 17592 seconds.  When it jumps forward, it always 
>>> jumps back a few milliseconds later.  However, it's not always easy 
>>> to catch these occurrences.  The delta is more specifically about 
>>> 17592186059 usec, give or take a few 10s of microseconds (most of the 
>>> time), despite the fact that the user-level program I have that is 
>>> testing it only checks every 10 milliseconds.
>>
>> I don't think the time code in the kernel is designed to handle
>> negative values, i.e., times before the epoch.  If you want it to do
>> that you'll have to check places like arch/powerpc/kernel/time.c,
>> kernel/time/timekeeping.c, arch/powerpc/include/asm/time.h, etc., and
>> make sure that it uses signed types where necessary and that the
>> arithmetic is correct.
>>
> 
> The time never goes negative.  It starts off at the epoch and moves 
> forward, but sometimes it jumps forward by 17952 seconds, and then 
> immediately jumps back.  But it never goes negative (or prior to 1970).
> 

One important thing I forgot to add is that ntpd is running on this 
system, but the ntp servers are not available.  I suspect the problem 
may be related to ntpd, even though I've seen the time jump even when I 
had ntpd stopped within gdb.  I've not yet been able to confirm if the 
problem still occurs when ntpd is never even started, although I will be 
testing that soon (the tests often require many hours to establish if 
there are no jumps).

	ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01  0:09     ` Benjamin Gamsa
@ 2009-09-01  2:20       ` Benjamin Gamsa
  2009-09-01  2:31         ` Sean MacLennan
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gamsa @ 2009-09-01  2:20 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Benjamin Gamsa wrote:
> Benjamin Gamsa wrote:
>> Paul Mackerras wrote:
>>> Ben Gamsa writes:
>>>
>>>> It appears to be the case that when the time on the system is around 
>>>> the epoch (1970), that time will occasionally jump forward and then 
>>>> backward by about 17592 seconds.  When it jumps forward, it always 
>>>> jumps back a few milliseconds later.  However, it's not always easy 
>>>> to catch these occurrences.  The delta is more specifically about 
>>>> 17592186059 usec, give or take a few 10s of microseconds (most of 
>>>> the time), despite the fact that the user-level program I have that 
>>>> is testing it only checks every 10 milliseconds.
>>>
>>> I don't think the time code in the kernel is designed to handle
>>> negative values, i.e., times before the epoch.  If you want it to do
>>> that you'll have to check places like arch/powerpc/kernel/time.c,
>>> kernel/time/timekeeping.c, arch/powerpc/include/asm/time.h, etc., and
>>> make sure that it uses signed types where necessary and that the
>>> arithmetic is correct.
>>>
>>
>> The time never goes negative.  It starts off at the epoch and moves 
>> forward, but sometimes it jumps forward by 17952 seconds, and then 
>> immediately jumps back.  But it never goes negative (or prior to 1970).
>>
> 
> One important thing I forgot to add is that ntpd is running on this 
> system, but the ntp servers are not available.  I suspect the problem 
> may be related to ntpd, even though I've seen the time jump even when I 
> had ntpd stopped within gdb.  I've not yet been able to confirm if the 
> problem still occurs when ntpd is never even started, although I will be 
> testing that soon (the tests often require many hours to establish if 
> there are no jumps).

For what it's worth, the problem occurs even when ntp is not even started.

	ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01  2:20       ` Benjamin Gamsa
@ 2009-09-01  2:31         ` Sean MacLennan
  2009-09-01  3:57           ` Benjamin Gamsa
  0 siblings, 1 reply; 10+ messages in thread
From: Sean MacLennan @ 2009-09-01  2:31 UTC (permalink / raw)
  To: Benjamin Gamsa; +Cc: linuxppc-dev, Paul Mackerras

On Mon, 31 Aug 2009 22:20:00 -0400
Benjamin Gamsa <ben@somanetworks.com> wrote:

> For what it's worth, the problem occurs even when ntp is not even
> started.

This is grasping, but could it have anything to do with the jiffies
wrapping near startup?

Cheers,
  Sean

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01  2:31         ` Sean MacLennan
@ 2009-09-01  3:57           ` Benjamin Gamsa
  2009-09-01 10:49             ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gamsa @ 2009-09-01  3:57 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev, Paul Mackerras

Sean MacLennan wrote:
> On Mon, 31 Aug 2009 22:20:00 -0400
> Benjamin Gamsa <ben@somanetworks.com> wrote:
> 
>> For what it's worth, the problem occurs even when ntp is not even
>> started.
> 
> This is grasping, but could it have anything to do with the jiffies
> wrapping near startup?
> 

I don't know how to test it, but I don't think so, since there are 
multiple of these glitches over an extended period of time.

	ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01  3:57           ` Benjamin Gamsa
@ 2009-09-01 10:49             ` Benjamin Herrenschmidt
  2009-09-01 11:20               ` Benjamin Gamsa
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2009-09-01 10:49 UTC (permalink / raw)
  To: Benjamin Gamsa; +Cc: Paul Mackerras, linuxppc-dev, Sean MacLennan

On Mon, 2009-08-31 at 23:57 -0400, Benjamin Gamsa wrote:
> Sean MacLennan wrote:
> > On Mon, 31 Aug 2009 22:20:00 -0400
> > Benjamin Gamsa <ben@somanetworks.com> wrote:
> > 
> >> For what it's worth, the problem occurs even when ntp is not even
> >> started.
> > 
> > This is grasping, but could it have anything to do with the jiffies
> > wrapping near startup?
> > 
> 
> I don't know how to test it, but I don't think so, since there are 
> multiple of these glitches over an extended period of time.

I'm not familiar with all the FSL processor variants, but is this
an UP or an SMP platform ? In the later case, are all the core timebases
properly synchronized ?

Cheers,
Ben.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01 10:49             ` Benjamin Herrenschmidt
@ 2009-09-01 11:20               ` Benjamin Gamsa
  2009-09-03 12:49                 ` Ben Gamsa
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Gamsa @ 2009-09-01 11:20 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Paul Mackerras, linuxppc-dev, Sean MacLennan

Benjamin Herrenschmidt wrote:
> On Mon, 2009-08-31 at 23:57 -0400, Benjamin Gamsa wrote:
>> Sean MacLennan wrote:
>>> On Mon, 31 Aug 2009 22:20:00 -0400
>>> Benjamin Gamsa <ben@somanetworks.com> wrote:
>>>
>>>> For what it's worth, the problem occurs even when ntp is not even
>>>> started.
>>> This is grasping, but could it have anything to do with the jiffies
>>> wrapping near startup?
>>>
>> I don't know how to test it, but I don't think so, since there are 
>> multiple of these glitches over an extended period of time.
> 
> I'm not familiar with all the FSL processor variants, but is this
> an UP or an SMP platform ? In the later case, are all the core timebases
> properly synchronized ?
> 

This a UP with a single e500 core.

	ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: time jumps forward/backwards
  2009-09-01 11:20               ` Benjamin Gamsa
@ 2009-09-03 12:49                 ` Ben Gamsa
  0 siblings, 0 replies; 10+ messages in thread
From: Ben Gamsa @ 2009-09-03 12:49 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras, Sean MacLennan

Benjamin Gamsa wrote:
> Benjamin Herrenschmidt wrote:
>> On Mon, 2009-08-31 at 23:57 -0400, Benjamin Gamsa wrote:
>>> Sean MacLennan wrote:
>>>> On Mon, 31 Aug 2009 22:20:00 -0400
>>>> Benjamin Gamsa <ben@somanetworks.com> wrote:
>>>>
>>>>> For what it's worth, the problem occurs even when ntp is not even
>>>>> started.
>>>> This is grasping, but could it have anything to do with the jiffies
>>>> wrapping near startup?
>>>>
>>> I don't know how to test it, but I don't think so, since there are 
>>> multiple of these glitches over an extended period of time.
>>
>> I'm not familiar with all the FSL processor variants, but is this
>> an UP or an SMP platform ? In the later case, are all the core timebases
>> properly synchronized ?
>>
> 
> This a UP with a single e500 core.
> 

I take it from the lack of follow-ups that no one has any good ideas as 
to what might be going wrong?

Since the problem seems to be confined to situations where the date is 
around the epoch, I guess I'll just work-around the problem by setting 
the date to a more recent date on startup.

-- 
Ben Gamsa       ben@somanetworks.com
SOMA Networks   312 Adelaide St. W. Suite 600 Toronto, Ontario, M5V1R2

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-09-03 12:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-31 21:53 time jumps forward/backwards Ben Gamsa
2009-08-31 23:45 ` Paul Mackerras
2009-09-01  0:01   ` Benjamin Gamsa
2009-09-01  0:09     ` Benjamin Gamsa
2009-09-01  2:20       ` Benjamin Gamsa
2009-09-01  2:31         ` Sean MacLennan
2009-09-01  3:57           ` Benjamin Gamsa
2009-09-01 10:49             ` Benjamin Herrenschmidt
2009-09-01 11:20               ` Benjamin Gamsa
2009-09-03 12:49                 ` Ben Gamsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.