Steven Rostedt | c94fbe1 | 2011-01-14 11:25:58 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Because linux/module.h has tracepoints in the header, and ftrace.h |
Paul Gortmaker | de47725 | 2011-05-26 13:46:22 -0400 | [diff] [blame] | 3 | * used to include this file, define_trace.h includes linux/module.h |
Steven Rostedt | c94fbe1 | 2011-01-14 11:25:58 -0500 | [diff] [blame] | 4 | * But we do not want the module.h to override the TRACE_SYSTEM macro |
| 5 | * variable that define_trace.h is processing, so we only set it |
| 6 | * when module events are being processed, which would happen when |
| 7 | * CREATE_TRACE_POINTS is defined. |
| 8 | */ |
| 9 | #ifdef CREATE_TRACE_POINTS |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 10 | #undef TRACE_SYSTEM |
| 11 | #define TRACE_SYSTEM module |
Steven Rostedt | c94fbe1 | 2011-01-14 11:25:58 -0500 | [diff] [blame] | 12 | #endif |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 13 | |
| 14 | #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) |
| 15 | #define _TRACE_MODULE_H |
| 16 | |
| 17 | #include <linux/tracepoint.h> |
| 18 | |
| 19 | #ifdef CONFIG_MODULES |
| 20 | |
| 21 | struct module; |
| 22 | |
| 23 | #define show_module_flags(flags) __print_flags(flags, "", \ |
| 24 | { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \ |
Mathieu Desnoyers | 66cc69e | 2014-03-13 12:11:30 +1030 | [diff] [blame] | 25 | { (1UL << TAINT_OOT_MODULE), "O" }, \ |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 26 | { (1UL << TAINT_FORCED_MODULE), "F" }, \ |
Mathieu Desnoyers | 66cc69e | 2014-03-13 12:11:30 +1030 | [diff] [blame] | 27 | { (1UL << TAINT_CRAP), "C" }, \ |
Mathieu Desnoyers | 132e9a6 | 2014-04-15 11:05:16 -0400 | [diff] [blame] | 28 | { (1UL << TAINT_UNSIGNED_MODULE), "E" }) |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 29 | |
| 30 | TRACE_EVENT(module_load, |
| 31 | |
| 32 | TP_PROTO(struct module *mod), |
| 33 | |
| 34 | TP_ARGS(mod), |
| 35 | |
| 36 | TP_STRUCT__entry( |
| 37 | __field( unsigned int, taints ) |
| 38 | __string( name, mod->name ) |
| 39 | ), |
| 40 | |
| 41 | TP_fast_assign( |
| 42 | __entry->taints = mod->taints; |
| 43 | __assign_str(name, mod->name); |
| 44 | ), |
| 45 | |
| 46 | TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints)) |
| 47 | ); |
| 48 | |
| 49 | TRACE_EVENT(module_free, |
| 50 | |
| 51 | TP_PROTO(struct module *mod), |
| 52 | |
| 53 | TP_ARGS(mod), |
| 54 | |
| 55 | TP_STRUCT__entry( |
| 56 | __string( name, mod->name ) |
| 57 | ), |
| 58 | |
| 59 | TP_fast_assign( |
| 60 | __assign_str(name, mod->name); |
| 61 | ), |
| 62 | |
| 63 | TP_printk("%s", __get_str(name)) |
| 64 | ); |
| 65 | |
Steven Rostedt | eb0c537 | 2010-03-29 14:25:18 -0400 | [diff] [blame] | 66 | #ifdef CONFIG_MODULE_UNLOAD |
| 67 | /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */ |
| 68 | |
Li Zefan | 925684d | 2009-11-26 15:03:23 +0800 | [diff] [blame] | 69 | DECLARE_EVENT_CLASS(module_refcnt, |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 70 | |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 71 | TP_PROTO(struct module *mod, unsigned long ip), |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 72 | |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 73 | TP_ARGS(mod, ip), |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 74 | |
| 75 | TP_STRUCT__entry( |
| 76 | __field( unsigned long, ip ) |
| 77 | __field( int, refcnt ) |
| 78 | __string( name, mod->name ) |
| 79 | ), |
| 80 | |
| 81 | TP_fast_assign( |
| 82 | __entry->ip = ip; |
Romain Izard | 098507a | 2014-03-04 10:09:39 +0100 | [diff] [blame] | 83 | __entry->refcnt = __this_cpu_read(mod->refptr->incs) - __this_cpu_read(mod->refptr->decs); |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 84 | __assign_str(name, mod->name); |
| 85 | ), |
| 86 | |
| 87 | TP_printk("%s call_site=%pf refcnt=%d", |
| 88 | __get_str(name), (void *)__entry->ip, __entry->refcnt) |
| 89 | ); |
| 90 | |
Li Zefan | 925684d | 2009-11-26 15:03:23 +0800 | [diff] [blame] | 91 | DEFINE_EVENT(module_refcnt, module_get, |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 92 | |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 93 | TP_PROTO(struct module *mod, unsigned long ip), |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 94 | |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 95 | TP_ARGS(mod, ip) |
Li Zefan | 925684d | 2009-11-26 15:03:23 +0800 | [diff] [blame] | 96 | ); |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 97 | |
Li Zefan | 925684d | 2009-11-26 15:03:23 +0800 | [diff] [blame] | 98 | DEFINE_EVENT(module_refcnt, module_put, |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 99 | |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 100 | TP_PROTO(struct module *mod, unsigned long ip), |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 101 | |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 102 | TP_ARGS(mod, ip) |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 103 | ); |
Steven Rostedt | eb0c537 | 2010-03-29 14:25:18 -0400 | [diff] [blame] | 104 | #endif /* CONFIG_MODULE_UNLOAD */ |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 105 | |
| 106 | TRACE_EVENT(module_request, |
| 107 | |
| 108 | TP_PROTO(char *name, bool wait, unsigned long ip), |
| 109 | |
| 110 | TP_ARGS(name, wait, ip), |
| 111 | |
| 112 | TP_STRUCT__entry( |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 113 | __field( unsigned long, ip ) |
David Sharp | b5e3008e | 2010-12-03 16:13:20 -0800 | [diff] [blame] | 114 | __field( bool, wait ) |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 115 | __string( name, name ) |
| 116 | ), |
| 117 | |
| 118 | TP_fast_assign( |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 119 | __entry->ip = ip; |
David Sharp | b5e3008e | 2010-12-03 16:13:20 -0800 | [diff] [blame] | 120 | __entry->wait = wait; |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 121 | __assign_str(name, name); |
| 122 | ), |
| 123 | |
| 124 | TP_printk("%s wait=%d call_site=%pf", |
| 125 | __get_str(name), (int)__entry->wait, (void *)__entry->ip) |
| 126 | ); |
| 127 | |
| 128 | #endif /* CONFIG_MODULES */ |
| 129 | |
| 130 | #endif /* _TRACE_MODULE_H */ |
| 131 | |
| 132 | /* This part must be outside protection */ |
| 133 | #include <trace/define_trace.h> |