Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 475477

Summary: Time(2) Off-by-one after Settimeofday(2)
Product: Red Hat Enterprise Linux 5 Reporter: Qian Cai <qcai>
Component: kernelAssignee: Red Hat Kernel Manager <kernel-mgr>
Status: CLOSED CANTFIX QA Contact: Martin Jenner <mjenner>
Severity: medium Docs Contact:
Priority: low    
Version: 5.2   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-12-11 18:11:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer none

Description Qian Cai 2008-12-09 13:06:47 UTC
Description of problem:
One of LTP (Linux Testing Project) test case was doing the following something similar to the following,

gettimeofday()
settimeofday()
time()

The result that time() returned was one less that we set.

# ./time
curr_time = 1228827598
pres_time = 1228827607
Failed.

If we changed the above code to

gettimeofday()
settimeofday()
gettimeofday()

It worked fine.

# ./time
curr_time = 1228827598
pres_time = 1228827608

The following is the list of known affected machines and their timer information,
sun-v40z-01.rhts.bos.redhat.com
...
Detected 20.834 MHz APIC timer.
time.c: Using 3.579545 MHz WALL PM GTOD PIT/TSC timer.
...

x86-64-5s-m1.lab.bos.redhat.com
...
Detected 12.453 MHz APIC timer.
SMP alternatives: switching to SMP code
Booting processor 1/8 APIC 0x1
...

hp-dl785g5-01.rhts.bos.redhat.com
...
Detected 12.500 MHz APIC timer.
...

hp-dl360g4-01.rhts.bos.redhat.com
...
Detected 12.500 MHz APIC timer
...

dell-pe2900-01.rhts.bos.redhat.com

I have never seen it failed on any IA-32 machine.

Version-Release number of selected component (if applicable):
kernel-2.6.18-92.el5
kernel-2.6.18-125.el5

How reproducible:
always

Additional info:
Ntpd had been stopped.

Comment 1 Qian Cai 2008-12-09 13:08:45 UTC
Created attachment 326300 [details]
Reproducer

Comment 2 Prarit Bhargava 2008-12-11 18:11:26 UTC
CANTFIX -- set/gettimeofday & time are known not to keep consistent time against one another.  Attempting to make them consistent results in a unacceptable 2200% performance hit on the time() syscall.

See BZ 461184.

Comment 3 Qian Cai 2008-12-12 09:30:12 UTC
Prait, someone in LTP mailing list pointed out that this upstream commit fixed the test failure.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=9a055117d3d9cb562f83f8d4cd88772761f4cab0

I cannot apply this patch to RHEL 5 kernel though because there is no timekeeping.c. The discussion in LTP is here,
http://article.gmane.org/gmane.linux.ltp/6730