public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* PATCH? rcu_do_batch: fix a pure theoretical memory ordering race
@ 2006-12-02 21:25 Oleg Nesterov
  2006-12-03 17:34 ` Eric Dumazet
  2006-12-04 16:43 ` Paul E. McKenney
  0 siblings, 2 replies; 8+ messages in thread
From: Oleg Nesterov @ 2006-12-02 21:25 UTC (permalink / raw)
  To: Paul E. McKenney, Dipankar Sarma
  Cc: Andrew Morton, Alan Stern, Eric Dumazet, linux-kernel

On top of rcu-add-a-prefetch-in-rcu_do_batch.patch

rcu_do_batch:

	struct rcu_head *next, *list;

	while (list) {
		next = list->next;	<------ [1]
		list->func(list);
		list = next;
	}

We can't trust *list after list->func() call, that is why we load list->next
beforehand. However I suspect in theory this is not enough, suppose that

	- [1] is stalled

	- list->func() marks *list as unused in some way

	- another CPU re-uses this rcu_head and dirties it

	- [1] completes and gets a wrong result

This means we need a barrier in between. mb() looks more suitable, but I think
rmb() should suffice.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 19-rc6/kernel/rcupdate.c~rdp	2006-12-02 20:46:03.000000000 +0300
+++ 19-rc6/kernel/rcupdate.c	2006-12-02 21:04:12.000000000 +0300
@@ -236,6 +236,8 @@ static void rcu_do_batch(struct rcu_data
 	list = rdp->donelist;
 	while (list) {
 		next = list->next;
+		/* complete the load above before we call ->func() */
+		smp_rmb();
 		prefetch(next);
 		list->func(list);
 		list = next;


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-12-04 16:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-02 21:25 PATCH? rcu_do_batch: fix a pure theoretical memory ordering race Oleg Nesterov
2006-12-03 17:34 ` Eric Dumazet
2006-12-03 20:01   ` Oleg Nesterov
2006-12-03 20:34     ` Eric Dumazet
2006-12-03 22:12       ` Oleg Nesterov
2006-12-03 23:08         ` Eric Dumazet
2006-12-03 23:46           ` Oleg Nesterov
2006-12-04 16:43 ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox