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

From: David Brown
Date: Thu Nov 08 2007 - 01:00:41 EST


On Wed, Nov 07, 2007 at 03:28:33PM -0800, Andrew Morton wrote:
On Wed, 7 Nov 2007 14:47:22 -0800 David Brown <lkml@xxxxxxxxxx> wrote:

will return '-1' to user space and set the negated clock_t value to errno.

At minimum, perhaps it should return a sane errno value.

RETURN VALUE
times() returns the number of clock ticks that have elapsed since an
arbitrary point in the past. For 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) seconds before system boot
time. The return value may overflow the possible range of type
clock_t. On error, (clock_t) -1 is returned, and errno is set appro-
priately.

The strange -1 behavior is enshrined in history. I think a better answer
is to tell people to use getrusage() if they want a return result without
this problem.

Adding INITIAL_JIFFIES will fix the case where an embedded system is booted
up to run a test and then shut down, and the mask, although it causes
discontinuities periodically at least moves them away from the early boot.

INITIAL_JIFFIES was a good idea, but it is probably best to keep it inside
of the kernel.

David Brown
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/