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


Groups > linux.kernel > #1417512 > unrolled thread

[tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type

Started bytip-bot for Peter Zijlstra <tipbot@zytor.com>
First post2016-06-08 16:30 +0200
Last post2016-06-08 16:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [tip:locking/core] locking/barriers: Validate  lockless_dereference() is used on a pointer type tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2016-06-08 16:30 +0200

#1417512 — [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type

Fromtip-bot for Peter Zijlstra <tipbot@zytor.com>
Date2016-06-08 16:30 +0200
Subject[tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type
Message-ID<rHMEy-1il-29@gated-at.bofh.it>
Commit-ID:  331b6d8c7afc2e5b900b9dcd850c265e1ba8d8e7
Gitweb:     http://git.kernel.org/tip/331b6d8c7afc2e5b900b9dcd850c265e1ba8d8e7
Author:     Peter Zijlstra <peterz@infradead.org>
AuthorDate: Sun, 22 May 2016 12:48:27 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 8 Jun 2016 14:22:47 +0200

locking/barriers: Validate lockless_dereference() is used on a pointer type

Use the type to validate the argument @p is indeed a pointer type.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160522104827.GP3193@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/compiler.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 793c082..06f27fd 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -545,10 +545,14 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
  * Similar to rcu_dereference(), but for situations where the pointed-to
  * object's lifetime is managed by something other than RCU.  That
  * "something other" might be reference counting or simple immortality.
+ *
+ * The seemingly unused void * variable is to validate @p is indeed a pointer
+ * type. All pointer types silently cast to void *.
  */
 #define lockless_dereference(p) \
 ({ \
 	typeof(p) _________p1 = READ_ONCE(p); \
+	__maybe_unused const void * const _________p2 = _________p1; \
 	smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
 	(_________p1); \
 })

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web