Commit fb454fda authored by Linus Torvalds's avatar Linus Torvalds

Clean up asm-i386/smplock.h

parent 7cc2fd8b
...@@ -10,15 +10,10 @@ ...@@ -10,15 +10,10 @@
extern spinlock_t kernel_flag; extern spinlock_t kernel_flag;
#ifdef CONFIG_SMP #define kernel_locked() (current->lock_depth >= 0)
#define kernel_locked() spin_is_locked(&kernel_flag)
#else #define get_kernel_lock() spin_lock(&kernel_flag)
#ifdef CONFIG_PREEMPT #define put_kernel_lock() spin_unlock(&kernel_flag)
#define kernel_locked() preempt_count()
#else
#define kernel_locked() 1
#endif
#endif
/* /*
* Release global kernel lock and global interrupt lock * Release global kernel lock and global interrupt lock
...@@ -26,7 +21,7 @@ extern spinlock_t kernel_flag; ...@@ -26,7 +21,7 @@ extern spinlock_t kernel_flag;
#define release_kernel_lock(task) \ #define release_kernel_lock(task) \
do { \ do { \
if (unlikely(task->lock_depth >= 0)) \ if (unlikely(task->lock_depth >= 0)) \
spin_unlock(&kernel_flag); \ put_kernel_lock(); \
} while (0) } while (0)
/* /*
...@@ -35,7 +30,7 @@ do { \ ...@@ -35,7 +30,7 @@ do { \
#define reacquire_kernel_lock(task) \ #define reacquire_kernel_lock(task) \
do { \ do { \
if (unlikely(task->lock_depth >= 0)) \ if (unlikely(task->lock_depth >= 0)) \
spin_lock(&kernel_flag); \ get_kernel_lock(); \
} while (0) } while (0)
...@@ -48,40 +43,16 @@ do { \ ...@@ -48,40 +43,16 @@ do { \
*/ */
static __inline__ void lock_kernel(void) static __inline__ void lock_kernel(void)
{ {
#ifdef CONFIG_PREEMPT int depth = current->lock_depth+1;
if (current->lock_depth == -1) if (!depth)
spin_lock(&kernel_flag); get_kernel_lock();
++current->lock_depth; current->lock_depth = depth;
#else
#if 1
if (!++current->lock_depth)
spin_lock(&kernel_flag);
#else
__asm__ __volatile__(
"incl %1\n\t"
"jne 9f"
spin_lock_string
"\n9:"
:"=m" (__dummy_lock(&kernel_flag)),
"=m" (current->lock_depth));
#endif
#endif
} }
static __inline__ void unlock_kernel(void) static __inline__ void unlock_kernel(void)
{ {
if (current->lock_depth < 0) if (current->lock_depth < 0)
BUG(); BUG();
#if 1
if (--current->lock_depth < 0) if (--current->lock_depth < 0)
spin_unlock(&kernel_flag); put_kernel_lock();
#else
__asm__ __volatile__(
"decl %1\n\t"
"jns 9f\n\t"
spin_unlock_string
"\n9:"
:"=m" (__dummy_lock(&kernel_flag)),
"=m" (current->lock_depth));
#endif
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment