From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992419AbcHRNsg (ORCPT ); Thu, 18 Aug 2016 09:48:36 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34444 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753916AbcHRNpR (ORCPT ); Thu, 18 Aug 2016 09:45:17 -0400 Date: Thu, 18 Aug 2016 06:40:57 -0700 From: tip-bot for Johannes Berg Message-ID: Cc: johannes.berg@intel.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, daniel.vetter@intel.com, hpa@zytor.com, paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, chris@chris-wilson.co.uk Reply-To: johannes.berg@intel.com, akpm@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, daniel.vetter@intel.com, hpa@zytor.com, paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, chris@chris-wilson.co.uk In-Reply-To: <1470909022-687-2-git-send-email-johannes@sipsolutions.net> References: <1470909022-687-2-git-send-email-johannes@sipsolutions.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/urgent] locking/barriers: Suppress sparse warnings in lockless_dereference() Git-Commit-ID: 112dc0c8069e5554e0ad29c58228f1e6ca49e13d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 112dc0c8069e5554e0ad29c58228f1e6ca49e13d Gitweb: http://git.kernel.org/tip/112dc0c8069e5554e0ad29c58228f1e6ca49e13d Author: Johannes Berg AuthorDate: Thu, 11 Aug 2016 11:50:22 +0200 Committer: Ingo Molnar CommitDate: Thu, 18 Aug 2016 15:36:13 +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 Signed-off-by: Johannes Berg Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Chris Wilson Cc: Daniel Vetter Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner 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 --- 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); \ })