]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/smp_lock.h
xps: Transmit Packet Steering
[net-next-2.6.git] / include / linux / smp_lock.h
CommitLineData
1da177e4
LT
1#ifndef __LINUX_SMPLOCK_H
2#define __LINUX_SMPLOCK_H
3
f037360f 4#ifdef CONFIG_LOCK_KERNEL
1da177e4 5#include <linux/sched.h>
1da177e4 6
1da177e4
LT
7#define kernel_locked() (current->lock_depth >= 0)
8
9extern int __lockfunc __reacquire_kernel_lock(void);
10extern void __lockfunc __release_kernel_lock(void);
11
12/*
13 * Release/re-acquire global kernel lock for the scheduler
14 */
15#define release_kernel_lock(tsk) do { \
16 if (unlikely((tsk)->lock_depth >= 0)) \
17 __release_kernel_lock(); \
18} while (0)
19
1da177e4
LT
20static inline int reacquire_kernel_lock(struct task_struct *task)
21{
22 if (unlikely(task->lock_depth >= 0))
6478d880 23 return __reacquire_kernel_lock();
1da177e4
LT
24 return 0;
25}
26
925936eb
FW
27extern void __lockfunc
28_lock_kernel(const char *func, const char *file, int line)
29__acquires(kernel_lock);
96a2c464 30
925936eb
FW
31extern void __lockfunc
32_unlock_kernel(const char *func, const char *file, int line)
33__releases(kernel_lock);
96a2c464 34
925936eb
FW
35#define lock_kernel() do { \
36 _lock_kernel(__func__, __FILE__, __LINE__); \
37} while (0)
38
39#define unlock_kernel() do { \
40 _unlock_kernel(__func__, __FILE__, __LINE__); \
41} while (0)
1da177e4 42
0b280676
JC
43/*
44 * Various legacy drivers don't really need the BKL in a specific
45 * function, but they *do* need to know that the BKL became available.
46 * This function just avoids wrapping a bunch of lock/unlock pairs
47 * around code which doesn't really need it.
48 */
49static inline void cycle_kernel_lock(void)
50{
51 lock_kernel();
52 unlock_kernel();
53}
54
1da177e4
LT
55#else
56
6de5bd12 57#ifdef CONFIG_BKL /* provoke build bug if not set */
925936eb
FW
58#define lock_kernel()
59#define unlock_kernel()
0b280676 60#define cycle_kernel_lock() do { } while(0)
1da177e4 61#define kernel_locked() 1
6de5bd12
AB
62#endif /* CONFIG_BKL */
63
64#define release_kernel_lock(task) do { } while(0)
65#define reacquire_kernel_lock(task) 0
1da177e4
LT
66
67#endif /* CONFIG_LOCK_KERNEL */
68#endif /* __LINUX_SMPLOCK_H */