diff mbox series

[v2] locking: Fixup write_lock_nested() implementation.

Message ID 20211123170134.y6xb7pmpgdn4m3bn@linutronix.de (mailing list archive)
State New, archived
Headers show
Series [v2] locking: Fixup write_lock_nested() implementation. | expand

Commit Message

Sebastian Andrzej Siewior Nov. 23, 2021, 5:01 p.m. UTC
Andrew, please merge it into:
  locking/rwlocks: introduce write_lock_nested
  locking-rwlocks-introduce-write_lock_nested.patch

And if someone could test it, I get sh4 defconfig built with and without
lockdep. x86 seems still to build, too. So it can't be that bad.

v1…v2: I noticed a typo in _raw_write_lock_nested() and decided that it
is no needed so now it is removed for !CONFIG_INLINE_WRITE_LOCK.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/rwlock_api_smp.h | 1 -
 kernel/locking/spinlock.c      | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Stephen Rothwell Nov. 23, 2021, 10:52 p.m. UTC | #1
Hi all,

On Tue, 23 Nov 2021 18:01:34 +0100 Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
>
> Andrew, please merge it into:
>   locking/rwlocks: introduce write_lock_nested
>   locking-rwlocks-introduce-write_lock_nested.patch
> 
> And if someone could test it, I get sh4 defconfig built with and without
> lockdep. x86 seems still to build, too. So it can't be that bad.
> 
> v1…v2: I noticed a typo in _raw_write_lock_nested() and decided that it
> is no needed so now it is removed for !CONFIG_INLINE_WRITE_LOCK.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/rwlock_api_smp.h | 1 -
>  kernel/locking/spinlock.c      | 4 ++++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/rwlock_api_smp.h b/include/linux/rwlock_api_smp.h
> index f0c535ec4e654..dceb0a59b6927 100644
> --- a/include/linux/rwlock_api_smp.h
> +++ b/include/linux/rwlock_api_smp.h
> @@ -47,7 +47,6 @@ _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
>  
>  #ifdef CONFIG_INLINE_WRITE_LOCK
>  #define _raw_write_lock(lock) __raw_write_lock(lock)
> -#define _raw_write_lock_nested(lock, subclass) __raw_write_lock_nested(lock, subclass)
>  #endif
>  
>  #ifdef CONFIG_INLINE_READ_LOCK_BH
> diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c
> index 996811efa6d6e..7f49baaa49793 100644
> --- a/kernel/locking/spinlock.c
> +++ b/kernel/locking/spinlock.c
> @@ -301,6 +301,10 @@ void __lockfunc _raw_write_lock(rwlock_t *lock)
>  }
>  EXPORT_SYMBOL(_raw_write_lock);
>  
> +#ifndef CONFIG_DEBUG_LOCK_ALLOC
> +#define __raw_write_lock_nested(lock, subclass)	__raw_write_lock(((void)(subclass), (lock)))
> +#endif
> +
>  void __lockfunc _raw_write_lock_nested(rwlock_t *lock, int subclass)
>  {
>  	__raw_write_lock_nested(lock, subclass);
> -- 
> 2.34.0
> 

I have added that patch to iinux-next today.
diff mbox series

Patch

diff --git a/include/linux/rwlock_api_smp.h b/include/linux/rwlock_api_smp.h
index f0c535ec4e654..dceb0a59b6927 100644
--- a/include/linux/rwlock_api_smp.h
+++ b/include/linux/rwlock_api_smp.h
@@ -47,7 +47,6 @@  _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
 
 #ifdef CONFIG_INLINE_WRITE_LOCK
 #define _raw_write_lock(lock) __raw_write_lock(lock)
-#define _raw_write_lock_nested(lock, subclass) __raw_write_lock_nested(lock, subclass)
 #endif
 
 #ifdef CONFIG_INLINE_READ_LOCK_BH
diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c
index 996811efa6d6e..7f49baaa49793 100644
--- a/kernel/locking/spinlock.c
+++ b/kernel/locking/spinlock.c
@@ -301,6 +301,10 @@  void __lockfunc _raw_write_lock(rwlock_t *lock)
 }
 EXPORT_SYMBOL(_raw_write_lock);
 
+#ifndef CONFIG_DEBUG_LOCK_ALLOC
+#define __raw_write_lock_nested(lock, subclass)	__raw_write_lock(((void)(subclass), (lock)))
+#endif
+
 void __lockfunc _raw_write_lock_nested(rwlock_t *lock, int subclass)
 {
 	__raw_write_lock_nested(lock, subclass);