linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] spin_lock_*(): Always evaluate second argument
@ 2014-07-22  7:17 Bart Van Assche
  2014-07-22 20:37 ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2014-07-22  7:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: David Rientjes, Peter Zijlstra, David S. Miller, Andrew Morton,
	linux-kernel

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() and
spin_lock_nest_lock().

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 <bvanassche@acm.org>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 include/linux/spinlock.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 3f2867f..32b16cc 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -197,8 +197,10 @@ 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)
-# define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
+# define raw_spin_lock_nested(lock, subclass)		\
+	((void)(subclass), _raw_spin_lock(lock))
+# define raw_spin_lock_nest_lock(lock, nest_lock)	\
+	((void)(nest_lock), _raw_spin_lock(lock))
 #endif
 
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND] spin_lock_*(): Always evaluate second argument
  2014-07-22  7:17 [PATCH RESEND] spin_lock_*(): Always evaluate second argument Bart Van Assche
@ 2014-07-22 20:37 ` Andrew Morton
  2014-07-22 23:16   ` David Rientjes
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2014-07-22 20:37 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Ingo Molnar, David Rientjes, Peter Zijlstra, David S. Miller,
	linux-kernel

On Tue, 22 Jul 2014 09:17:45 +0200 Bart Van Assche <bvanassche@acm.org> wrote:

> 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() and
> spin_lock_nest_lock().
> 
> 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:
> 
> ...
>
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -197,8 +197,10 @@ 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)
> -# define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
> +# define raw_spin_lock_nested(lock, subclass)		\
> +	((void)(subclass), _raw_spin_lock(lock))
> +# define raw_spin_lock_nest_lock(lock, nest_lock)	\
> +	((void)(nest_lock), _raw_spin_lock(lock))
>  #endif
>  

Did you try converting these to static inline functions?  That should
squish the warning and makes the code nicer instead of nastier...


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND] spin_lock_*(): Always evaluate second argument
  2014-07-22 20:37 ` Andrew Morton
@ 2014-07-22 23:16   ` David Rientjes
  2014-08-06 17:07     ` Bart Van Assche
  0 siblings, 1 reply; 11+ messages in thread
From: David Rientjes @ 2014-07-22 23:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Bart Van Assche, Ingo Molnar, Peter Zijlstra, David S. Miller,
	linux-kernel

On Tue, 22 Jul 2014, Andrew Morton wrote:

> > 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() and
> > spin_lock_nest_lock().
> > 
> > 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:
> > 
> > ...
> >
> > --- a/include/linux/spinlock.h
> > +++ b/include/linux/spinlock.h
> > @@ -197,8 +197,10 @@ 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)
> > -# define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
> > +# define raw_spin_lock_nested(lock, subclass)		\
> > +	((void)(subclass), _raw_spin_lock(lock))
> > +# define raw_spin_lock_nest_lock(lock, nest_lock)	\
> > +	((void)(nest_lock), _raw_spin_lock(lock))
> >  #endif
> >  
> 
> Did you try converting these to static inline functions?  That should
> squish the warning and makes the code nicer instead of nastier...
> 

Not sure how that would be done since _raw_spin_lock isn't declared in 
this scope.

Taking a second look, however, I think the patch doesn't need to modify 
raw_spin_lock_nest_lock() for the problem being reported and evaluating 
the parameter of type struct lockdep_map * probably is meaningless.

Bart, is it possible to just get away with the raw_spin_lock_nested() 
change?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RESEND] spin_lock_*(): Always evaluate second argument
  2014-07-22 23:16   ` David Rientjes
@ 2014-08-06 17:07     ` Bart Van Assche
  2014-08-06 17:10       ` [PATCH v2] spin_lock_nested(): " Bart Van Assche
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2014-08-06 17:07 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton
  Cc: Ingo Molnar, Peter Zijlstra, David S. Miller, linux-kernel

