lkml.org 
[lkml]   [2006]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] fix bad macro param in timer.c (was: kernel/timer.c: next_timer_interrupt() strange/buggy(?) code (2.6.18-rc1-mm2))
From
Date
On Mon, 2006-07-17 at 20:53 +0200, Andreas Mohr wrote:
> Hi all,
>
> next_timer_interrupt() contains the following gem:
>
> /* Check tv2-tv5. */
> varray[0] = &base->tv2;
> varray[1] = &base->tv3;
> varray[2] = &base->tv4;
> varray[3] = &base->tv5;
> for (i = 0; i < 4; i++) {
> j = INDEX(i);
> do {
> if (list_empty(varray[i]->vec + j)) {
> j = (j + 1) & TVN_MASK;
> continue;
> }
> list_for_each_entry(nte, varray[i]->vec + j, entry)
> if (time_before(nte->expires, expires))
> expires = nte->expires;
> if (j < (INDEX(i)) && i < 3)

Looking at what INDEX is defined to be:

#define INDEX(N) (base->timer_jiffies >> (TVR_BITS + N * TVN_BITS)) & TVN_MASK

> list = varray[i + 1]->vec + (INDEX(i + 1));

And this INDEX(i+1) is now a ... (TVR_BITS + i + 1 * TVN_BITS)) ...
This doesn't quite look like it suppose to be that way. Probably having
some funny results because of it.

Here's the patch to clean up the macro used to find the index of the
timer vector.

This is definitely a bug fix and should go into 2.6.18

-- Steve

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Index: linux-2.6.18-rc2/kernel/timer.c
===================================================================
--- linux-2.6.18-rc2.orig/kernel/timer.c 2006-07-17 21:34:08.000000000 -0400
+++ linux-2.6.18-rc2/kernel/timer.c 2006-07-17 21:34:22.000000000 -0400
@@ -408,7 +408,7 @@ static int cascade(tvec_base_t *base, tv
* This function cascades all vectors and executes all expired timer
* vectors.
*/
-#define INDEX(N) (base->timer_jiffies >> (TVR_BITS + N * TVN_BITS)) & TVN_MASK
+#define INDEX(N) (base->timer_jiffies >> (TVR_BITS + (N) * TVN_BITS)) & TVN_MASK

static inline void __run_timers(tvec_base_t *base)
{

-
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: 2006-07-18 03:51    [W:0.199 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site