Skip to contentSkip to conversation

Negative time on Acer Ferrari One with current -git

Regression Rafael J. Wysocki 5 participants 16 messages May 21, 2010 – May 23, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

Rafael

#1 lore raw
Quoted 6 lines · Rafael J. Wysocki

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

No ideas, but apart from the obvious "maybe you can pin it down a bit with a few bisection compiles", it's almost certainly through the timer tree merge from Thomas, which included various wall-clock-time changes from John Stultz & co.

I don't see anything else that would likely affect any wall-clock time, but who knows..

John, Thomas? Ring any bells?

Linus

#2 lore raw
Quoted 14 lines · Linus Torvalds
Quoted 6 lines · Rafael J. Wysocki

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

No ideas, but apart from the obvious "maybe you can pin it down a bit with a few bisection compiles", it's almost certainly through the timer tree merge from Thomas, which included various wall-clock-time changes from John Stultz & co.

Quoted 4 lines

I don't see anything else that would likely affect any wall-clock time, but who knows..

John, Thomas? Ring any bells?

Hrm.. From my queue, I'd probably try reverting the following first:

6a867a3|| time: Remove xtime_cache

Rafael: I assume 2.6.34 is fine?

thanks
-john

#3 lore raw
Quoted 15 lines · john stultz
Quoted 14 lines · Linus Torvalds
Quoted 6 lines · Rafael J. Wysocki

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

No ideas, but apart from the obvious "maybe you can pin it down a bit with a few bisection compiles", it's almost certainly through the timer tree merge from Thomas, which included various wall-clock-time changes from John Stultz & co.

Quoted 8 lines
Quoted 4 lines

I don't see anything else that would likely affect any wall-clock time, but who knows..

John, Thomas? Ring any bells?

Hrm.. From my queue, I'd probably try reverting the following first:

6a867a3|| time: Remove xtime_cache

That doesn't help.

Quoted 1 line

Rafael: I assume 2.6.34 is fine?

Yes, it is.

Thanks,
Rafael

#4 lore raw
In reply to Linus Torvalds
Quoted 13 lines · Linus Torvalds
Quoted 6 lines · Rafael J. Wysocki

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

No ideas, but apart from the obvious "maybe you can pin it down a bit with a few bisection compiles", it's almost certainly through the timer tree merge from Thomas, which included various wall-clock-time changes from John Stultz & co.

Quoted 4 lines

I don't see anything else that would likely affect any wall-clock time, but who knows..

John, Thomas? Ring any bells?

Went through the pile and nothing stands out.

The system has an AMD X2 with the jinxed C1E, so I'd rather suspect that we managed to break C1E again.

Just tried to boot -git on my X2 machine and it does not come up. Investigating.

Thanks,

tglx

#5 lore raw
Quoted 19 lines · Thomas Gleixner
Quoted 13 lines · Linus Torvalds
Quoted 6 lines · Rafael J. Wysocki

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

No ideas, but apart from the obvious "maybe you can pin it down a bit with a few bisection compiles", it's almost certainly through the timer tree merge from Thomas, which included various wall-clock-time changes from John Stultz & co.

Quoted 4 lines

I don't see anything else that would likely affect any wall-clock time, but who knows..

John, Thomas? Ring any bells?

Quoted 7 lines

Went through the pile and nothing stands out.

The system has an AMD X2 with the jinxed C1E, so I'd rather suspect that we managed to break C1E again.

Just tried to boot -git on my X2 machine and it does not come up. Investigating.

