Re: testing/pre-7 and do_poll()

Adam Heath (doogie@debian.org)
Mon, 11 Jan 1999 14:20:08 -0600 (CST)


On Sun, 10 Jan 1999, Chip Salzenberg wrote:

> According to Linus Torvalds:
> > There's a "pre-7.gz" on ftp.kernel.org in testing, anybody interested?
>
> Got it, like it -- *except* the fix for overflow in do_poll() is a
> little bit off. Quoting testing/pre-7:
>
> if (timeout) {
> /* Carefula about overflow in the intermediate values */
> if ((unsigned long) timeout < MAX_SCHEDULE_TIMEOUT / HZ)
> timeout = (timeout*HZ+999)/1000+1;
> else /* Negative or overflow */
> timeout = MAX_SCHEDULE_TIMEOUT;
> }
>
> However, the maximum legal millisecond timeout isn't (as shown)
> MAX_SCHEDULE_TIMEOUT/HZ, but rather MAX_SCHEDULE_TIMEOUT/(1000/HZ).
> So this code will turn some large timeouts into MAX_SCHEDULE_TIMEOUT
> unnecessarily.

A/(B/C) = A * (C / B) = A / B * C (done this way to eliminate overflow)

MAX_SCHEDULE_TIMEOUT / 1000 * HZ

Adam

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