tracing/events: Add module tracepoints
Subsystems (2)
PATCH RESEND 1/1 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=0Note:
- 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
--- include/linux/module.h | 14 ++++- include/trace/events/module.h | 126 +++++++++++++++++++++++++++++++++++++++++ kernel/kmod.c | 4 + kernel/module.c | 11 ++++ 4 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 include/trace/events/module.h
include/linux/module.h +11 -3
@@ -17,10 +17,12 @@#include <linux/moduleparam.h> #include <linux/marker.h> #include <linux/tracepoint.h> -#include <asm/local.h> +#include <asm/local.h> #include <asm/module.h> +#include <trace/events/module.h> +/* Not Yet Implemented */ #define MODULE_SUPPORTED_DEVICE (name)
@@ -480,7 +482,10 @@ static inline local_t *__module_ref_addr(struct module *mod, int cpu)static inline void __module_get (struct module *module) {if (module) { -local_inc (__module_ref_addr (module,get_cpu ())); +unsigned int cpu =get_cpu (); +local_inc (__module_ref_addr (module, cpu)); +trace_module_get (module, _THIS_IP_, +local_read (__module_ref_addr (module, cpu)));put_cpu (); } }
@@ -491,8 +496,11 @@ static inline int try_module_get(struct module *module)if (module) {unsigned int cpu =get_cpu (); -if (likely (module_is_live (module))) +if (likely (module_is_live (module))) {local_inc (__module_ref_addr (module, cpu)); +trace_module_get (module, _THIS_IP_, +local_read (__module_ref_addr (module, cpu))); + }else ret =0 ;put_cpu ();
include/trace/events/module.h new file +126 -0
126 lines not on this page · raw message
kernel/kmod.c +4 -0
@@ -37,6 +37,8 @@#include <linux/suspend.h> #include <asm/uaccess.h> +#include <trace/events/module.h> +extern int max_threads;static struct workqueue_struct *khelper_wq;
@@ -108,6 +110,8 @@ int __request_module(bool wait, const char *fmt, ...)return -ENOMEM ; } +trace_module_request (module_name, wait, _RET_IP_); + ret =call_usermodehelper (modprobe_path, argv, envp, wait ?UMH_WAIT_PROC :UMH_WAIT_EXEC );atomic_dec (&kmod_concurrent);
kernel/module.c +11 -0
@@ -55,6 +55,11 @@#include <linux/percpu.h> #include <linux/kmemleak.h> +#define CREATE_TRACE_POINTS +#include <trace/events/module.h> + +EXPORT_TRACEPOINT_SYMBOL (module_get); +#if 0 #define DEBUGP printk#else
@@ -940,6 +945,8 @@ void module_put(struct module *module)if (module) {unsigned int cpu =get_cpu ();local_dec (__module_ref_addr (module, cpu)); +trace_module_put (module, _RET_IP_, +local_read (__module_ref_addr (module, cpu)));/* Maybe they're waiting for us to drop reference? */ if (unlikely (!module_is_live (module)))wake_up_process (module->waiter);
@@ -1491,6 +1498,8 @@ static int __unlink_module(void *_mod)/* Free a module, remove from lists, etc (must hold module_mutex). */ static void free_module (struct module *mod) { +trace_module_free (mod); +/* Delete from various lists */ stop_machine (__unlink_module, mod,NULL );remove_notes_attrs (mod);
@@ -2358,6 +2367,8 @@ static noinline struct module *load_module(void __user *umod,/* Get rid of temporary copy */ vfree (hdr); +trace_module_load (mod); +/* Done! */ return mod;
Signature · 1 line
1.6.3
Commit-ID: 7ead8b8313d92b3a69a1a61b0dcbc4cd66c960dc Gitweb: http://git.kernel.org/tip/7ead8b8313d92b3a69a1a61b0dcbc4cd66c960dc Author: Li Zefan <[email protected]> AuthorDate: Mon, 17 Aug 2009 16:56:28 +0800 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 17 Aug 2009 11:25:08 +0200
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=0Note:
- 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
LKML-Reference: <[email protected]>
--- include/linux/module.h | 14 ++++- include/trace/events/module.h | 126 +++++++++++++++++++++++++++++++++++++++++ kernel/kmod.c | 4 + kernel/module.c | 11 ++++ 4 files changed, 152 insertions(+), 3 deletions(-)
include/linux/module.h +11 -3
@@ -17,10 +17,12 @@#include <linux/moduleparam.h> #include <linux/marker.h> #include <linux/tracepoint.h> -#include <asm/local.h> +#include <asm/local.h> #include <asm/module.h> +#include <trace/events/module.h> +/* Not Yet Implemented */ #define MODULE_SUPPORTED_DEVICE (name)
@@ -462,7 +464,10 @@ static inline local_t *__module_ref_addr(struct module *mod, int cpu)static inline void __module_get (struct module *module) {if (module) { -local_inc (__module_ref_addr (module,get_cpu ())); +unsigned int cpu =get_cpu (); +local_inc (__module_ref_addr (module, cpu)); +trace_module_get (module, _THIS_IP_, +local_read (__module_ref_addr (module, cpu)));put_cpu (); } }
@@ -473,8 +478,11 @@ static inline int try_module_get(struct module *module)if (module) {unsigned int cpu =get_cpu (); -if (likely (module_is_live (module))) +if (likely (module_is_live (module))) {local_inc (__module_ref_addr (module, cpu)); +trace_module_get (module, _THIS_IP_, +local_read (__module_ref_addr (module, cpu))); + }else ret =0 ;put_cpu ();
include/trace/events/module.h new file +126 -0
126 lines not on this page · raw message
kernel/kmod.c +4 -0
@@ -37,6 +37,8 @@#include <linux/suspend.h> #include <asm/uaccess.h> +#include <trace/events/module.h> +extern int max_threads;static struct workqueue_struct *khelper_wq;
@@ -108,6 +110,8 @@ int __request_module(bool wait, const char *fmt, ...)return -ENOMEM ; } +trace_module_request (module_name, wait, _RET_IP_); + ret =call_usermodehelper (modprobe_path, argv, envp, wait ?UMH_WAIT_PROC :UMH_WAIT_EXEC );atomic_dec (&kmod_concurrent);
kernel/module.c +11 -0
@@ -55,6 +55,11 @@#include <linux/percpu.h> #include <linux/kmemleak.h> +#define CREATE_TRACE_POINTS +#include <trace/events/module.h> + +EXPORT_TRACEPOINT_SYMBOL (module_get); +#if 0 #define DEBUGP printk#else
@@ -940,6 +945,8 @@ void module_put(struct module *module)if (module) {unsigned int cpu =get_cpu ();local_dec (__module_ref_addr (module, cpu)); +trace_module_put (module, _RET_IP_, +local_read (__module_ref_addr (module, cpu)));/* Maybe they're waiting for us to drop reference? */ if (unlikely (!module_is_live (module)))wake_up_process (module->waiter);
@@ -1491,6 +1498,8 @@ static int __unlink_module(void *_mod)/* Free a module, remove from lists, etc (must hold module_mutex). */ static void free_module (struct module *mod) { +trace_module_free (mod); +/* Delete from various lists */ stop_machine (__unlink_module, mod,NULL );remove_notes_attrs (mod);
@@ -2358,6 +2367,8 @@ static noinline struct module *load_module(void __user *umod,/* Get rid of temporary copy */ vfree (hdr); +trace_module_load (mod); +/* Done! */ return mod;