From: Michael Kerrisk <mtk.manpages@googlemail.com>
To: akpm@linux-foundation.org, lkml@davidb.org, paulus@samba.org
Cc: Ulrich Drepper <drepper@redhat.com>,
Chris Friesen <cfriesen@nortel.com>,
Andreas Schwab <schwab@suse.de>,
David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: Re: compat_sys_times() bogus until jiffies >= 0.
Date: Thu, 20 Dec 2007 12:36:52 +0100 [thread overview]
Message-ID: <476A53D4.7040909@gmail.com> (raw)
In-Reply-To: <4734A4D9.3090907@redhat.com>
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:
> Chris Friesen wrote:
>>> A possible remedy is to return the ticks since process start time, which
>>> delays the wrap around much further. POSIX only demands consistency
>>> within the same process.
>> This would be an interesting solution.
>
>> The man page for linux states that the return code is time since system
>> boot, so that could realistically be expected to correlate between
>> different processes.
>
> The Linux man page is documenting existing functionality on top of what
> the standard requires. Programmers should ever only require what the
> standard guarantees.
>
> I am perfectly willing to support a solution where the time is measured
>>from process startup time. The only code using times() I found is
> cross-platform and most likely does not depend on the value returned is
> usable in isolation (only in a difference).
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
next prev parent reply other threads:[~2007-12-20 11:37 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-07 22:47 compat_sys_times() bogus until jiffies >= 0 David Brown
2007-11-07 23:28 ` Andrew Morton
2007-11-08 0:18 ` Andrew Morton
2007-11-08 0:54 ` Andreas Schwab
2007-11-08 1:17 ` Andrew Morton
2007-11-08 1:53 ` Paul Mackerras
2007-11-08 2:09 ` David Miller
2007-11-08 10:20 ` Andreas Schwab
2007-11-08 14:42 ` Chris Friesen
2007-11-09 18:20 ` Ulrich Drepper
2007-12-20 11:36 ` Michael Kerrisk [this message]
2007-12-20 11:51 ` David Miller
2007-12-22 0:42 ` Andi Kleen
2007-12-22 1:41 ` David Miller
2007-12-22 1:45 ` David Miller
2007-12-22 1:53 ` Andi Kleen
2007-12-22 4:36 ` David Miller
2007-12-22 12:47 ` Andi Kleen
2007-12-22 1:49 ` Andi Kleen
2007-11-08 19:25 ` Denys Vlasenko
2007-11-08 3:07 ` Andrew Morton
2007-11-08 3:13 ` David Miller
2007-11-08 5:15 ` Paul Mackerras
2007-11-08 6:24 ` David Miller
2007-11-08 4:59 ` Paul Mackerras
2007-11-08 5:20 ` Andrew Morton
2007-11-08 5:36 ` Paul Mackerras
2007-11-08 6:12 ` Andrew Morton
2007-11-08 6:25 ` David Miller
2007-11-08 7:09 ` Andrew Morton
2007-11-08 7:14 ` David Miller
2007-11-08 8:53 ` Paul Mackerras
2007-11-08 6:22 ` David Miller
2007-11-08 19:27 ` Denys Vlasenko
2007-11-08 0:50 ` David Miller
2007-11-08 1:13 ` Andrew Morton
2007-11-08 6:00 ` David Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=476A53D4.7040909@gmail.com \
--to=mtk.manpages@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=cfriesen@nortel.com \
--cc=davem@davemloft.net \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@davidb.org \
--cc=paulus@samba.org \
--cc=schwab@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox