Re: Compilers and RCU readers: Once more unto the breach!

From: Paul E. McKenney
Date: Wed May 20 2015 - 11:18:38 EST


On Wed, May 20, 2015 at 03:15:48PM +0100, Ramana Radhakrishnan wrote:
>
>
> On 20/05/15 15:03, Paul E. McKenney wrote:
> >On Wed, May 20, 2015 at 02:44:30PM +0100, Ramana Radhakrishnan wrote:
> >>
> >>
> >>On 20/05/15 14:37, David Howells wrote:
> >>>Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx> wrote:
> >>>
> >>>>I was thinking of "y" as a simple variable, but if it is something more
> >>>>complex, then the compiler could do this, right?
> >>>>
> >>>> char *x;
> >>>>
> >>>> y;
> >>>> x = z;
> >>>
> >>>Yeah. I presume it has to maintain the ordering, though.
> >>
> >>The scheduler for e.g. is free to reorder if it can prove there is
> >>no dependence (or indeed side-effects for y) between insns produced
> >>for y and `x = z'.
> >
> >So for example, if y is independent of z, the compiler can do the
> >following:
> >
> > char *x;
> >
> > x = z;
> > y;
> >
> >But the dependency ordering is still maintained from z to x, so this
> >is not a problem.
>
>
> Well, reads if any of x (assuming x was initialized elsewhere) would
> need to happen before x got assigned to z.

Agreed, there needs to be a memory_order_consume load up there somewhere.
(AKA rcu_dereference().)

> I understood the original "maintain the ordering" as between the
> statements `x = z' and `y'.

Ah, I was assuming between x and z. David, what was your intent? ;-)

> >Or am I missing something subtle here?
>
> No, it sounds like we are on the same page here.

Whew! ;-)

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/