forked from torvalds/linux
-
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.
tracing/events: Add module tracepoints
Add trace points to trace module_load, module_free, module_get, module_put and module_request, and use trace_event facility to get the trace output. Here's the sample output: TASK-PID CPU# TIMESTAMP FUNCTION | | | | | <...>-42 [000] 1.758380: module_request: fb0 wait=1 call_site=fb_open ... <...>-60 [000] 3.269403: module_load: scsi_wait_scan <...>-60 [000] 3.269432: module_put: scsi_wait_scan call_site=sys_init_module refcnt=0 <...>-61 [001] 3.273168: module_free: scsi_wait_scan ... <...>-1021 [000] 13.836081: module_load: sunrpc <...>-1021 [000] 13.840589: module_put: sunrpc call_site=sys_init_module refcnt=-1 <...>-1027 [000] 13.848098: module_get: sunrpc call_site=try_module_get refcnt=0 <...>-1027 [000] 13.848308: module_get: sunrpc call_site=get_filesystem refcnt=1 <...>-1027 [000] 13.848692: module_put: sunrpc call_site=put_filesystem refcnt=0 ... modprobe-2587 [001] 1088.437213: module_load: trace_events_sample F modprobe-2587 [001] 1088.437786: module_put: trace_events_sample call_site=sys_init_module refcnt=0 Note: - the taints flag can be 'F', 'C' and/or 'P' if mod->taints != 0 - the module refcnt is percpu, so it can be negative in a specific cpu Signed-off-by: Li Zefan <[email protected]> Acked-by: Rusty Russell <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Rusty Russell <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
- Loading branch information
Li Zefan
authored and
Ingo Molnar
committed
Aug 17, 2009
1 parent
60d970c
commit 7ead8b8
Showing
4 changed files
with
152 additions
and
3 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,126 @@ | ||
#undef TRACE_SYSTEM | ||
#define TRACE_SYSTEM module | ||
|
||
#if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) | ||
#define _TRACE_MODULE_H | ||
|
||
#include <linux/tracepoint.h> | ||
|
||
#ifdef CONFIG_MODULES | ||
|
||
struct module; | ||
|
||
#define show_module_flags(flags) __print_flags(flags, "", \ | ||
{ (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \ | ||
{ (1UL << TAINT_FORCED_MODULE), "F" }, \ | ||
{ (1UL << TAINT_CRAP), "C" }) | ||
|
||
TRACE_EVENT(module_load, | ||
|
||
TP_PROTO(struct module *mod), | ||
|
||
TP_ARGS(mod), | ||
|
||
TP_STRUCT__entry( | ||
__field( unsigned int, taints ) | ||
__string( name, mod->name ) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->taints = mod->taints; | ||
__assign_str(name, mod->name); | ||
), | ||
|
||
TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints)) | ||
); | ||
|
||
TRACE_EVENT(module_free, | ||
|
||
TP_PROTO(struct module *mod), | ||
|
||
TP_ARGS(mod), | ||
|
||
TP_STRUCT__entry( | ||
__string( name, mod->name ) | ||
), | ||
|
||
TP_fast_assign( | ||
__assign_str(name, mod->name); | ||
), | ||
|
||
TP_printk("%s", __get_str(name)) | ||
); | ||
|
||
TRACE_EVENT(module_get, | ||
|
||
TP_PROTO(struct module *mod, unsigned long ip, int refcnt), | ||
|
||
TP_ARGS(mod, ip, refcnt), | ||
|
||
TP_STRUCT__entry( | ||
__field( unsigned long, ip ) | ||
__field( int, refcnt ) | ||
__string( name, mod->name ) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->ip = ip; | ||
__entry->refcnt = refcnt; | ||
__assign_str(name, mod->name); | ||
), | ||
|
||
TP_printk("%s call_site=%pf refcnt=%d", | ||
__get_str(name), (void *)__entry->ip, __entry->refcnt) | ||
); | ||
|
||
TRACE_EVENT(module_put, | ||
|
||
TP_PROTO(struct module *mod, unsigned long ip, int refcnt), | ||
|
||
TP_ARGS(mod, ip, refcnt), | ||
|
||
TP_STRUCT__entry( | ||
__field( unsigned long, ip ) | ||
__field( int, refcnt ) | ||
__string( name, mod->name ) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->ip = ip; | ||
__entry->refcnt = refcnt; | ||
__assign_str(name, mod->name); | ||
), | ||
|
||
TP_printk("%s call_site=%pf refcnt=%d", | ||
__get_str(name), (void *)__entry->ip, __entry->refcnt) | ||
); | ||
|
||
TRACE_EVENT(module_request, | ||
|
||
TP_PROTO(char *name, bool wait, unsigned long ip), | ||
|
||
TP_ARGS(name, wait, ip), | ||
|
||
TP_STRUCT__entry( | ||
__field( bool, wait ) | ||
__field( unsigned long, ip ) | ||
__string( name, name ) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->wait = wait; | ||
__entry->ip = ip; | ||
__assign_str(name, name); | ||
), | ||
|
||
TP_printk("%s wait=%d call_site=%pf", | ||
__get_str(name), (int)__entry->wait, (void *)__entry->ip) | ||
); | ||
|
||
#endif /* CONFIG_MODULES */ | ||
|
||
#endif /* _TRACE_MODULE_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
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