1*c94fbe1dSSteven Rostedt /* 2*c94fbe1dSSteven Rostedt * Because linux/module.h has tracepoints in the header, and ftrace.h 3*c94fbe1dSSteven Rostedt * eventually includes this file, define_trace.h includes linux/module.h 4*c94fbe1dSSteven Rostedt * But we do not want the module.h to override the TRACE_SYSTEM macro 5*c94fbe1dSSteven Rostedt * variable that define_trace.h is processing, so we only set it 6*c94fbe1dSSteven Rostedt * when module events are being processed, which would happen when 7*c94fbe1dSSteven Rostedt * CREATE_TRACE_POINTS is defined. 8*c94fbe1dSSteven Rostedt */ 9*c94fbe1dSSteven Rostedt #ifdef CREATE_TRACE_POINTS 107ead8b83SLi Zefan #undef TRACE_SYSTEM 117ead8b83SLi Zefan #define TRACE_SYSTEM module 12*c94fbe1dSSteven Rostedt #endif 137ead8b83SLi Zefan 147ead8b83SLi Zefan #if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) 157ead8b83SLi Zefan #define _TRACE_MODULE_H 167ead8b83SLi Zefan 177ead8b83SLi Zefan #include <linux/tracepoint.h> 187ead8b83SLi Zefan 197ead8b83SLi Zefan #ifdef CONFIG_MODULES 207ead8b83SLi Zefan 217ead8b83SLi Zefan struct module; 227ead8b83SLi Zefan 237ead8b83SLi Zefan #define show_module_flags(flags) __print_flags(flags, "", \ 247ead8b83SLi Zefan { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \ 257ead8b83SLi Zefan { (1UL << TAINT_FORCED_MODULE), "F" }, \ 267ead8b83SLi Zefan { (1UL << TAINT_CRAP), "C" }) 277ead8b83SLi Zefan 287ead8b83SLi Zefan TRACE_EVENT(module_load, 297ead8b83SLi Zefan 307ead8b83SLi Zefan TP_PROTO(struct module *mod), 317ead8b83SLi Zefan 327ead8b83SLi Zefan TP_ARGS(mod), 337ead8b83SLi Zefan 347ead8b83SLi Zefan TP_STRUCT__entry( 357ead8b83SLi Zefan __field( unsigned int, taints ) 367ead8b83SLi Zefan __string( name, mod->name ) 377ead8b83SLi Zefan ), 387ead8b83SLi Zefan 397ead8b83SLi Zefan TP_fast_assign( 407ead8b83SLi Zefan __entry->taints = mod->taints; 417ead8b83SLi Zefan __assign_str(name, mod->name); 427ead8b83SLi Zefan ), 437ead8b83SLi Zefan 447ead8b83SLi Zefan TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints)) 457ead8b83SLi Zefan ); 467ead8b83SLi Zefan 477ead8b83SLi Zefan TRACE_EVENT(module_free, 487ead8b83SLi Zefan 497ead8b83SLi Zefan TP_PROTO(struct module *mod), 507ead8b83SLi Zefan 517ead8b83SLi Zefan TP_ARGS(mod), 527ead8b83SLi Zefan 537ead8b83SLi Zefan TP_STRUCT__entry( 547ead8b83SLi Zefan __string( name, mod->name ) 557ead8b83SLi Zefan ), 567ead8b83SLi Zefan 577ead8b83SLi Zefan TP_fast_assign( 587ead8b83SLi Zefan __assign_str(name, mod->name); 597ead8b83SLi Zefan ), 607ead8b83SLi Zefan 617ead8b83SLi Zefan TP_printk("%s", __get_str(name)) 627ead8b83SLi Zefan ); 637ead8b83SLi Zefan 64eb0c5377SSteven Rostedt #ifdef CONFIG_MODULE_UNLOAD 65eb0c5377SSteven Rostedt /* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */ 66eb0c5377SSteven Rostedt 67925684d6SLi Zefan DECLARE_EVENT_CLASS(module_refcnt, 687ead8b83SLi Zefan 69ae832d1eSLi Zefan TP_PROTO(struct module *mod, unsigned long ip), 707ead8b83SLi Zefan 71ae832d1eSLi Zefan TP_ARGS(mod, ip), 727ead8b83SLi Zefan 737ead8b83SLi Zefan TP_STRUCT__entry( 747ead8b83SLi Zefan __field( unsigned long, ip ) 757ead8b83SLi Zefan __field( int, refcnt ) 767ead8b83SLi Zefan __string( name, mod->name ) 777ead8b83SLi Zefan ), 787ead8b83SLi Zefan 797ead8b83SLi Zefan TP_fast_assign( 807ead8b83SLi Zefan __entry->ip = ip; 81c1ab9cabSIngo Molnar __entry->refcnt = __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs); 827ead8b83SLi Zefan __assign_str(name, mod->name); 837ead8b83SLi Zefan ), 847ead8b83SLi Zefan 857ead8b83SLi Zefan TP_printk("%s call_site=%pf refcnt=%d", 867ead8b83SLi Zefan __get_str(name), (void *)__entry->ip, __entry->refcnt) 877ead8b83SLi Zefan ); 887ead8b83SLi Zefan 89925684d6SLi Zefan DEFINE_EVENT(module_refcnt, module_get, 907ead8b83SLi Zefan 91ae832d1eSLi Zefan TP_PROTO(struct module *mod, unsigned long ip), 927ead8b83SLi Zefan 93ae832d1eSLi Zefan TP_ARGS(mod, ip) 94925684d6SLi Zefan ); 957ead8b83SLi Zefan 96925684d6SLi Zefan DEFINE_EVENT(module_refcnt, module_put, 977ead8b83SLi Zefan 98ae832d1eSLi Zefan TP_PROTO(struct module *mod, unsigned long ip), 997ead8b83SLi Zefan 100ae832d1eSLi Zefan TP_ARGS(mod, ip) 1017ead8b83SLi Zefan ); 102eb0c5377SSteven Rostedt #endif /* CONFIG_MODULE_UNLOAD */ 1037ead8b83SLi Zefan 1047ead8b83SLi Zefan TRACE_EVENT(module_request, 1057ead8b83SLi Zefan 1067ead8b83SLi Zefan TP_PROTO(char *name, bool wait, unsigned long ip), 1077ead8b83SLi Zefan 1087ead8b83SLi Zefan TP_ARGS(name, wait, ip), 1097ead8b83SLi Zefan 1107ead8b83SLi Zefan TP_STRUCT__entry( 1117ead8b83SLi Zefan __field( bool, wait ) 1127ead8b83SLi Zefan __field( unsigned long, ip ) 1137ead8b83SLi Zefan __string( name, name ) 1147ead8b83SLi Zefan ), 1157ead8b83SLi Zefan 1167ead8b83SLi Zefan TP_fast_assign( 1177ead8b83SLi Zefan __entry->wait = wait; 1187ead8b83SLi Zefan __entry->ip = ip; 1197ead8b83SLi Zefan __assign_str(name, name); 1207ead8b83SLi Zefan ), 1217ead8b83SLi Zefan 1227ead8b83SLi Zefan TP_printk("%s wait=%d call_site=%pf", 1237ead8b83SLi Zefan __get_str(name), (int)__entry->wait, (void *)__entry->ip) 1247ead8b83SLi Zefan ); 1257ead8b83SLi Zefan 1267ead8b83SLi Zefan #endif /* CONFIG_MODULES */ 1277ead8b83SLi Zefan 1287ead8b83SLi Zefan #endif /* _TRACE_MODULE_H */ 1297ead8b83SLi Zefan 1307ead8b83SLi Zefan /* This part must be outside protection */ 1317ead8b83SLi Zefan #include <trace/define_trace.h> 1327ead8b83SLi Zefan 133