Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1415780
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type |
| Date | 2016-06-07 09:20 +0200 |
| Message-ID | <rHjsS-82q-15@gated-at.bofh.it> (permalink) |
| References | <rBz7j-8a7-11@gated-at.bofh.it> <rFUZz-25k-9@gated-at.bofh.it> <rHapA-1UM-29@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2016-06-03 13:00 +0200
Re: [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type Mateusz Guzik <mguzik@redhat.com> - 2016-06-06 23:40 +0200
Re: [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type Peter Zijlstra <peterz@infradead.org> - 2016-06-07 09:20 +0200
csiph-web