]> err.no Git - linux-2.6/commitdiff
[PATCH] spin_unlock_bh() and preempt_check_resched()
authorSamuel Thibault <samuel.thibault@labri.fr>
Sat, 21 May 2005 15:50:15 +0000 (17:50 +0200)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 21 May 2005 17:46:48 +0000 (10:46 -0700)
In _spin_unlock_bh(lock):
do { \
_raw_spin_unlock(lock); \
preempt_enable(); \
local_bh_enable(); \
__release(lock); \
} while (0)

there is no reason for using preempt_enable() instead of a simple
preempt_enable_no_resched()

Since we know bottom halves are disabled, preempt_schedule() will always
return at once (preempt_count!=0), and hence preempt_check_resched() is
useless here...

This fixes it by using "preempt_enable_no_resched()" instead of the
"preempt_enable()", and thus avoids the useless preempt_check_resched()
just before re-enabling bottom halves.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/spinlock.h
kernel/spinlock.c

index e895f3eaf53ab1196ee0473ba258586998ec2d4c..d6ba068719b61bf4a035e4d6e297694b65941442 100644 (file)
@@ -248,7 +248,7 @@ typedef struct {
 
 #define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \
                                _raw_spin_trylock(lock) ? \
-                               1 : ({preempt_enable(); local_bh_enable(); 0;});})
+                               1 : ({preempt_enable_no_resched(); local_bh_enable(); 0;});})
 
 #define _spin_lock(lock)       \
 do { \
@@ -383,7 +383,7 @@ do { \
 #define _spin_unlock_bh(lock) \
 do { \
        _raw_spin_unlock(lock); \
-       preempt_enable(); \
+       preempt_enable_no_resched(); \
        local_bh_enable(); \
        __release(lock); \
 } while (0)
@@ -391,7 +391,7 @@ do { \
 #define _write_unlock_bh(lock) \
 do { \
        _raw_write_unlock(lock); \
-       preempt_enable(); \
+       preempt_enable_no_resched(); \
        local_bh_enable(); \
        __release(lock); \
 } while (0)
@@ -423,8 +423,8 @@ do { \
 #define _read_unlock_bh(lock)  \
 do { \
        _raw_read_unlock(lock); \
+       preempt_enable_no_resched();    \
        local_bh_enable();      \
-       preempt_enable();       \
        __release(lock); \
 } while (0)
 
index e15ed17863f16d1c266b82124e76222f1829e26c..0c3f9d8bbe17b3bd00a1c4a77e941bbebc90e226 100644 (file)
@@ -294,7 +294,7 @@ EXPORT_SYMBOL(_spin_unlock_irq);
 void __lockfunc _spin_unlock_bh(spinlock_t *lock)
 {
        _raw_spin_unlock(lock);
-       preempt_enable();
+       preempt_enable_no_resched();
        local_bh_enable();
 }
 EXPORT_SYMBOL(_spin_unlock_bh);
@@ -318,7 +318,7 @@ EXPORT_SYMBOL(_read_unlock_irq);
 void __lockfunc _read_unlock_bh(rwlock_t *lock)
 {
        _raw_read_unlock(lock);
-       preempt_enable();
+       preempt_enable_no_resched();
        local_bh_enable();
 }
 EXPORT_SYMBOL(_read_unlock_bh);
@@ -342,7 +342,7 @@ EXPORT_SYMBOL(_write_unlock_irq);
 void __lockfunc _write_unlock_bh(rwlock_t *lock)
 {
        _raw_write_unlock(lock);
-       preempt_enable();
+       preempt_enable_no_resched();
        local_bh_enable();
 }
 EXPORT_SYMBOL(_write_unlock_bh);
@@ -354,7 +354,7 @@ int __lockfunc _spin_trylock_bh(spinlock_t *lock)
        if (_raw_spin_trylock(lock))
                return 1;
 
-       preempt_enable();
+       preempt_enable_no_resched();
        local_bh_enable();
        return 0;
 }