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 553407

Summary: nanosleep() is unstable on xen kernel and ntpd with -x option
Product: Red Hat Enterprise Linux 5 Reporter: Marc Milgram <mmilgram>
Component: kernel-xenAssignee: Paolo Bonzini <pbonzini>
Status: CLOSED ERRATA QA Contact: Boris Ranto <branto>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: branto, drjones, jlv, mjenner, pbonzini, xen-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-13 20:58:41 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:
Bug Depends On:    
Bug Blocks: 514489    
Attachments:
Description Flags
reproducer.sh none

Description Marc Milgram 2010-01-07 20:11:29 UTC
Description of problem:
nanosleep() which is used like usleep command is unstable.
Even if nanosleep() doesn't sleep for specific time, it returns 0 (successfully).

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

How reproducible:
Every time.

Steps to Reproduce:
1. Boot xen kernel.
2. Configure /etc/ntp.conf and /etc/sysconfig/ntpd.

    --- ntp.conf
    server xxx.xxx.xxx.xxx
    ---
    *Set 1 NTP server.

    --- ntpd
    OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -x"
    ---
    *Add -x option.
3. Start ntpd service.
4. Set the date forward about 10 minutes.

    # date
    Tue Sep 29 13:16:07 JST 2009
    # date 09291326
    Tue Sep 29 13:26:00 JST 2009

5. Wait a few moments for sync NTP server (Check ntpq -p command result).
6. Execute usleep command.

    --- test.sh
    for i in $(seq 1 10)
      do
        date +%H:%M:%S.%N
        usleep 200000
    done

    # ./test.sh | awk 'BEGIN{FS=":"}{print "60*60*"$1"+60*"$2"+"$3}' | bc |\
    xargs echo | awk '{for(i = 1; i < NF; i++){print $(i+1)"-"$i}}' | bc

Actual results:
 # ./test.sh | awk 'BEGIN{FS=":"}{print "60*60*"$1"+60*"$2"+"$3}' | bc |\
 xargs echo | awk '{for(i = 1; i < NF; i++){print $(i+1)"-"$i}}' | bc
 0
 0
 0
 0
 0
 0
 0
 0
 0

Expected results:
 # ./test.sh | awk 'BEGIN{FS=":"}{print "60*60*"$1"+60*"$2"+"$3}' | bc |\
 xargs echo | awk '{for(i = 1; i < NF; i++){print $(i+1)"-"$i}}' | bc
 .203355000
 .202815000
 .202857000
 .202972000
 .203597000
 .202734000
 .202808000
 .202839000
 .202948000

Additional info:
 It isn't reproduced on generic kernel environment.
 It isn't reproduced on ntpd without -x option.
 If ntpd stops during reproducing, nanosleep() becomes stable.
 If usleep is given more than 1000000 (1sec.) during reproducing, it looks stable.

Comment 1 Marc Milgram 2010-01-07 20:12:34 UTC
Created attachment 382323 [details]
reproducer.sh

Comment 2 Paolo Bonzini 2010-06-22 18:48:41 UTC
Is this in a guest or in the host?  I cannot reproduce this in the host, and in the guest I cannot even set the date because it is reset immediately to the host's date.

Comment 3 Marc Milgram 2010-06-23 15:10:43 UTC
I was able to reproduce this under DOM 0 (host).

Comment 4 Paolo Bonzini 2010-06-23 18:18:11 UTC
Reproduced now in the host.  I get

nanosleep({0, 20000000}, NULL) = 0

in the strace.

Comment 5 RHEL Program Management 2010-06-30 18:31:01 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 7 bkabele 2010-08-24 10:28:04 UTC
I've reproduced it on rhel5.5-196 and 164 xen kernel.
Rhel6-xen4.0.1-rc6 doesn't heve this bug and SLES11-xen3.3.1 also doesn't have the bug.

Comment 8 Paolo Bonzini 2010-08-25 08:25:31 UTC
Other results:

- works with RHEL hypervisor and SLES kernel
- fails with RHEL kernel and SLES hypervisor

So the bug is (as kind of expected) in the kernel.

Comment 10 Jarod Wilson 2010-08-31 01:17:00 UTC
in kernel-2.6.18-214.el5
You can download this test kernel from http://people.redhat.com/jwilson/el5

Detailed testing feedback is always welcomed.

Comment 15 errata-xmlrpc 2011-01-13 20:58:41 UTC
An advisory 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 therefore 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-2011-0017.html