lkml.org 
[lkml]   [2003]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH] fix nanosleep() granularity bumps
    On Tue, 18 Mar 2003, Tim Schmielau wrote:

    > Please don't yet forward to Linus. After twisting my little brain a bit
    > further, I see that the patch is still wrong if the lowest TVR_BITS of
    > INITIAL_JIFFIES happen to be zero while others are not.

    OK, this one looks ugly but should be correct, even in the case of a
    partial timer cascade on the first timer interrupt:


    --- linux-2.5.65/kernel/timer.c.orig Tue Mar 18 13:02:39 2003
    +++ linux-2.5.65/kernel/timer.c Tue Mar 18 13:41:53 2003
    @@ -1182,11 +1182,23 @@
    INIT_LIST_HEAD(base->tv1.vec + j);

    base->timer_jiffies = INITIAL_JIFFIES;
    - base->tv1.index = INITIAL_JIFFIES & TVR_MASK;
    - base->tv2.index = (INITIAL_JIFFIES >> TVR_BITS) & TVN_MASK;
    - base->tv3.index = (INITIAL_JIFFIES >> (TVR_BITS+TVN_BITS)) & TVN_MASK;
    - base->tv4.index = (INITIAL_JIFFIES >> (TVR_BITS+2*TVN_BITS)) & TVN_MASK;
    - base->tv5.index = (INITIAL_JIFFIES >> (TVR_BITS+3*TVN_BITS)) & TVN_MASK;
    + /*
    + * The tv indices are always larger by one compared to the
    + * respective parts of timer_jiffies. If all lower indices are
    + * zero at initialisation, this is achieved by an (otherwise
    + * unneccessary) invocation of the timer cascade on the first
    + * timer interrupt. If not, we need to take it into account
    + * here:
    + */
    + j = (base->tv1.index = INITIAL_JIFFIES & TVR_MASK) !=0;
    + j |= (base->tv2.index = ((INITIAL_JIFFIES >> TVR_BITS) + j)
    + & TVN_MASK) !=0;
    + j |= (base->tv3.index = ((INITIAL_JIFFIES >> (TVR_BITS+TVN_BITS)) + j)
    + & TVN_MASK) !=0;
    + j |= (base->tv4.index = ((INITIAL_JIFFIES >> (TVR_BITS+2*TVN_BITS)) + j)
    + & TVN_MASK) !=0;
    + base->tv5.index = ((INITIAL_JIFFIES >> (TVR_BITS+3*TVN_BITS)) + j)
    + & TVN_MASK;
    }

    static int __devinit timer_cpu_notify(struct notifier_block *self,
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:34    [W:3.931 / U:1.504 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site