aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-07-31 19:34:24 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-09-24 09:16:31 -0400
commit96a2c464de07d7c72988db851c029b204fc59108 (patch)
tree6e24c17c603268c097069000883b83bc51b4d112 /include/linux
parent0efb4d20723d58edbad29d1ff98a86b631adb5e6 (diff)
tracing/bkl: Add bkl ftrace events
Add two events lock_kernel and unlock_kernel() to trace the bkl uses. This opens the door for userspace tools to perform statistics about the callsites that use it, dependencies with other locks (by pairing the trace with lock events), use with recursivity and so on... The {__reacquire,release}_kernel_lock() events are not traced because these are called from schedule, thus the sched events are sufficient to trace them. Example of a trace: hald-addon-stor-4152 [000] 165.875501: unlock_kernel: depth: 0, fs/block_dev.c:1358 __blkdev_put() hald-addon-stor-4152 [000] 167.832974: lock_kernel: depth: 0, fs/block_dev.c:1167 __blkdev_get() How to get the callsites that acquire it recursively: cd /debug/tracing/events/bkl echo "lock_depth > 0" > filter firefox-4951 [001] 206.276967: unlock_kernel: depth: 1, fs/reiserfs/super.c:575 reiserfs_dirty_inode() You can also filter by file and/or line. v2: Use of FILTER_PTR_STRING attribute for files and lines fields to make them traceable. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/smp_lock.h19
1 files changed, 15 insertions, 4 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
27extern void __lockfunc lock_kernel(void) __acquires(kernel_lock); 28extern void __lockfunc _lock_kernel(void) __acquires(kernel_lock);
28extern void __lockfunc unlock_kernel(void) __releases(kernel_lock); 29extern 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