Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Jul 2005 11:05:00 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Maciej Zawadzinski <mzawadzinski@gmail.com>
Cc:        freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org
Subject:   Re: kern/83192: 
Message-ID:  <20050710104715.M1354@epsplex.bde.org>
In-Reply-To: <200507091628.j69GS7rD070292@www.freebsd.org>
References:  <200507091628.j69GS7rD070292@www.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050710104715.M1354>