diff options
-rw-r--r-- | include/linux/smp_lock.h | 19 | ||||
-rw-r--r-- | include/trace/events/bkl.h | 61 | ||||
-rw-r--r-- | lib/kernel_lock.c | 11 |
3 files changed, 82 insertions, 9 deletions
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h index 813be59bf345..d48cc77ba70d 100644 --- a/include/linux/smp_lock.h +++ b/include/linux/smp_lock.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #ifdef CONFIG_LOCK_KERNEL | 4 | #ifdef CONFIG_LOCK_KERNEL |
5 | #include <linux/sched.h> | 5 | #include <linux/sched.h> |
6 | #include <trace/events/bkl.h> | ||
6 | 7 | ||
7 | #define kernel_locked() (current->lock_depth >= 0) | 8 | #define kernel_locked() (current->lock_depth >= 0) |
8 | 9 | ||
@@ -24,8 +25,18 @@ static inline int reacquire_kernel_lock(struct task_struct *task) | |||
24 | return 0; | 25 | return 0; |
25 | } | 26 | } |
26 | 27 | ||
27 | extern void __lockfunc lock_kernel(void) __acquires(kernel_lock); | 28 | extern void __lockfunc _lock_kernel(void) __acquires(kernel_lock); |
28 | extern void __lockfunc unlock_kernel(void) __releases(kernel_lock); | 29 | extern void __lockfunc _unlock_kernel(void) __releases(kernel_lock); |
30 | |||
31 | #define lock_kernel() { \ | ||
32 | trace_lock_kernel(__func__, __FILE__, __LINE__); \ | ||
33 | _lock_kernel(); \ | ||
34 | } | ||
35 | |||
36 | #define unlock_kernel() { \ | ||
37 | trace_unlock_kernel(__func__, __FILE__, __LINE__); \ | ||
38 | _unlock_kernel(); \ | ||
39 | } | ||
29 | 40 | ||
30 | /* | 41 | /* |
31 | * Various legacy drivers don't really need the BKL in a specific | 42 | * Various legacy drivers don't really need the BKL in a specific |
@@ -41,8 +52,8 @@ static inline void cycle_kernel_lock(void) | |||
41 | 52 | ||
42 | #else | 53 | #else |
43 | 54 | ||
44 | #define lock_kernel() do { } while(0) | 55 | #define lock_kernel() trace_lock_kernel(__func__, __FILE__, __LINE__); |
45 | #define unlock_kernel() do { } while(0) | 56 | #define unlock_kernel() trace_unlock_kernel(__func__, __FILE__, __LINE__); |
46 | #define release_kernel_lock(task) do { } while(0) | 57 | #define release_kernel_lock(task) do { } while(0) |
47 | #define cycle_kernel_lock() do { } while(0) | 58 | #define cycle_kernel_lock() do { } while(0) |
48 | #define reacquire_kernel_lock(task) 0 | 59 | #define reacquire_kernel_lock(task) 0 |
diff --git a/include/trace/events/bkl.h b/include/trace/events/bkl.h new file mode 100644 index 000000000000..8abd620a490e --- /dev/null +++ b/include/trace/events/bkl.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM bkl | ||
3 | |||
4 | #if !defined(_TRACE_BKL_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_BKL_H | ||
6 | |||
7 | #include <linux/tracepoint.h> | ||
8 | |||
9 | TRACE_EVENT(lock_kernel, | ||
10 | |||
11 | TP_PROTO(const char *func, const char *file, int line), | ||
12 | |||
13 | TP_ARGS(func, file, line), | ||
14 | |||
15 | TP_STRUCT__entry( | ||
16 | __field( int, lock_depth ) | ||
17 | __field_ext( const char *, func, FILTER_PTR_STRING ) | ||
18 | __field_ext( const char *, file, FILTER_PTR_STRING ) | ||
19 | __field( int, line ) | ||
20 | ), | ||
21 | |||
22 | TP_fast_assign( | ||
23 | /* We want to record the lock_depth after lock is acquired */ | ||
24 | __entry->lock_depth = current->lock_depth + 1; | ||
25 | __entry->func = func; | ||
26 | __entry->file = file; | ||
27 | __entry->line = line; | ||
28 | ), | ||
29 | |||
30 | TP_printk("depth: %d, %s:%d %s()", __entry->lock_depth, | ||
31 | __entry->file, __entry->line, __entry->func) | ||
32 | ); | ||
33 | |||
34 | TRACE_EVENT(unlock_kernel, | ||
35 | |||
36 | TP_PROTO(const char *func, const char *file, int line), | ||
37 | |||
38 | TP_ARGS(func, file, line), | ||
39 | |||
40 | TP_STRUCT__entry( | ||
41 | __field(int, lock_depth) | ||
42 | __field(const char *, func) | ||
43 | __field(const char *, file) | ||
44 | __field(int, line) | ||
45 | ), | ||
46 | |||
47 | TP_fast_assign( | ||
48 | __entry->lock_depth = current->lock_depth; | ||
49 | __entry->func = func; | ||
50 | __entry->file = file; | ||
51 | __entry->line = line; | ||
52 | ), | ||
53 | |||
54 | TP_printk("depth: %d, %s:%d %s()", __entry->lock_depth, | ||
55 | __entry->file, __entry->line, __entry->func) | ||
56 | ); | ||
57 | |||
58 | #endif /* _TRACE_BKL_H */ | ||
59 | |||
60 | /* This part must be outside protection */ | ||
61 | #include <trace/define_trace.h> | ||
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c index 39f1029e3525..5c10b2e1fd08 100644 --- a/lib/kernel_lock.c +++ b/lib/kernel_lock.c | |||
@@ -5,10 +5,11 @@ | |||
5 | * relegated to obsolescence, but used by various less | 5 | * relegated to obsolescence, but used by various less |
6 | * important (or lazy) subsystems. | 6 | * important (or lazy) subsystems. |
7 | */ | 7 | */ |
8 | #include <linux/smp_lock.h> | ||
9 | #include <linux/module.h> | 8 | #include <linux/module.h> |
10 | #include <linux/kallsyms.h> | 9 | #include <linux/kallsyms.h> |
11 | #include <linux/semaphore.h> | 10 | #include <linux/semaphore.h> |
11 | #define CREATE_TRACE_POINTS | ||
12 | #include <linux/smp_lock.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * The 'big kernel lock' | 15 | * The 'big kernel lock' |
@@ -113,7 +114,7 @@ static inline void __unlock_kernel(void) | |||
113 | * This cannot happen asynchronously, so we only need to | 114 | * This cannot happen asynchronously, so we only need to |
114 | * worry about other CPU's. | 115 | * worry about other CPU's. |
115 | */ | 116 | */ |
116 | void __lockfunc lock_kernel(void) | 117 | void __lockfunc _lock_kernel(void) |
117 | { | 118 | { |
118 | int depth = current->lock_depth+1; | 119 | int depth = current->lock_depth+1; |
119 | if (likely(!depth)) | 120 | if (likely(!depth)) |
@@ -121,13 +122,13 @@ void __lockfunc lock_kernel(void) | |||
121 | current->lock_depth = depth; | 122 | current->lock_depth = depth; |
122 | } | 123 | } |
123 | 124 | ||
124 | void __lockfunc unlock_kernel(void) | 125 | void __lockfunc _unlock_kernel(void) |
125 | { | 126 | { |
126 | BUG_ON(current->lock_depth < 0); | 127 | BUG_ON(current->lock_depth < 0); |
127 | if (likely(--current->lock_depth < 0)) | 128 | if (likely(--current->lock_depth < 0)) |
128 | __unlock_kernel(); | 129 | __unlock_kernel(); |
129 | } | 130 | } |
130 | 131 | ||
131 | EXPORT_SYMBOL(lock_kernel); | 132 | EXPORT_SYMBOL(_lock_kernel); |
132 | EXPORT_SYMBOL(unlock_kernel); | 133 | EXPORT_SYMBOL(_unlock_kernel); |
133 | 134 | ||