Second boot worked, I love heisenbugs. :(

Rafael, can you check whether the C1E idle is selected. Also which clocksource is used ?

Thanks,

tglx

#6 lore raw
Quoted 25 lines · Thomas Gleixner
Quoted 24 lines · Thomas Gleixner
Quoted 13 lines · Linus Torvalds
Quoted 6 lines · Rafael J. Wysocki

Trying to boot current -git on Acer Ferrari One (64-bit), I get mount errors for all filesystems telling me that "now = (null) is in the future" and when run 'date' it says: "date: time <long negative number> is out of range".

Any ideas anyone?

No ideas, but apart from the obvious "maybe you can pin it down a bit with a few bisection compiles", it's almost certainly through the timer tree merge from Thomas, which included various wall-clock-time changes from John Stultz & co.

Quoted 4 lines

I don't see anything else that would likely affect any wall-clock time, but who knows..

John, Thomas? Ring any bells?

Went through the pile and nothing stands out.

The system has an AMD X2 with the jinxed C1E, so I'd rather suspect that we managed to break C1E again.

Quoted 6 lines
Quoted 2 lines

Just tried to boot -git on my X2 machine and it does not come up. Investigating.

Second boot worked, I love heisenbugs. :(

Rafael, can you check whether the C1E idle is selected.

Can you please remind me how I can check that?

Quoted 1 line

Also which clocksource is used ?

hpet

Thanks,
Rafael

#7 lore raw

From: "Rafael J. Wysocki" <[email protected]>
Date: Sat, May 22, 2010 at 07:34:09PM +0200

Quoted 3 lines
Quoted 1 line

Rafael, can you check whether the C1E idle is selected.

Can you please remind me how I can check that?

look for

"using C1E aware idle routine"

in dmesg.

Signature · 2 lines
Regards/Gruss,
    Boris.
#8 lore raw
Quoted 10 lines · Borislav Petkov

From: "Rafael J. Wysocki" <[email protected]>
Date: Sat, May 22, 2010 at 07:34:09PM +0200

Quoted 3 lines
Quoted 1 line

Rafael, can you check whether the C1E idle is selected.

Can you please remind me how I can check that?

look for

"using C1E aware idle routine"

Yes, it prints that.

Rafael

#9 lore raw
In reply to Rafael J. Wysocki
Quoted 5 lines · Rafael J. Wysocki
Quoted 1 line · Thomas Gleixner

Also which clocksource is used ?

hpet

Hmm, there is only one hpet related commit sin .34: 30a564be9d and I can hardly see how this should be related.

Thanks,

tglx

#10 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 5 lines · Rafael J. Wysocki
Quoted 1 line · Thomas Gleixner

Also which clocksource is used ?

hpet

Hmm, there is only one hpet related commit sin .34: 30a564be9d and I can hardly see how this should be related.

Does the problem persist if you disable HPET on the kernel command line ?

Thanks,

tglx

#11 lore raw
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Thomas Gleixner
Quoted 2 lines · Rafael J. Wysocki

On Saturday 22 May 2010, Thomas Gleixner wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Also which clocksource is used ?

hpet

Hmm, there is only one hpet related commit sin .34: 30a564be9d and I can hardly see how this should be related.

Does the problem persist if you disable HPET on the kernel command line ?

I didn't try that, but I bisected it in the meantime which lead to:

commit 64ce4c2f5252f25798117fa80a027993163d6d84

Author: John Stultz <[email protected]>
Date:   Thu Mar 11 14:04:47 2010 -0800

time: Clean up warp_clock()

warp_clock() currently accesses timekeeping internal state directly, which is unnecessary. Convert it to use the proper timekeeping interfaces.

So I don't think it's an hpet issue. :-)

I'm now going to revert that commit and see what happens.

Thanks,
Rafael

#12 lore raw
Quoted 26 lines · Rafael J. Wysocki
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Thomas Gleixner
Quoted 2 lines · Rafael J. Wysocki

On Saturday 22 May 2010, Thomas Gleixner wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Also which clocksource is used ?

hpet

Hmm, there is only one hpet related commit sin .34: 30a564be9d and I can hardly see how this should be related.

Does the problem persist if you disable HPET on the kernel command line ?

I didn't try that, but I bisected it in the meantime which lead to:

commit 64ce4c2f5252f25798117fa80a027993163d6d84

Author: John Stultz <[email protected]>
Date:   Thu Mar 11 14:04:47 2010 -0800

time: Clean up warp_clock()

warp_clock() currently accesses timekeeping internal state directly, which is unnecessary. Convert it to use the proper timekeeping interfaces.

Quoted 8 lines

So I don't think it's an hpet issue. :-)

I'm now going to revert that commit and see what happens.

After reverting commit 64ce4c2f above things work again.

To be precise, I reverted both commit 64ce4c2f and commit 6a867a3 (time:
Remove xtime_cache), but since the symptoms continued to apprear after reverting the latter alone, it's quite clear that commit 64ce4c2f breaks things on this box.

Thanks,
Rafael

#13 lore raw
Quoted 6 lines · Rafael J. Wysocki

After reverting commit 64ce4c2f above things work again.

To be precise, I reverted both commit 64ce4c2f and commit 6a867a3 (time:
Remove xtime_cache), but since the symptoms continued to apprear after reverting the latter alone, it's quite clear that commit 64ce4c2f breaks things on this box.

I assume the cmos clock of this machine is not on UTC, right ? Does the patch below fix the issue ?

@John: Can you please check the other users of timespec_add_safe() in timekeeping as well ?

Thanks,

tglx

---------->
Subject: timekeeping: Fix timezone update
From: Thomas Gleixner <[email protected]>
Date: Sun, 23 May 2010 08:14:45 +0200

commit 64ce4c2f (time: Clean up warp_clock()) breaks the timezone update in a very subtle way. To avoid the direct access to timekeeping internals it adds the timezone delta to the current time with timespec_add_safe(). This works nicely when the timezone delta is > 0. If timezone delta is < 0 then the wrap check in timespec_add_safe() triggers and timespec_add_safe() returns TIME_MAX and screws up timekeeping completely.

This is not surprising as the comment above timespec_add_safe() says:
It's assumed that both values are valid (>= 0)

The function was created to avoid overflow issues when adding the select() timeout to current time, where the above applies.

Add the timezone seconds adjustment directly.

---
 kernel/time.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/time.c +4 -4
Index: linux-2.6/kernel/time.c
===================================================================
@@ -132,10 +132,10 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
  */
 static inline void warp_clock(void)
 {
-	struct timespec delta, adjust;
-	delta.tv_sec = sys_tz.tz_minuteswest * 60;
-	delta.tv_nsec = 0;
-	adjust = timespec_add_safe(current_kernel_time(), delta);
+	struct timespec adjust;
+
+	adjust = current_kernel_time();
+	adjust.tv_sec += sys_tz.tz_minuteswest * 60;
 	do_settimeofday(&adjust);
 }
 
