Bug 108488 - Millisecond timer resolution on ia64
Millisecond timer resolution on ia64
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: kernel (Show other bugs)
3.0
ia64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jason Baron
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-10-29 18:21 EST by Arun Sharma
Modified: 2013-03-06 00:56 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-12-02 21:06:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Arun Sharma 2003-10-29 18:21:29 EST
Description of problem:

gettimeofday() on linux-ia64 tries to provide a microsecond resolution on base
kernels (2.4, 2.6). However with RHEL3 release kernel, the resolution is only
milliseconds.

Version-Release number of selected component (if applicable):

2.4.21-4.EL

How reproducible:

Run this program:

#include <stdio.h>
#include <sys/time.h>

int main() {
  struct timeval tv1, tv2;

  gettimeofday( & tv1, 0 );
  gettimeofday( & tv2, 0 );
  while (tv2.tv_usec - tv1.tv_usec == 0) {
    gettimeofday( & tv2, 0 );
  }
  printf("Minimum measurable time: %d seconds, %d usecs\n",
         tv2.tv_sec - tv1.tv_sec,
         tv2.tv_usec - tv1.tv_usec);
}

The problem seems to be coming from a machine independent patch being maintained
 in the linux-ia64-2.4, accessible here:

http://lia64.bkbits.net:8080/linux-ia64-2.4/diffs/kernel/timer.c@1.8?nav=index.html|src/|src/kernel|hist/kernel/timer.c

This patch is missing from RHEL3. Because last_time_offset doesn't reset to zero
after a timer tick, it's monotonically increasing. gettimeofday always returns
xtime + last_time_offset. As a result the return value of gettimeofday doesn't
change between timer ticks.
Comment 1 Arun Sharma 2003-11-03 14:15:06 EST
Apart from the timer resolution issues, this bug could also result in
unsynchronized clocks on a cluster of NTP synchronized machines.
Comment 2 Jason Baron 2003-11-13 11:22:11 EST
ok, here is the patch i'm proposing for RHEL 3. i haven't included the
timer bit in sys_nanosleep, b/c i don't consider that essetial.


--- linux-2.4.21/kernel/timer.c.bak     2003-11-12 14:44:56.000000000
-0500
+++ linux-2.4.21/kernel/timer.c 2003-11-12 14:45:54.000000000 -0500
@@ -1206,7 +1206,7 @@ asmlinkage long sys_nanosleep(struct tim
        return 0;
 }
 
-
+unsigned long last_time_offset;
 
 static inline void update_times(void)
 {
@@ -1226,6 +1226,7 @@ static inline void update_times(void)
                update_wall_time(ticks);
        }
        vxtime_unlock();
+       last_time_offset = 0;
        br_write_unlock_irq(BR_XTIME_LOCK);
        calc_load(ticks);
 }
--- linux-2.4.21/arch/ia64/kernel/time.c.bak    2003-11-12
14:44:33.000000000 -0500
+++ linux-2.4.21/arch/ia64/kernel/time.c        2003-11-12
14:44:44.000000000 -0500
@@ -27,7 +27,7 @@
 
 extern unsigned long wall_jiffies;
 
-unsigned long last_time_offset;
+extern unsigned long last_time_offset;
 #ifdef CONFIG_IA64_DEBUG_IRQ
 
 unsigned long last_cli_ip;
Comment 3 Jason Baron 2003-11-13 11:48:43 EST
ok, i'm proposing just the first part of this patch for RHEL 3, as the
remainder is not critical, imo:

--- linux-2.4.21/kernel/timer.c.bak     2003-11-12 14:44:56.000000000
-0500
+++ linux-2.4.21/kernel/timer.c 2003-11-12 14:45:54.000000000 -0500
@@ -1206,7 +1206,7 @@ asmlinkage long sys_nanosleep(struct tim
        return 0;
 }
 
-
+unsigned long last_time_offset;
 
 static inline void update_times(void)
 {
@@ -1226,6 +1226,7 @@ static inline void update_times(void)
                update_wall_time(ticks);
        }
        vxtime_unlock();
+       last_time_offset = 0;
        br_write_unlock_irq(BR_XTIME_LOCK);
        calc_load(ticks);
 }
--- linux-2.4.21/arch/ia64/kernel/time.c.bak    2003-11-12
14:44:33.000000000 -0500
+++ linux-2.4.21/arch/ia64/kernel/time.c        2003-11-12
14:44:44.000000000 -0500
@@ -27,7 +27,7 @@
 
 extern unsigned long wall_jiffies;
 
-unsigned long last_time_offset;
+extern unsigned long last_time_offset;
 #ifdef CONFIG_IA64_DEBUG_IRQ
 
 unsigned long last_cli_ip;
Comment 4 Arun Sharma 2003-11-13 18:14:37 EST
The patch looks good to me.
Comment 5 Ernie Petrides 2004-01-09 20:30:10 EST
A variant of this fix was committed to RHEL 3 U1 on
14-Nov-2003 (kernel versions 2.4.21-4.15.EL and later).
Comment 6 Ernie Petrides 2004-12-02 21:06:52 EST
An errata has been issued which should help the problem 
described in this bug report. This report is therefore being 
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, 
please follow the link below. You may reopen this bug report 
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2004-017.html

Note You need to log in before you can comment on or make changes to this bug.