* rcu_do_batch: rcu_data->qlen is not irq safe
@ 2006-09-10 15:08 Oleg Nesterov
2006-09-10 20:58 ` Dipankar Sarma
0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2006-09-10 15:08 UTC (permalink / raw)
To: Paul E. McKenney, Dipankar Sarma, Srivatsa Vaddagiri,
Andrew Morton
Cc: linux-kernel
rcu_do_batch() decrements rdp->qlen with irqs enabled.
This is not good, it can also be modified by call_rcu()
from interrupt.
So, is it worth fixing? The problem is mostly theoretical.
If yes, is it ok to use local_t ? Iirc, the were some
problems with local_t on some arches. Sometimes it is
just atomic_t ...
Otherwise, we can update ->qlen after the main loop,
local_irq_disable();
rdp->qlen -= count;
local_irq_enable();
What dou you think?
Oleg.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: rcu_do_batch: rcu_data->qlen is not irq safe
2006-09-10 15:08 rcu_do_batch: rcu_data->qlen is not irq safe Oleg Nesterov
@ 2006-09-10 20:58 ` Dipankar Sarma
2006-09-10 21:27 ` Oleg Nesterov
2006-09-10 21:32 ` [PATCH] rcu_do_batch: make ->qlen decrement " Oleg Nesterov
0 siblings, 2 replies; 5+ messages in thread
From: Dipankar Sarma @ 2006-09-10 20:58 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Paul E. McKenney, Srivatsa Vaddagiri, Andrew Morton, linux-kernel
On Sun, Sep 10, 2006 at 07:08:20PM +0400, Oleg Nesterov wrote:
> rcu_do_batch() decrements rdp->qlen with irqs enabled.
> This is not good, it can also be modified by call_rcu()
> from interrupt.
>
> So, is it worth fixing? The problem is mostly theoretical.
I think we should fix it even though the problem is theoritical.
> If yes, is it ok to use local_t ? Iirc, the were some
> problems with local_t on some arches. Sometimes it is
> just atomic_t ...
AFAIK, x86 local_t is atomic. Not good.
>
> Otherwise, we can update ->qlen after the main loop,
>
> local_irq_disable();
> rdp->qlen -= count;
> local_irq_enable();
>
> What dou you think?
We should do this.
Thanks
Dipankar
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: rcu_do_batch: rcu_data->qlen is not irq safe
2006-09-10 20:58 ` Dipankar Sarma
@ 2006-09-10 21:27 ` Oleg Nesterov
2006-09-10 21:32 ` [PATCH] rcu_do_batch: make ->qlen decrement " Oleg Nesterov
1 sibling, 0 replies; 5+ messages in thread
From: Oleg Nesterov @ 2006-09-10 21:27 UTC (permalink / raw)
To: Dipankar Sarma
Cc: Paul E. McKenney, Srivatsa Vaddagiri, Andrew Morton, linux-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] rcu_do_batch: make ->qlen decrement irq safe
2006-09-10 20:58 ` Dipankar Sarma
2006-09-10 21:27 ` Oleg Nesterov
@ 2006-09-10 21:32 ` Oleg Nesterov
2006-09-10 22:17 ` Dipankar Sarma
1 sibling, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2006-09-10 21:32 UTC (permalink / raw)
To: Dipankar Sarma
Cc: Paul E. McKenney, Srivatsa Vaddagiri, Andrew Morton, linux-kernel
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>
--- rc6-mm1/kernel/rcupdate.c~ 2006-08-22 16:22:49.000000000 +0400
+++ rc6-mm1/kernel/rcupdate.c 2006-09-11 01:24:17.000000000 +0400
@@ -241,12 +241,16 @@ static void rcu_do_batch(struct rcu_data
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] rcu_do_batch: make ->qlen decrement irq safe
2006-09-10 21:32 ` [PATCH] rcu_do_batch: make ->qlen decrement " Oleg Nesterov
@ 2006-09-10 22:17 ` Dipankar Sarma
0 siblings, 0 replies; 5+ messages in thread
From: Dipankar Sarma @ 2006-09-10 22:17 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Paul E. McKenney, Srivatsa Vaddagiri, Andrew Morton, linux-kernel
On Mon, Sep 11, 2006 at 01:32:43AM +0400, Oleg Nesterov wrote:
> 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>
>
> --- rc6-mm1/kernel/rcupdate.c~ 2006-08-22 16:22:49.000000000 +0400
> +++ rc6-mm1/kernel/rcupdate.c 2006-09-11 01:24:17.000000000 +0400
> @@ -241,12 +241,16 @@ static void rcu_do_batch(struct rcu_data
> 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
Looks good to me.
Thanks
Dipankar
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-09-10 22:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-10 15:08 rcu_do_batch: rcu_data->qlen is not irq safe Oleg Nesterov
2006-09-10 20:58 ` Dipankar Sarma
2006-09-10 21:27 ` Oleg Nesterov
2006-09-10 21:32 ` [PATCH] rcu_do_batch: make ->qlen decrement " Oleg Nesterov
2006-09-10 22:17 ` Dipankar Sarma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox