blob: 21a546d27c0c499e371852b1023be7c67a160140 [file] [log] [blame]
Steven Rostedtc94fbe12011-01-14 11:25:58 -05001/*
2 * Because linux/module.h has tracepoints in the header, and ftrace.h
3 * eventually includes this file, define_trace.h includes linux/module.h
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 Zefan7ead8b82009-08-17 16:56:28 +080010#undef TRACE_SYSTEM
11#define TRACE_SYSTEM module
Steven Rostedtc94fbe12011-01-14 11:25:58 -050012#endif
Li Zefan7ead8b82009-08-17 16:56:28 +080013
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
21struct module;
22
23#define show_module_flags(flags) __print_flags(flags, "", \
24 { (1UL << TAINT_PROPRIETARY_MODULE), "P" }, \
25 { (1UL << TAINT_FORCED_MODULE), "F" }, \
26 { (1UL << TAINT_CRAP), "C" })
27
28TRACE_EVENT(module_load,
29
30 TP_PROTO(struct module *mod),
31
32 TP_ARGS(mod),
33
34 TP_STRUCT__entry(
35 __field( unsigned int, taints )
36 __string( name, mod->name )
37 ),
38
39 TP_fast_assign(
40 __entry->taints = mod->taints;
41 __assign_str(name, mod->name);
42 ),
43
44 TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
45);
46
47TRACE_EVENT(module_free,
48
49 TP_PROTO(struct module *mod),
50
51 TP_ARGS(mod),
52
53 TP_STRUCT__entry(
54 __string( name, mod->name )
55 ),
56
57 TP_fast_assign(
58 __assign_str(name, mod->name);
59 ),
60
61 TP_printk("%s", __get_str(name))
62);
63
Steven Rostedteb0c5372010-03-29 14:25:18 -040064#ifdef CONFIG_MODULE_UNLOAD
65/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
66
Li Zefan925684d2009-11-26 15:03:23 +080067DECLARE_EVENT_CLASS(module_refcnt,
Li Zefan7ead8b82009-08-17 16:56:28 +080068
Li Zefanae832d12010-03-24 10:57:43 +080069 TP_PROTO(struct module *mod, unsigned long ip),
Li Zefan7ead8b82009-08-17 16:56:28 +080070
Li Zefanae832d12010-03-24 10:57:43 +080071 TP_ARGS(mod, ip),
Li Zefan7ead8b82009-08-17 16:56:28 +080072
73 TP_STRUCT__entry(
74 __field( unsigned long, ip )
75 __field( int, refcnt )
76 __string( name, mod->name )
77 ),
78
79 TP_fast_assign(
80 __entry->ip = ip;
Ingo Molnarc1ab9ca2010-04-08 09:06:12 +020081 __entry->refcnt = __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
Li Zefan7ead8b82009-08-17 16:56:28 +080082 __assign_str(name, mod->name);
83 ),
84
85 TP_printk("%s call_site=%pf refcnt=%d",
86 __get_str(name), (void *)__entry->ip, __entry->refcnt)
87);
88
Li Zefan925684d2009-11-26 15:03:23 +080089DEFINE_EVENT(module_refcnt, module_get,
Li Zefan7ead8b82009-08-17 16:56:28 +080090
Li Zefanae832d12010-03-24 10:57:43 +080091 TP_PROTO(struct module *mod, unsigned long ip),
Li Zefan7ead8b82009-08-17 16:56:28 +080092
Li Zefanae832d12010-03-24 10:57:43 +080093 TP_ARGS(mod, ip)
Li Zefan925684d2009-11-26 15:03:23 +080094);
Li Zefan7ead8b82009-08-17 16:56:28 +080095
Li Zefan925684d2009-11-26 15:03:23 +080096DEFINE_EVENT(module_refcnt, module_put,
Li Zefan7ead8b82009-08-17 16:56:28 +080097
Li Zefanae832d12010-03-24 10:57:43 +080098 TP_PROTO(struct module *mod, unsigned long ip),
Li Zefan7ead8b82009-08-17 16:56:28 +080099
Li Zefanae832d12010-03-24 10:57:43 +0800100 TP_ARGS(mod, ip)
Li Zefan7ead8b82009-08-17 16:56:28 +0800101);
Steven Rostedteb0c5372010-03-29 14:25:18 -0400102#endif /* CONFIG_MODULE_UNLOAD */
Li Zefan7ead8b82009-08-17 16:56:28 +0800103
104TRACE_EVENT(module_request,
105
106 TP_PROTO(char *name, bool wait, unsigned long ip),
107
108 TP_ARGS(name, wait, ip),
109
110 TP_STRUCT__entry(
Li Zefan7ead8b82009-08-17 16:56:28 +0800111 __field( unsigned long, ip )
David Sharpb5e3008e2010-12-03 16:13:20 -0800112 __field( bool, wait )
Li Zefan7ead8b82009-08-17 16:56:28 +0800113 __string( name, name )
114 ),
115
116 TP_fast_assign(
Li Zefan7ead8b82009-08-17 16:56:28 +0800117 __entry->ip = ip;
David Sharpb5e3008e2010-12-03 16:13:20 -0800118 __entry->wait = wait;
Li Zefan7ead8b82009-08-17 16:56:28 +0800119 __assign_str(name, name);
120 ),
121
122 TP_printk("%s wait=%d call_site=%pf",
123 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
124);
125
126#endif /* CONFIG_MODULES */
127
128#endif /* _TRACE_MODULE_H */
129
130/* This part must be outside protection */
131#include <trace/define_trace.h>