diff mbox series

[v2,bpf-next,03/13] Revert "locking/spinlocks: Remove the unused spin_lock_bh_nested() API"

Message ID 20201207132456.65472-4-kuniyu@amazon.co.jp (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series Socket migration for SO_REUSEPORT. | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 30857 this patch: 30858
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: Single statement macros should not use a do {} while (0) loop WARNING: line length of 81 exceeds 80 columns
netdev/build_allmodconfig_warn fail Errors and warnings before: 28703 this patch: 28704
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Iwashima, Kuniyuki Dec. 7, 2020, 1:24 p.m. UTC
This reverts commit 607904c357c61adf20b8fd18af765e501d61a385 to use
spin_lock_bh_nested() in the next commit.

Link: https://lore.kernel.org/netdev/9d290a57-49e1-04cd-2487-262b0d7c5844@gmail.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
CC: Waiman Long <longman@redhat.com>
---
 include/linux/spinlock.h         | 8 ++++++++
 include/linux/spinlock_api_smp.h | 2 ++
 include/linux/spinlock_api_up.h  | 1 +
 kernel/locking/spinlock.c        | 8 ++++++++
 4 files changed, 19 insertions(+)

Comments

Waiman Long Dec. 7, 2020, 4:25 p.m. UTC | #1
On 12/7/20 8:24 AM, Kuniyuki Iwashima wrote:
> This reverts commit 607904c357c61adf20b8fd18af765e501d61a385 to use
> spin_lock_bh_nested() in the next commit.
>
> Link: https://lore.kernel.org/netdev/9d290a57-49e1-04cd-2487-262b0d7c5844@gmail.com/
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
> CC: Waiman Long <longman@redhat.com>

If there is a use case for spin_lock_bh_nested(), it is perfectly fine 
to add it back.

Acked-by: Waiman Long <longman@redhat.com>

> ---
>   include/linux/spinlock.h         | 8 ++++++++
>   include/linux/spinlock_api_smp.h | 2 ++
>   include/linux/spinlock_api_up.h  | 1 +
>   kernel/locking/spinlock.c        | 8 ++++++++
>   4 files changed, 19 insertions(+)
>
> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> index 79897841a2cc..c020b375a071 100644
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -227,6 +227,8 @@ static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
>   #ifdef CONFIG_DEBUG_LOCK_ALLOC
>   # define raw_spin_lock_nested(lock, subclass) \
>   	_raw_spin_lock_nested(lock, subclass)
> +# define raw_spin_lock_bh_nested(lock, subclass) \
> +	_raw_spin_lock_bh_nested(lock, subclass)
>   
>   # define raw_spin_lock_nest_lock(lock, nest_lock)			\
>   	 do {								\
> @@ -242,6 +244,7 @@ static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
>   # 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)
> +# define raw_spin_lock_bh_nested(lock, subclass)	_raw_spin_lock_bh(lock)
>   #endif
>   
>   #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
> @@ -369,6 +372,11 @@ do {								\
>   	raw_spin_lock_nested(spinlock_check(lock), subclass);	\
>   } while (0)
>   
> +#define spin_lock_bh_nested(lock, subclass)			\
> +do {								\
> +	raw_spin_lock_bh_nested(spinlock_check(lock), subclass);\
> +} while (0)
> +
>   #define spin_lock_nest_lock(lock, nest_lock)				\
>   do {									\
>   	raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock);	\
> diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
> index 19a9be9d97ee..d565fb6304f2 100644
> --- a/include/linux/spinlock_api_smp.h
> +++ b/include/linux/spinlock_api_smp.h
> @@ -22,6 +22,8 @@ int in_lock_functions(unsigned long addr);
>   void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)		__acquires(lock);
>   void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
>   								__acquires(lock);
> +void __lockfunc _raw_spin_lock_bh_nested(raw_spinlock_t *lock, int subclass)
> +								__acquires(lock);
>   void __lockfunc
>   _raw_spin_lock_nest_lock(raw_spinlock_t *lock, struct lockdep_map *map)
>   								__acquires(lock);
> diff --git a/include/linux/spinlock_api_up.h b/include/linux/spinlock_api_up.h
> index d0d188861ad6..d3afef9d8dbe 100644
> --- a/include/linux/spinlock_api_up.h
> +++ b/include/linux/spinlock_api_up.h
> @@ -57,6 +57,7 @@
>   
>   #define _raw_spin_lock(lock)			__LOCK(lock)
>   #define _raw_spin_lock_nested(lock, subclass)	__LOCK(lock)
> +#define _raw_spin_lock_bh_nested(lock, subclass) __LOCK(lock)
>   #define _raw_read_lock(lock)			__LOCK(lock)
>   #define _raw_write_lock(lock)			__LOCK(lock)
>   #define _raw_spin_lock_bh(lock)			__LOCK_BH(lock)
> diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c
> index 0ff08380f531..48e99ed1bdd8 100644
> --- a/kernel/locking/spinlock.c
> +++ b/kernel/locking/spinlock.c
> @@ -363,6 +363,14 @@ void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
>   }
>   EXPORT_SYMBOL(_raw_spin_lock_nested);
>   
> +void __lockfunc _raw_spin_lock_bh_nested(raw_spinlock_t *lock, int subclass)
> +{
> +	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
> +	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
> +	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
> +}
> +EXPORT_SYMBOL(_raw_spin_lock_bh_nested);
> +
>   unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock,
>   						   int subclass)
>   {
diff mbox series

Patch

diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 79897841a2cc..c020b375a071 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -227,6 +227,8 @@  static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # define raw_spin_lock_nested(lock, subclass) \
 	_raw_spin_lock_nested(lock, subclass)
+# define raw_spin_lock_bh_nested(lock, subclass) \
+	_raw_spin_lock_bh_nested(lock, subclass)
 
 # define raw_spin_lock_nest_lock(lock, nest_lock)			\
 	 do {								\
@@ -242,6 +244,7 @@  static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
 # 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)
+# define raw_spin_lock_bh_nested(lock, subclass)	_raw_spin_lock_bh(lock)
 #endif
 
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
@@ -369,6 +372,11 @@  do {								\
 	raw_spin_lock_nested(spinlock_check(lock), subclass);	\
 } while (0)
 
+#define spin_lock_bh_nested(lock, subclass)			\
+do {								\
+	raw_spin_lock_bh_nested(spinlock_check(lock), subclass);\
+} while (0)
+
 #define spin_lock_nest_lock(lock, nest_lock)				\
 do {									\
 	raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock);	\
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
index 19a9be9d97ee..d565fb6304f2 100644
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -22,6 +22,8 @@  int in_lock_functions(unsigned long addr);
 void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)		__acquires(lock);
 void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
 								__acquires(lock);
+void __lockfunc _raw_spin_lock_bh_nested(raw_spinlock_t *lock, int subclass)
+								__acquires(lock);
 void __lockfunc
 _raw_spin_lock_nest_lock(raw_spinlock_t *lock, struct lockdep_map *map)
 								__acquires(lock);
diff --git a/include/linux/spinlock_api_up.h b/include/linux/spinlock_api_up.h
index d0d188861ad6..d3afef9d8dbe 100644
--- a/include/linux/spinlock_api_up.h
+++ b/include/linux/spinlock_api_up.h
@@ -57,6 +57,7 @@ 
 
 #define _raw_spin_lock(lock)			__LOCK(lock)
 #define _raw_spin_lock_nested(lock, subclass)	__LOCK(lock)
+#define _raw_spin_lock_bh_nested(lock, subclass) __LOCK(lock)
 #define _raw_read_lock(lock)			__LOCK(lock)
 #define _raw_write_lock(lock)			__LOCK(lock)
 #define _raw_spin_lock_bh(lock)			__LOCK_BH(lock)
diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c
index 0ff08380f531..48e99ed1bdd8 100644
--- a/kernel/locking/spinlock.c
+++ b/kernel/locking/spinlock.c
@@ -363,6 +363,14 @@  void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
 }
 EXPORT_SYMBOL(_raw_spin_lock_nested);
 
+void __lockfunc _raw_spin_lock_bh_nested(raw_spinlock_t *lock, int subclass)
+{
+	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
+	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
+	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
+}
+EXPORT_SYMBOL(_raw_spin_lock_bh_nested);
+
 unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock,
 						   int subclass)
 {