mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] locking/barriers: evaluate the argument to lockless_dereference only once
@ 2016-06-07 13:14 Mateusz Guzik
  2016-06-14 10:50 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Guzik @ 2016-06-07 13:14 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel, tglx, mingo, hpa, torvalds

The commit 25841ee0e9d2a ("Validate lockless_dereference() is used on a
pointer type") added a second use of the parameter to the macro.

This leads to trouble with consumers which use arguments with side
effects.

Instead, reuse the value which was read the first time.

Signed-off-by: Mateusz Guzik <mguzik@redhat.com>

---
 include/linux/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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); \
 })
-- 
1.8.3.1

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

end of thread, other threads:[~2016-06-14 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 13:14 [PATCH] locking/barriers: evaluate the argument to lockless_dereference only once Mateusz Guzik
2016-06-14 10:50 ` Peter Zijlstra

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

all inboxes | Powered by JetHome®