From owner-freebsd-bugs Mon Jan 24 14:20:56 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 33086152E2 for ; Mon, 24 Jan 2000 14:20:52 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id OAA66513; Mon, 24 Jan 2000 14:10:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Date: Mon, 24 Jan 2000 14:10:02 -0800 (PST) Message-Id: <200001242210.OAA66513@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Peter Jeremy Subject: Re: kern/13644 Reply-To: Peter Jeremy Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/13644; it has been noted by GNATS. From: Peter Jeremy To: stable@FreeBSD.org, FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: Re: kern/13644 Date: Tue, 25 Jan 2000 08:58:36 +1100 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-bugs" in the body of the message