Skip to contentSkip to conversation

2.5.64 and jiffies wrap

PATCH Jens Axboe 2 participants 3 messages Mar 7, 2003 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

Hi,

The patch doesn't look right, why is INITIAL_JIFFIES being cast to unsigned int? This breaks x86_64 at least.

arch/x86_64/kernel/time.c renamed from opt/kernel/linux-2.5.64/arch/x86_64/kernel/time.c +1 -1
@@ -30,7 +30,7 @@
 #include <asm/apic.h>
 #endif
 
-u64 jiffies_64;
+u64 jiffies_64 = INITIAL_JIFFIES;
 
 extern int using_apic_timer;
 
include/linux/time.h renamed from opt/kernel/linux-2.5.64/include/linux/time.h +1 -1
@@ -31,7 +31,7 @@
  * Have the 32 bit jiffies value wrap 5 minutes after boot
  * so jiffies wrap bugs show up earlier.
  */
-#define INITIAL_JIFFIES ((unsigned int) (-300*HZ))
+#define INITIAL_JIFFIES ((unsigned long) (-300*HZ))
 
 /*
  * Change timeval to jiffies, trying to avoid the
Signature · 1 line
Jens Axboe
#1 lore raw
Quoted 8 lines · Jens Axboe

Hi,

The patch doesn't look right, why is INITIAL_JIFFIES being cast to unsigned int? This breaks x86_64 at least.

...
-#define INITIAL_JIFFIES ((unsigned int) (-300*HZ))

This sets the initial jiffies value to 0x00000000fffb6c20, which can trigger 32-bit wraparound bugs: if some random jiffy counter wraps from 0x00000000ffffffff to 0x0000000000000000 then things fail.

davem was bitten by at least one such bug in the qlogicfc driver. It would have caused 64-bit machines to fail after 49 days.

It turns out that it is more valuable to test for this than to test for 64-bit wraparound bugs.

author
#2 lore raw
Quoted 14 lines · Andrew Morton
Quoted 8 lines · Jens Axboe

Hi,

The patch doesn't look right, why is INITIAL_JIFFIES being cast to unsigned int? This breaks x86_64 at least.

...
-#define INITIAL_JIFFIES ((unsigned int) (-300*HZ))

This sets the initial jiffies value to 0x00000000fffb6c20, which can trigger 32-bit wraparound bugs: if some random jiffy counter wraps from 0x00000000ffffffff to 0x0000000000000000 then things fail.

Quoted 5 lines

davem was bitten by at least one such bug in the qlogicfc driver. It would have caused 64-bit machines to fail after 49 days.

It turns out that it is more valuable to test for this than to test for 64-bit wraparound bugs.

Ok makes sense, I thought the point was just to test for jiffies wrap. Anyways, the patch breaks boot on x86_64 here.

Signature · 1 line
Jens Axboe