[PATCH] rcu_do_batch: make ->qlen decrement irq safe
authorOleg Nesterov <oleg@tv-sign.ru>
Wed, 13 Sep 2006 03:35:55 +0000 (20:35 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 13 Sep 2006 14:32:14 +0000 (07:32 -0700)
rcu_do_batch() decrements rdp->qlen with irqs enabled.  This is not good,
it can also be modified by call_rcu() from interrupt.

Decrement ->qlen once with irqs disabled, after a main loop.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Dipankar Sarma <dipankar@in.ibm.com>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/rcupdate.c

index 436ab35f6fa74821b7f40d1625cce47ccf674121..523e46483b99e6b3bbee6376c7a4232dc71adca4 100644 (file)
@@ -241,12 +241,16 @@ static void rcu_do_batch(struct rcu_data *rdp)
                next = rdp->donelist = list->next;
                list->func(list);
                list = next;
-               rdp->qlen--;
                if (++count >= rdp->blimit)
                        break;
        }
+
+       local_irq_disable();
+       rdp->qlen -= count;
+       local_irq_enable();
        if (rdp->blimit == INT_MAX && rdp->qlen <= qlowmark)
                rdp->blimit = blimit;
+
        if (!rdp->donelist)
                rdp->donetail = &rdp->donelist;
        else