aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/smp_lock.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/smp_lock.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/smp_lock.h')
-rw-r--r--include/linux/smp_lock.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
new file mode 100644
index 000000000000..b63ce7014093
--- /dev/null
+++ b/include/linux/smp_lock.h
@@ -0,0 +1,54 @@
1#ifndef __LINUX_SMPLOCK_H
2#define __LINUX_SMPLOCK_H
3
4#include <linux/config.h>
5#include <linux/sched.h>
6#include <linux/spinlock.h>
7
8#ifdef CONFIG_LOCK_KERNEL
9
10#define kernel_locked() (current->lock_depth >= 0)
11
12extern int __lockfunc __reacquire_kernel_lock(void);
13extern void __lockfunc __release_kernel_lock(void);
14
15/*
16 * Release/re-acquire global kernel lock for the scheduler
17 */
18#define release_kernel_lock(tsk) do { \
19 if (unlikely((tsk)->lock_depth >= 0)) \
20 __release_kernel_lock(); \
21} while (0)
22
23/*
24 * Non-SMP kernels will never block on the kernel lock,
25 * so we are better off returning a constant zero from
26 * reacquire_kernel_lock() so that the compiler can see
27 * it at compile-time.
28 */
29#if defined(CONFIG_SMP) && !defined(CONFIG_PREEMPT_BKL)
30# define return_value_on_smp return
31#else
32# define return_value_on_smp
33#endif
34
35static inline int reacquire_kernel_lock(struct task_struct *task)
36{
37 if (unlikely(task->lock_depth >= 0))
38 return_value_on_smp __reacquire_kernel_lock();
39 return 0;
40}
41
42extern void __lockfunc lock_kernel(void) __acquires(kernel_lock);
43extern void __lockfunc unlock_kernel(void) __releases(kernel_lock);
44
45#else
46
47#define lock_kernel() do { } while(0)
48#define unlock_kernel() do { } while(0)
49#define release_kernel_lock(task) do { } while(0)
50#define reacquire_kernel_lock(task) 0
51#define kernel_locked() 1
52
53#endif /* CONFIG_LOCK_KERNEL */
54#endif /* __LINUX_SMPLOCK_H */