#14 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 6 lines · Rafael J. Wysocki

After reverting commit 64ce4c2f above things work again.

To be precise, I reverted both commit 64ce4c2f and commit 6a867a3 (time:
Remove xtime_cache), but since the symptoms continued to apprear after reverting the latter alone, it's quite clear that commit 64ce4c2f breaks things on this box.

I assume the cmos clock of this machine is not on UTC, right ?

Yup.

Quoted 1 line

Does the patch below fix the issue ?

Yes, it does, thanks!

Quoted 42 lines

@John: Can you please check the other users of timespec_add_safe() in timekeeping as well ?

Thanks,

tglx

---------->
Subject: timekeeping: Fix timezone update
From: Thomas Gleixner <[email protected]>
Date: Sun, 23 May 2010 08:14:45 +0200

commit 64ce4c2f (time: Clean up warp_clock()) breaks the timezone update in a very subtle way. To avoid the direct access to timekeeping internals it adds the timezone delta to the current time with timespec_add_safe(). This works nicely when the timezone delta is > 0. If timezone delta is < 0 then the wrap check in timespec_add_safe() triggers and timespec_add_safe() returns TIME_MAX and screws up timekeeping completely.

This is not surprising as the comment above timespec_add_safe() says:
It's assumed that both values are valid (>= 0)

The function was created to avoid overflow issues when adding the select() timeout to current time, where the above applies.

Add the timezone seconds adjustment directly.

---
 kernel/time.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/kernel/time.c
===================================================================

kernel/time.c +0 -0
@@ -132,10 +132,10 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
  */
 static inline void warp_clock(void)
 {

kernel/time.c SYSCALL_DEFINE2(gettimeofday, struct tim · line 140

Quoted 10 lines
kernel/time.c +4 -4
-	struct timespec delta, adjust;
-	delta.tv_sec = sys_tz.tz_minuteswest * 60;
-	delta.tv_nsec = 0;
-	adjust = timespec_add_safe(current_kernel_time(), delta);
+	struct timespec adjust;
+
+	adjust = current_kernel_time();
+	adjust.tv_sec += sys_tz.tz_minuteswest * 60;
 	do_settimeofday(&adjust);
 }

Rafael

Acked-by
#15 lore raw
In reply to Thomas Gleixner
Quoted 10 lines · Thomas Gleixner
Quoted 6 lines · Rafael J. Wysocki

After reverting commit 64ce4c2f above things work again.

To be precise, I reverted both commit 64ce4c2f and commit 6a867a3 (time:
Remove xtime_cache), but since the symptoms continued to apprear after reverting the latter alone, it's quite clear that commit 64ce4c2f breaks things on this box.

I assume the cmos clock of this machine is not on UTC, right ? Does the patch below fix the issue ?

Oof. Thanks for catching that.

Quoted 2 lines

@John: Can you please check the other users of timespec_add_safe() in timekeeping as well ?

So monotonic_to_bootbased() looks ok, as total_sleep_time should always be positive.

timekeeping_resume() also looks ok, since it we make sure the delta between the resume time and the suspend time is positive.

That said, it may be worth open coding the:

	set_normalized_timespec(&ret, a.tv_sec + b.tv_sec, 
				a.tv_nsec + b.tv_nsec);

just so we don't have similar mix ups in the future, since timespec_add_safe is just such a reassuring and comforting name :)

Quoted 20 lines

Thanks,

tglx

---------->
Subject: timekeeping: Fix timezone update
From: Thomas Gleixner <[email protected]>
Date: Sun, 23 May 2010 08:14:45 +0200

commit 64ce4c2f (time: Clean up warp_clock()) breaks the timezone update in a very subtle way. To avoid the direct access to timekeeping internals it adds the timezone delta to the current time with timespec_add_safe(). This works nicely when the timezone delta is > 0. If timezone delta is < 0 then the wrap check in timespec_add_safe() triggers and timespec_add_safe() returns TIME_MAX and screws up timekeeping completely.

This is not surprising as the comment above timespec_add_safe() says:
It's assumed that both values are valid (>= 0)

Quoted 7 lines

The function was created to avoid overflow issues when adding the select() timeout to current time, where the above applies.

Add the timezone seconds adjustment directly.

Quoted 23 lines
---
 kernel/time.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/kernel/time.c
===================================================================

kernel/time.c +4 -4
@@ -132,10 +132,10 @@ SYSCALL_DEFINE2(gettimeofday, struct tim
  */
 static inline void warp_clock(void)
 {
-	struct timespec delta, adjust;
-	delta.tv_sec = sys_tz.tz_minuteswest * 60;
-	delta.tv_nsec = 0;
-	adjust = timespec_add_safe(current_kernel_time(), delta);
+	struct timespec adjust;
+
+	adjust = current_kernel_time();
+	adjust.tv_sec += sys_tz.tz_minuteswest * 60;
 	do_settimeofday(&adjust);
 }