On 07/23/14 01:16, David Rientjes wrote:
> On Tue, 22 Jul 2014, Andrew Morton wrote:
>>> 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() and
>>> spin_lock_nest_lock().
>>>
>>> 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:
>>>
>>> ...
>>>
>>> --- a/include/linux/spinlock.h
>>> +++ b/include/linux/spinlock.h
>>> @@ -197,8 +197,10 @@ 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)
>>> -# define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
>>> +# define raw_spin_lock_nested(lock, subclass)		\
>>> +	((void)(subclass), _raw_spin_lock(lock))
>>> +# define raw_spin_lock_nest_lock(lock, nest_lock)	\
>>> +	((void)(nest_lock), _raw_spin_lock(lock))
>>>  #endif
>>>  
>>
>> Did you try converting these to static inline functions?  That should
>> squish the warning and makes the code nicer instead of nastier...
> 
> Not sure how that would be done since _raw_spin_lock isn't declared in 
> this scope.
> 
> Taking a second look, however, I think the patch doesn't need to modify 
> raw_spin_lock_nest_lock() for the problem being reported and evaluating 
> the parameter of type struct lockdep_map * probably is meaningless.
> 
> Bart, is it possible to just get away with the raw_spin_lock_nested() 
> change?

Probably ... I will post an updated version of this patch.

Bart.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] spin_lock_nested(): Always evaluate second argument
  2014-08-06 17:07     ` Bart Van Assche
@ 2014-08-06 17:10       ` Bart Van Assche
  2014-08-06 21:56         ` David Rientjes
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2014-08-06 17:10 UTC (permalink / raw)
  To: Ingo Molnar, David Rientjes, Andrew Morton
  Cc: Peter Zijlstra, David S. Miller, linux-kernel

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 <bvanassche@acm.org>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 include/linux/spinlock.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 3f2867f..485d5dc 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -197,7 +197,8 @@ 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)
+# define raw_spin_lock_nested(lock, subclass)		\
+	((void)(subclass), _raw_spin_lock(lock))
 # define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
 #endif
 
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] spin_lock_nested(): Always evaluate second argument
  2014-08-06 17:10       ` [PATCH v2] spin_lock_nested(): " Bart Van Assche
@ 2014-08-06 21:56         ` David Rientjes
  2014-08-08 10:32           ` Bart Van Assche
  0 siblings, 1 reply; 11+ messages in thread
From: David Rientjes @ 2014-08-06 21:56 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, David S. Miller,
	linux-kernel

On Wed, 6 Aug 2014, Bart Van Assche wrote:

> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> index 3f2867f..485d5dc 100644
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -197,7 +197,8 @@ 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)
> +# define raw_spin_lock_nested(lock, subclass)		\
> +	((void)(subclass), _raw_spin_lock(lock))
>  # define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
>  #endif
>  

I think it would be nice to comment why we're evaluating the subclass when 
CONFIG_DEBUG_LOCK_ALLOC=n so that nobody comes along and unknowingly 
changes it back.

Thanks for posting the updated version and keeping at it!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] spin_lock_nested(): Always evaluate second argument
  2014-08-06 21:56         ` David Rientjes
@ 2014-08-08 10:32           ` Bart Van Assche
  2014-08-08 10:35             ` [PATCH v3] " Bart Van Assche
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2014-08-08 10:32 UTC (permalink / raw)
  To: David Rientjes
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, David S. Miller,
	linux-kernel

On 08/06/14 23:56, David Rientjes wrote:
> On Wed, 6 Aug 2014, Bart Van Assche wrote:
>> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
>> index 3f2867f..485d5dc 100644
>> --- a/include/linux/spinlock.h
>> +++ b/include/linux/spinlock.h
>> @@ -197,7 +197,8 @@ 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)
>> +# define raw_spin_lock_nested(lock, subclass)		\
>> +	((void)(subclass), _raw_spin_lock(lock))
>>  # define raw_spin_lock_nest_lock(lock, nest_lock)	_raw_spin_lock(lock)
>>  #endif
>>  
> 
> I think it would be nice to comment why we're evaluating the subclass when 
> CONFIG_DEBUG_LOCK_ALLOC=n so that nobody comes along and unknowingly 
> changes it back.
> 
> Thanks for posting the updated version and keeping at it!

This morning I received an e-mail from Wu Fengguang reporting that this
patch breaks the build for CONFIG_SMP=n. I will post a third version.

Bart.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3] spin_lock_nested(): Always evaluate second argument
  2014-08-08 10:32           ` Bart Van Assche
