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