kern/83192:
Bruce Evans
bde at zeta.org.au
Sun Jul 10 01:05:03 GMT 2005
On Sat, 9 Jul 2005, Maciej Zawadzinski wrote:
>> Fix:
> --- kern_synch.c.orig Fri Jul 8 22:07:20 2005
> +++ kern_synch.c Fri Jul 8 22:07:47 2005
> @@ -322,7 +322,7 @@
> * over max, arrange to kill the process in ast().
> */
> if (p->p_cpulimit != RLIM_INFINITY &&
> - p->p_runtime.sec > p->p_cpulimit) {
> + p->p_runtime.sec >= p->p_cpulimit) {
> p->p_sflag |= PS_XCPU;
> td->td_flags |= TDF_ASTPENDING;
> }
This seems to be correct, except it changes the code back to not matching
the comment. p->p_cpulimit a max, not a limit despite its name, since
it is an alias for the corresponding rlimit which is also a max, not a
limit despite _its_ name. Doing something when a max is reached but
not exceeded is normally wrong, but here we know that when the max in
seconds is reached, the max in a significantly higher resolution is
exceeded.
The bug was smaller (< 1 usec, thus not observable) when it was
originally implemented in rev.1.58 of kern_synch.c, since p_cpulimit
was in microseconds then. Then the comparision of seconds still used
">=", but was only reached if the comparison of microseconds gave ">".
Related bug: sys/resource.h says that RLIMIT_CPU gives the "cpu time in
milliseconds", but it actually gives the _maximum_ CPU time in _seconds_.
The man page and POSIX agree that it is in seconds but don't say if the
comparison must or can be done at a higher resolution.
Bruce
More information about the freebsd-bugs
mailing list