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 #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
10 extern spinlock_t kernel_flag
;
12 #define kernel_locked() (current->lock_depth >= 0)
14 #define get_kernel_lock() spin_lock(&kernel_flag)
15 #define put_kernel_lock() spin_unlock(&kernel_flag)
18 * Release global kernel lock.
20 static inline void release_kernel_lock(struct task_struct
*task
)
22 if (unlikely(task
->lock_depth
>= 0))
27 * Re-acquire the kernel lock
29 static inline void reacquire_kernel_lock(struct task_struct
*task
)
31 if (unlikely(task
->lock_depth
>= 0))
36 * Getting the big kernel lock.
38 * This cannot happen asynchronously,
39 * so we only need to worry about other
42 static inline void lock_kernel(void)
44 int depth
= current
->lock_depth
+1;
47 current
->lock_depth
= depth
;
50 static inline void unlock_kernel(void)
52 BUG_ON(current
->lock_depth
< 0);
53 if (likely(--current
->lock_depth
< 0))
59 #define lock_kernel() do { } while(0)
60 #define unlock_kernel() do { } while(0)
61 #define release_kernel_lock(task) do { } while(0)
62 #define reacquire_kernel_lock(task) do { } while(0)
63 #define kernel_locked() 1
65 #endif /* CONFIG_SMP || CONFIG_PREEMPT */
66 #endif /* __LINUX_SMPLOCK_H */