[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-9054b5958ca3cc83ec815d40ed5b5176bf422a03@git.kernel.org>
Date: Thu, 18 Aug 2016 04:00:00 -0700
From: tip-bot for Johannes Berg <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
mingo@...nel.org, akpm@...ux-foundation.org, tglx@...utronix.de,
torvalds@...ux-foundation.org, daniel.vetter@...el.com,
chris@...is-wilson.co.uk, paulmck@...ux.vnet.ibm.com,
johannes.berg@...el.com, hpa@...or.com
Subject: [tip:locking/core] locking/barriers: Suppress sparse warnings in
lockless_dereference()
Commit-ID: 9054b5958ca3cc83ec815d40ed5b5176bf422a03
Gitweb: http://git.kernel.org/tip/9054b5958ca3cc83ec815d40ed5b5176bf422a03
Author: Johannes Berg <johannes.berg@...el.com>
AuthorDate: Thu, 11 Aug 2016 11:50:22 +0200
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Thu, 18 Aug 2016 11:34:27 +0200
locking/barriers: Suppress sparse warnings in lockless_dereference()
After Peter's commit:
331b6d8c7afc ("locking/barriers: Validate lockless_dereference() is used on a pointer type")
... we get a lot of sparse warnings (one for every rcu_dereference, and more)
since the expression here is assigning to the wrong address space.
Instead of validating that 'p' is a pointer this way, instead make
it fail compilation when it's not by using sizeof(*(p)). This will
not cause any sparse warnings (tested, likely since the address
space is irrelevant for sizeof), and will fail compilation when
'p' isn't a pointer type.
Tested-by: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Signed-off-by: Johannes Berg <johannes.berg@...el.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Chris Wilson <chris@...is-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@...el.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Fixes: 331b6d8c7afc ("locking/barriers: Validate lockless_dereference() is used on a pointer type")
Link: http://lkml.kernel.org/r/1470909022-687-2-git-send-email-johannes@sipsolutions.net
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
include/linux/compiler.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 1bb9548..436aa4e 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -527,13 +527,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
* 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 *.
+ * The seemingly unused size_t variable is to validate @p is indeed a pointer
+ * type by making sure it can be dereferenced.
*/
#define lockless_dereference(p) \
({ \
typeof(p) _________p1 = READ_ONCE(p); \
- __maybe_unused const void * const _________p2 = _________p1; \
+ size_t __maybe_unused __size_of_ptr = sizeof(*(p)); \
smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
(_________p1); \
})
Powered by blists - more mailing lists