Re: [PATCH 1/2] srcu: RCU variant permitting read-side blocking

From: Paul E. McKenney
Date: Tue Jun 27 2006 - 15:17:36 EST


On Tue, Jun 27, 2006 at 11:59:45AM -0700, Paul E. McKenney wrote:
> On Wed, Jun 28, 2006 at 01:13:58AM +0400, Oleg Nesterov wrote:
> > "Paul E. McKenney" wrote:
> > > + idx = sp->completed & 0x1;
> > > + sp->completed++;
> >
> > But srcu_read_lock()'s path and rcu_dereference() doesn't have rmb(),
> > and the reader can block, so I can't understand how this all works.
> >
> > Suppose ->completed == 0,
> >
> > WRITER: READER:
> >
> > old = global_ptr;
> > rcu_assign_pointer(global_ptr, new);
> >
> > synchronize_srcu:
> >
> > locks mutex, does mb,
> > ->completed++;
> >
> > srcu_read_lock();
> > // reads ->completed == 1
> > // does .c[1]++
> > ptr = rcu_dereference(global_ptr)
> > // reads the *OLD* value,
> > // because we don't have rmb()
>
> Hmmm... I thought I was handling this case, but my rationale as to
> how is looking a bit flimsy at the moment. ;-) I will look at this
> more carefully. If you are correct, one fix is to replace the prior mb
> with synchronize_sched(). Do you agree that this would fix the problem?

Never mind -- this fix would have no effect. Guess I should engage
my brain before sending email. :-/

First to review my reasoning, and then to provide either the explanation
should my reasoning prove true or a fix otherwise...

Thanx, Paul
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/