[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1465305295-16336-1-git-send-email-mguzik@redhat.com>
Date: Tue, 7 Jun 2016 15:14:55 +0200
From: Mateusz Guzik <mguzik@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, tglx@...utronix.de, mingo@...nel.org,
hpa@...or.com, torvalds@...ux-foundation.org
Subject: [PATCH] locking/barriers: evaluate the argument to lockless_dereference only once
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@...hat.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
Powered by blists - more mailing lists