From owner-freebsd-stable Mon Jan 24 14: 3:29 2000 Delivered-To: freebsd-stable@freebsd.org Received: from alcanet.com.au (mail.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id C96191524A; Mon, 24 Jan 2000 14:03:09 -0800 (PST) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <115243>; Tue, 25 Jan 2000 08:58:41 +1100 Content-return: prohibited From: Peter Jeremy Subject: Re: kern/13644 In-reply-to: <200001241659.LAA34219@misha.cisco.com>; from mi@aldan.algebra.com on Tue, Jan 25, 2000 at 04:02:28AM +1100 To: stable@FreeBSD.org, FreeBSD-gnats-submit@FreeBSD.org Message-Id: <00Jan25.085841est.115243@border.alcanet.com.au> MIME-version: 1.0 X-Mailer: Mutt 1.0i Content-type: text/plain; charset=us-ascii References: <14476.31150.689748.108097@onceler.kcilink.com> <200001241659.LAA34219@misha.cisco.com> Date: Tue, 25 Jan 2000 08:58:36 +1100 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 2000-Jan-25 04:02:28 +1100, Mikhail Teterin wrote: > It does not explain the consistent 9-10 msecs excess. _That_ might be a bug. The select(2) delay is converted from a struct timeval into ticks by tvtohz(). This routine rounds up to the next tick and then adds 1 to the result (in both -stable and -current). The `+1' would seem to be incorrect - even if you want to allow for the current tick, a more reasonable estimate would be 0.5, not 1. Based on a quick check, both Solaris 2.5 and Digital Unix (aka Tru64) 4.0D don't include this one tick over-estimate. I believe one (only) of the following two patches should be applied: Index: kern_clock.c =================================================================== RCS file: /home/CVSROOT/src/sys/kern/kern_clock.c,v retrieving revision 1.104 diff -u -r1.104 kern_clock.c --- kern_clock.c 1999/12/08 10:02:12 1.104 +++ kern_clock.c 2000/01/24 21:51:27 @@ -271,9 +271,8 @@ * If the number of usecs in the whole seconds part of the time * difference fits in a long, then the total number of usecs will * fit in an unsigned long. Compute the total and convert it to - * ticks, rounding up and adding 1 to allow for the current tick - * to expire. Rounding also depends on unsigned long arithmetic - * to avoid overflow. + * ticks, rounding up. Rounding also depends on unsigned long + * arithmetic to avoid overflow. * * Otherwise, if the number of ticks in the whole seconds part of * the time difference fits in a long, then convert the parts to @@ -305,10 +304,10 @@ ticks = 1; } else if (sec <= LONG_MAX / 1000000) ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1)) - / tick + 1; + / tick; else if (sec <= LONG_MAX / hz) ticks = sec * hz - + ((unsigned long)usec + (tick - 1)) / tick + 1; + + ((unsigned long)usec + (tick - 1)) / tick; else ticks = LONG_MAX; if (ticks > INT_MAX) Index: sys_generic.c =================================================================== RCS file: /home/CVSROOT/src/sys/kern/sys_generic.c,v retrieving revision 1.54 diff -u -r1.54 sys_generic.c --- sys_generic.c 2000/01/14 02:53:25 1.54 +++ sys_generic.c 2000/01/24 21:50:26 @@ -687,7 +687,10 @@ ttv = atv; timevalsub(&ttv, &rtv); timo = ttv.tv_sec > 24 * 60 * 60 ? - 24 * 60 * 60 * hz : tvtohz(&ttv); + 24 * 60 * 60 * hz + 1 : tvtohz(&ttv); + /* compensate for over-estimate in tvtohz() */ + if (timo > 1) + timo-- } s = splhigh(); if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { @@ -818,7 +821,10 @@ ttv = atv; timevalsub(&ttv, &rtv); timo = ttv.tv_sec > 24 * 60 * 60 ? - 24 * 60 * 60 * hz : tvtohz(&ttv); + 24 * 60 * 60 * hz + 1 : tvtohz(&ttv); + /* compensate for over-estimate in tvtohz() */ + if (timo > 1) + timo-- } s = splhigh(); if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message