-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Frederic Weisbecker
committed
Sep 24, 2009
1 parent
0efb4d2
commit 96a2c46
Showing
3 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#undef TRACE_SYSTEM | ||
#define TRACE_SYSTEM bkl | ||
|
||
#if !defined(_TRACE_BKL_H) || defined(TRACE_HEADER_MULTI_READ) | ||
#define _TRACE_BKL_H | ||
|
||
#include <linux/tracepoint.h> | ||
|
||
TRACE_EVENT(lock_kernel, | ||
|
||
TP_PROTO(const char *func, const char *file, int line), | ||
|
||
TP_ARGS(func, file, line), | ||
|
||
TP_STRUCT__entry( | ||
__field( int, lock_depth ) | ||
__field_ext( const char *, func, FILTER_PTR_STRING ) | ||
__field_ext( const char *, file, FILTER_PTR_STRING ) | ||
__field( int, line ) | ||
), | ||
|
||
TP_fast_assign( | ||
/* We want to record the lock_depth after lock is acquired */ | ||
__entry->lock_depth = current->lock_depth + 1; | ||
__entry->func = func; | ||
__entry->file = file; | ||
__entry->line = line; | ||
), | ||
|
||
TP_printk("depth: %d, %s:%d %s()", __entry->lock_depth, | ||
__entry->file, __entry->line, __entry->func) | ||
); | ||
|
||
TRACE_EVENT(unlock_kernel, | ||
|
||
TP_PROTO(const char *func, const char *file, int line), | ||
|
||
TP_ARGS(func, file, line), | ||
|
||
TP_STRUCT__entry( | ||
__field(int, lock_depth) | ||
__field(const char *, func) | ||
__field(const char *, file) | ||
__field(int, line) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->lock_depth = current->lock_depth; | ||
__entry->func = func; | ||
__entry->file = file; | ||
__entry->line = line; | ||
), | ||
|
||
TP_printk("depth: %d, %s:%d %s()", __entry->lock_depth, | ||
__entry->file, __entry->line, __entry->func) | ||
); | ||
|
||
#endif /* _TRACE_BKL_H */ | ||
|
||
/* This part must be outside protection */ | ||
#include <trace/define_trace.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters