lkml.org 
[lkml]   [1999]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    Subjecttesting/pre-7 and do_poll()
    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.

    Therefore, I suggest this patch:

    Index: fs/select.c
    *************** asmlinkage int sys_poll(struct pollfd *
    *** 336,346 ****
    goto out;

    ! 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;
    ! }

    err = -ENOMEM;
    --- 336,343 ----
    goto out;

    ! if (timeout < 0)
    ! timeout = MAX_SCHEDULE_TIMEOUT;
    ! else if (timeout)
    ! timeout = ROUND_UP(timeout, 1000/HZ);

    err = -ENOMEM;


    --
    Chip Salzenberg - a.k.a. - <chip@perlsupport.com>
    "When do you work?" "Whenever I'm not busy."

    -
    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/

    \
     
     \ /
      Last update: 2005-03-22 13:49    [W:0.019 / U:0.576 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site