Skip to contentSkip to conversation

spinlock: rm duplicated preempt en/disable for bottom half

PATCH In review Bob Liu 3 participants 4 messages Sep 27, 2011 Locking primitives

lore
Share & tools
lore

Bob Liu

author
#0 lore raw

PATCH 1/1 spinlock: rm duplicated preempt en/disable for bottom half

local_bh_en/disable() has already deal with en/disable preempt, so rm the dumplicated one from spinlock_api_up/smp.h head file.

---
 include/linux/spinlock_api_smp.h |    4 ----
 include/linux/spinlock_api_up.h  |    5 ++---
 2 files changed, 2 insertions(+), 7 deletions(-)
include/linux/spinlock_api_smp.h +0 -4
index e253ccd..ba8b8f3 100644
@@ -132,7 +132,6 @@ static inline void __raw_spin_lock_irq(raw_spinlock_t *lock)
 static inline void __raw_spin_lock_bh(raw_spinlock_t *lock)
 {
 	local_bh_disable();
-	preempt_disable();
 	spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
 	LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 }
@@ -174,19 +173,16 @@ static inline void __raw_spin_unlock_bh(raw_spinlock_t *lock)
 {
 	spin_release(&lock->dep_map, 1, _RET_IP_);
 	do_raw_spin_unlock(lock);
-	preempt_enable_no_resched();
 	local_bh_enable_ip((unsigned long)__builtin_return_address(0));
 }
 
 static inline int __raw_spin_trylock_bh(raw_spinlock_t *lock)
 {
 	local_bh_disable();
-	preempt_disable();
 	if (do_raw_spin_trylock(lock)) {
 		spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
 		return 1;
 	}
-	preempt_enable_no_resched();
 	local_bh_enable_ip((unsigned long)__builtin_return_address(0));
 	return 0;
 }
include/linux/spinlock_api_up.h +2 -3
index af1f472..c9e4f1c 100644
@@ -28,7 +28,7 @@
   do { preempt_disable(); __acquire(lock); (void)(lock); } while (0)
 
 #define __LOCK_BH(lock) \
-  do { local_bh_disable(); __LOCK(lock); } while (0)
+  do { local_bh_disable(); __acquire(lock); (void)(lock); } while (0)
 
 #define __LOCK_IRQ(lock) \
   do { local_irq_disable(); __LOCK(lock); } while (0)
@@ -40,8 +40,7 @@
   do { preempt_enable(); __release(lock); (void)(lock); } while (0)
 
 #define __UNLOCK_BH(lock) \
-  do { preempt_enable_no_resched(); local_bh_enable(); \
-	  __release(lock); (void)(lock); } while (0)
+  do { local_bh_enable(); __release(lock); (void)(lock); } while (0)
 
 #define __UNLOCK_IRQ(lock) \
   do { local_irq_enable(); __UNLOCK(lock); } while (0)
Signature · 1 line
1.6.3.3
maintainer
#1 lore raw
Quoted 2 lines · Bob Liu

local_bh_en/disable() has already deal with en/disable preempt, so rm the dumplicated one from spinlock_api_up/smp.h head file.

I bet you haven't tried booting this.. you just broke stuff like:

  spin_lock_bh(&foo);
  /* do crap */
  spin_unlock(&foo);
  /* do some other crap */
  local_bh_enable();

And yes that does happen.

author
#2 lore raw
Quoted 6 lines · Peter Zijlstra
Quoted 2 lines · Bob Liu

local_bh_en/disable() has already deal with en/disable preempt, so rm the dumplicated one from spinlock_api_up/smp.h head file.

I bet you haven't tried booting this..  you just broke stuff like:

I only tried it on blackfin arch and can boot successfully although it's a simple single-cpu ystem.

Quoted 8 lines

 spin_lock_bh(&foo);
 /* do crap */
 spin_unlock(&foo);
 /* do some other crap */
 local_bh_enable();

And yes that does happen.

Could you please give an example? I did a simple search but no result. I thought the user should use spin_lock_bh()/spin_unlock_bh() in pairs.

Signature · 2 lines
Regards,
--Bob
#3 lore raw
Quoted 18 lines · Bob Liu
Quoted 6 lines · Peter Zijlstra
Quoted 2 lines · Bob Liu

local_bh_en/disable() has already deal with en/disable preempt, so rm the dumplicated one from spinlock_api_up/smp.h head file.

I bet you haven't tried booting this.. you just broke stuff like:

I only tried it on blackfin arch and can boot successfully although it's a simple single-cpu ystem.

Quoted 7 lines

spin_lock_bh(&foo);
/* do crap */
spin_unlock(&foo);
/* do some other crap */
local_bh_enable();

Quoted 5 lines
Quoted 1 line

And yes that does happen.

Could you please give an example? I did a simple search but no result. I thought the user should use spin_lock_bh()/spin_unlock_bh() in pairs.

You probably can find such use in network stack.

net/ipv4/inet_hashtables.c function __inet_hash_connect()