@ 2014-08-08 10:35             ` Bart Van Assche
  2014-08-08 21:52               ` David Rientjes
  2014-08-13 10:56               ` [tip:locking/core] locking/spinlocks: Always evaluate the second argument of spin_lock_nested() tip-bot for Bart Van Assche
  0 siblings, 2 replies; 11+ messages in thread
From: Bart Van Assche @ 2014-08-08 10:35 UTC (permalink / raw)
  To: Ingo Molnar, David Rientjes
  Cc: Andrew Morton, Peter Zijlstra, David S. Miller, linux-kernel

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 <bvanassche@acm.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] spin_lock_nested(): Always evaluate second argument
  2014-08-08 10:35             ` [PATCH v3] " Bart Van Assche
@ 2014-08-08 21:52               ` David Rientjes
  2014-08-09  6:17                 ` Peter Zijlstra
  2014-08-13 10:56               ` [tip:locking/core] locking/spinlocks: Always evaluate the second argument of spin_lock_nested() tip-bot for Bart Van Assche
  1 sibling, 1 reply; 11+ messages in thread
From: David Rientjes @ 2014-08-08 21:52 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, David S. Miller,
	linux-kernel

On Fri, 8 Aug 2014, Bart Van Assche wrote:

> 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.
> + */

I was hoping there was going to be a more important reason for this change 
than to avoid compiler warnings, such as an example where someone is doing 
spin_lock_nested(lock, subclass) and the expression for "subclass" 
requires evaluation in all configs.

> +# 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
>  

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] spin_lock_nested(): Always evaluate second argument
  2014-08-08 21:52               ` David Rientjes
@ 2014-08-09  6:17                 ` Peter Zijlstra
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Zijlstra @ 2014-08-09  6:17 UTC (permalink / raw)
  To: David Rientjes
  Cc: Bart Van Assche, Ingo Molnar, Andrew Morton, David S. Miller,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

On Fri, Aug 08, 2014 at 02:52:50PM -0700, David Rientjes wrote:
> On Fri, 8 Aug 2014, Bart Van Assche wrote:
> 
> > 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.
> > + */
> 
> I was hoping there was going to be a more important reason for this change 
> than to avoid compiler warnings, such as an example where someone is doing 
> spin_lock_nested(lock, subclass) and the expression for "subclass" 
> requires evaluation in all configs.

That would stink, having that argument have side effects. I'd call that
a plain old bug that needs fixing.



[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tip:locking/core] locking/spinlocks: Always evaluate the second argument of spin_lock_nested()
  2014-08-08 10:35             ` [PATCH v3] " Bart Van Assche
  2014-08-08 21:52               ` David Rientjes
@ 2014-08-13 10:56               ` tip-bot for Bart Van Assche
  1 sibling, 0 replies; 11+ messages in thread
From: tip-bot for Bart Van Assche @ 2014-08-13 10:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, torvalds, peterz, davem, paulmck,
	bvanassche, akpm, oleg, tglx, rientjes

Commit-ID:  4999201a59ef555f9105d2bb2459ed895627f7aa
Gitweb:     http://git.kernel.org/tip/4999201a59ef555f9105d2bb2459ed895627f7aa
Author:     Bart Van Assche <bvanassche@acm.org>
AuthorDate: Fri, 8 Aug 2014 12:35:36 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 13 Aug 2014 10:32:38 +0200

locking/spinlocks: Always evaluate the second argument of spin_lock_nested()

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 <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: David Rientjes <rientjes@google.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/53E4A7F8.1040700@acm.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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
 

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-08-13 10:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-22  7:17 [PATCH RESEND] spin_lock_*(): Always evaluate second argument Bart Van Assche
2014-07-22 20:37 ` Andrew Morton
2014-07-22 23:16   ` David Rientjes
2014-08-06 17:07     ` Bart Van Assche
2014-08-06 17:10       ` [PATCH v2] spin_lock_nested(): " Bart Van Assche
2014-08-06 21:56         ` David Rientjes
2014-08-08 10:32           ` Bart Van Assche
2014-08-08 10:35             ` [PATCH v3] " Bart Van Assche
2014-08-08 21:52               ` David Rientjes
2014-08-09  6:17                 ` Peter Zijlstra
2014-08-13 10:56               ` [tip:locking/core] locking/spinlocks: Always evaluate the second argument of spin_lock_nested() tip-bot for Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).