Re: compat_sys_times() bogus until jiffies >= 0.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Michael Kerrisk
Date: Thursday, December 20, 2007 - 4:36 am

David, Andrew, Paul,

A late coda to this thread, but I'll just note some changes I'm making to
the man page (which I'd like you to review -- please see below), and note a
few other points.

Andrew, you asked about what happens for x86 with the -1 to -4095 return
for other syscalls.  At least two other syscalls suffer the same problem.
From the fcntl(2) man page:

   BUGS
       A limitation of the Linux system call conventions on some
       architectures  (notably  x86)  means that if a (negative)
       process group ID to be returned by F_GETOWN falls in  the
       range  -1  to  -4095,  then  the  return value is wrongly
       interpreted by glibc as an error in the system call; that
       is,  the  return  value  of fcntl() will be -1, and errno
       will contain the (positive) process group ID.

Some testing just now shows me that lseek() on /dev/mem suffers similar
problems when seeking to bytes 0xfffff001 through to 0xffffffff.

Ulrich Drepper wrote:

Did I miss anything?  Is anyone actually working on a solution along these
lines?

In the meantime, for man-pages-2.74, I've reworked the description of the
return value:

   RETURN VALUE
       times() returns the  number  of  clock  ticks  that  have
       elapsed since an arbitrary point in the past.  The return
       value may overflow the possible range  of  type  clock_t.
       On  error,  (clock_t) -1  is  returned,  and errno is set
       appropriately.

I moved the Linux specific details of the return value to NOTES, and added
a warning about relying on those details:

   NOTES
       ...

       On Linux, the "arbitrary point in the  past"  from  which
       the return value of times() is measured has varied across
       kernel versions.  On Linux 2.4 and earlier this point  is
       the  moment the system was booted.  Since Linux 2.6, this
       point is (2^32/HZ) - 300 (i.e., about 429  million)  sec-
       onds  before  system  boot time.  This variability across
       kernel versions (and across Unix  implementations),  com-
       bined  with the fact that the returned value may overflow
       the range of clock_t, means that a  portable  application
       would  be  wise  to  avoid  using this value.  To measure
       changes in elapsed time, use gettimeofday(2) instead.

Under BUGS I added:

   BUGS
       A limitation of the Linux system call conventions on some
       architectures (notably x86) means that on Linux 2.6 there
       is  a small time window (41 seconds) soon after boot when
       times(2) can return -1, falsely indicating that an  error
       occurred.   The  same  problem  can occur when the return
       value wraps passed the maximum value that can  be  stored
       in clockid_t.

Look okay to you folks?

Cheers,

Michael
-- 
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug?  Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
compat_sys_times() bogus until jiffies >= 0., David Brown, (Wed Nov 7, 3:47 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 4:28 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 5:18 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Wed Nov 7, 5:50 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andreas Schwab, (Wed Nov 7, 5:54 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 6:13 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 6:17 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Paul Mackerras, (Wed Nov 7, 6:53 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Wed Nov 7, 7:09 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 8:07 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Wed Nov 7, 8:13 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Paul Mackerras, (Wed Nov 7, 9:59 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Paul Mackerras, (Wed Nov 7, 10:15 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 10:20 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Paul Mackerras, (Wed Nov 7, 10:36 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Brown, (Wed Nov 7, 11:00 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Wed Nov 7, 11:12 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Wed Nov 7, 11:22 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Wed Nov 7, 11:24 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Wed Nov 7, 11:25 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andrew Morton, (Thu Nov 8, 12:09 am)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Thu Nov 8, 12:14 am)
Re: compat_sys_times() bogus until jiffies >= 0., Paul Mackerras, (Thu Nov 8, 1:53 am)
Re: compat_sys_times() bogus until jiffies >= 0., Andreas Schwab, (Thu Nov 8, 3:20 am)
Re: compat_sys_times() bogus until jiffies >= 0., Chris Friesen, (Thu Nov 8, 7:42 am)
Re: compat_sys_times() bogus until jiffies >= 0., Denys Vlasenko, (Thu Nov 8, 12:25 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Denys Vlasenko, (Thu Nov 8, 12:27 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Ulrich Drepper, (Fri Nov 9, 11:20 am)
Re: compat_sys_times() bogus until jiffies >= 0., Michael Kerrisk, (Thu Dec 20, 4:36 am)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Thu Dec 20, 4:51 am)
Re: compat_sys_times() bogus until jiffies >= 0., Andi Kleen, (Fri Dec 21, 5:42 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Fri Dec 21, 6:41 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andi Kleen, (Fri Dec 21, 6:49 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andi Kleen, (Fri Dec 21, 6:53 pm)
Re: compat_sys_times() bogus until jiffies >= 0., David Miller, (Fri Dec 21, 9:36 pm)
Re: compat_sys_times() bogus until jiffies >= 0., Andi Kleen, (Sat Dec 22, 5:47 am)