From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756444AbaHHKfp (ORCPT ); Fri, 8 Aug 2014 06:35:45 -0400 Received: from sf1.bxl.stone.is ([87.238.167.36]:33272 "EHLO sf1.bxl.stone.is" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756013AbaHHKfo (ORCPT ); Fri, 8 Aug 2014 06:35:44 -0400 X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network Message-ID: <53E4A7F8.1040700@acm.org> Date: Fri, 08 Aug 2014 12:35:36 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Ingo Molnar , David Rientjes CC: Andrew Morton , Peter Zijlstra , "David S. Miller" , linux-kernel Subject: [PATCH v3] spin_lock_nested(): Always evaluate second argument References: <53CE1019.10708@acm.org> <20140722133716.cff957eff4eff1cc9c1d9968@linux-foundation.org> <53E260D9.6030803@acm.org> <53E2618F.6040208@acm.org> <53E4A73D.5080801@acm.org> In-Reply-To: <53E4A73D.5080801@acm.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Filter-ID: XtLePq6GTMn8G68F0EmQvdthj6rk7ohlAkaRQG+cDaLZlN3ufQ0ZRHdy43341LQ0JYRGiu4wDuX/ sGw1Y7RAsZ3WBw9ZlycipwBG3jGu9D8JBgu10R0foqIRsBJqRnurUO/XCGxJVedBWv8BXp6lSPrf oA0XngOaR5RLFk6kKY8+X6tyUZ34Ozy6TOwmaHPzFR2lHDoBQ4zwtMehH4SfWgLcNhHqvET8hkHK 4DD3CZT4SL0VvzAbTStaxE3e6xctxkHXgTSJC2+q+O2n2sPwh+CpLQk2sgUsKd5RNPNJeN3I5L/U AJH41ve/RciJD7RwcMm6IODZgOZ9Y8BEoKFU+dplnEc9jfM8rmxx+/zyrq0ccBIk1Sag4dKiqCrF 8eZZsQYibGPulATAPqOguWXWenmy4p4jVbvkvQrOImHI+zH4ns3e6vWEaK66hz4t87L5hVQSL57W w8nd1cTP1twpFFTUuHOuOBA828Pfce2frIKvtUus/ypEW5W6Dw4DmSZF9OoIMWCP9bnVs5BJWbbt 5dM+m4WpRRDP6YzwkAPgQJZcv8AnfPB9HqHgcyCJwUz8oOSQKVK4yyKUlGmQMgPOfIQtTQXMrNAv J7CbCYezRVuhdlkpfoNhtgWYwB/e4S2rpoRvMJWweGFGUUnI6wOX8j4FS3UlU37B6qPMab0LB93J IFkIZaBCBQxuHnm838r5oXZZKX6DYbYFmMAf3uEtq0CVt0DUeFU/MBWnkHtFiUWUs1IAPjDts3+I etSNQKiFa27IsDu2NxxouWmZdcGOChVo3Ylh8ywfjYp979CTGJlcA0OL1mkTp3S7nD3AxhtVMS+4 ayUpOtEhdxekWDmK9g== X-Report-Abuse-To: spam@sf1.bxl.stone.is X-Filter-Fingerprint: cPaH8lomer6UwsJ3BnJDyh/24V0ZnPLChpTdx0aQyMi0VFDyP20las9Mq1v6nXmfrqKtWpHLpkE8 c09GKJn2t66S65eVMsSONLoJrfmhPEJMqRJTan78INzQLlEGX/jFRST5X0bRoOLYozD+qqgg13U4 H51jyCSmLdA2hPaiVpwYWaeThsiFlmPt/lOSmjPekAuF+602V6QvPKXkSIpowmqK95LAXg+Ea3Jb F9WwpaZ//Un1C5ivAWoOksRE8XtOTT9J6CK2j8j7/AJ9TNml+IbyXSJXjZjMx+Tok7jY2RMVEkZR xMpnILpnPlb/BDIPR3BzrtNvug17DaoVb9RvKu/asqb5U7p3XPySiJaf+1XE3nrK/nhevL/uAoHg xNXar0XzbLB8Pru9OEB7tNjak+6bpnvFzMd6SECQNf1u/wGWAJzP31LdUHDVnH0aZDcVCxO6ac9X hDc8gFJxmNF1qg== X-Originating-IP: 87.238.167.34 X-SpamExperts-Domain: stone.is X-SpamExperts-Username: 87.238.167.34 Authentication-Results: bxl.stone.is; auth=pass smtp.auth=87.238.167.34 X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.03) X-Recommended-Action: accept Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Evaluating a macro argument only if certain configuration options have been selected is confusing and error-prone. Hence always evaluate the second argument of spin_lock_nested(). An intentional side effect of this patch is that it avoids that the following warning is reported for netif_addr_lock_nested() when building with CONFIG_DEBUG_LOCK_ALLOC=n and with W=1: include/linux/netdevice.h: In function 'netif_addr_lock_nested': include/linux/netdevice.h:2865:6: warning: variable 'subclass' set but not used [-Wunused-but-set-variable] int subclass = SINGLE_DEPTH_NESTING; ^ Signed-off-by: Bart Van Assche Cc: Ingo Molnar Cc: David Rientjes Cc: Peter Zijlstra Cc: David S. Miller Cc: Andrew Morton --- include/linux/spinlock.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 3f2867f..262ba4e 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -197,7 +197,13 @@ static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock) _raw_spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \ } while (0) #else -# define raw_spin_lock_nested(lock, subclass) _raw_spin_lock(lock) +/* + * Always evaluate the 'subclass' argument to avoid that the compiler + * warns about set-but-not-used variables when building with + * CONFIG_DEBUG_LOCK_ALLOC=n and with W=1. + */ +# define raw_spin_lock_nested(lock, subclass) \ + _raw_spin_lock(((void)(subclass), (lock))) # define raw_spin_lock_nest_lock(lock, nest_lock) _raw_spin_lock(lock) #endif -- 1.8.4.5