1 #ifndef __LINUX_SMPLOCK_H
2 #define __LINUX_SMPLOCK_H
4 #include <linux/config.h>
5 #include <linux/sched.h>
6 #include <linux/spinlock.h>
8 #define BKL_DEBUG /* For testing for sleep_on() abuse */
10 #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) || defined(BKL_DEBUG)
12 extern spinlock_t kernel_flag;
14 #define kernel_locked() (current->lock_depth >= 0)
16 #define get_kernel_lock() spin_lock(&kernel_flag)
17 #define put_kernel_lock() spin_unlock(&kernel_flag)
20 * Release global kernel lock.
22 static inline void release_kernel_lock(struct task_struct *task)
24 if (unlikely(task->lock_depth >= 0))
29 * Re-acquire the kernel lock
31 static inline void reacquire_kernel_lock(struct task_struct *task)
33 if (unlikely(task->lock_depth >= 0))
38 * Getting the big kernel lock.
40 * This cannot happen asynchronously,
41 * so we only need to worry about other
44 static inline void lock_kernel(void)
46 int depth = current->lock_depth+1;
49 current->lock_depth = depth;
52 static inline void unlock_kernel(void)
54 BUG_ON(current->lock_depth < 0);
55 if (likely(--current->lock_depth < 0))
61 #define lock_kernel() do { } while(0)
62 #define unlock_kernel() do { } while(0)
63 #define release_kernel_lock(task) do { } while(0)
64 #define reacquire_kernel_lock(task) do { } while(0)
65 #define kernel_locked() 1
67 #endif /* CONFIG_SMP || CONFIG_PREEMPT */
68 #endif /* __LINUX_SMPLOCK_H */