Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1416153 > unrolled thread

[PATCH] locking/barriers: evaluate the argument to lockless_dereference only once

Started byMateusz Guzik <mguzik@redhat.com>
First post2016-06-07 15:20 +0200
Last post2016-06-07 15:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] locking/barriers: evaluate the argument to lockless_dereference only once Mateusz Guzik <mguzik@redhat.com> - 2016-06-07 15:20 +0200

#1416153 — [PATCH] locking/barriers: evaluate the argument to lockless_dereference only once

FromMateusz Guzik <mguzik@redhat.com>
Date2016-06-07 15:20 +0200
Subject[PATCH] locking/barriers: evaluate the argument to lockless_dereference only once
Message-ID<rHp5f-3b5-9@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web