On Mon, Jun 06, 2016 at 11:31:39PM +0200, Mateusz Guzik wrote:
> The reason is that leaf_walk_rcu does get_child_rcu(pn, cindex++), which
> ends up in lockless_dereference as pn[cindex++], which is now evaluated
> twice.
Indeed, bad that; yes I think the below will work, will you send a
proper patch so I can apply?
> The simplest fix I see does the assignment later, that is:
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index e9c6417..06f27fd 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -551,8 +551,8 @@ static __always_inline void __write_once_size(volatile
> void *p, void *res, int s
> */
> #define lockless_dereference(p) \
> ({ \
> - __maybe_unused const void * const _________p2 = p; \
> typeof(p) _________p1 = READ_ONCE(p); \
> + __maybe_unused const void * const _________p2 = _________p1; \
> smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
> (_________p1); \
> })
>
> --
> Mateusz Guzik