tracing: update comments to match event code macros
[linux-2.6-block.git] / kernel / trace / trace_events_stage_3.h
CommitLineData
c32e827b
SR
1/*
2 * Stage 3 of the trace events.
3 *
4 * Override the macros in <trace/trace_event_types.h> to include the following:
5 *
6 * static void ftrace_event_<call>(proto)
7 * {
efed792d 8 * event_trace_printk(_RET_IP_, "<call>: " <fmt>);
c32e827b
SR
9 * }
10 *
11 * static int ftrace_reg_event_<call>(void)
12 * {
13 * int ret;
14 *
15 * ret = register_trace_<call>(ftrace_event_<call>);
16 * if (!ret)
17 * pr_info("event trace: Could not activate trace point "
18 * "probe to <call>");
19 * return ret;
20 * }
21 *
22 * static void ftrace_unreg_event_<call>(void)
23 * {
24 * unregister_trace_<call>(ftrace_event_<call>);
25 * }
26 *
27 * For those macros defined with TRACE_FORMAT:
28 *
29 * static struct ftrace_event_call __used
30 * __attribute__((__aligned__(4)))
31 * __attribute__((section("_ftrace_events"))) event_<call> = {
32 * .name = "<call>",
33 * .regfunc = ftrace_reg_event_<call>,
34 * .unregfunc = ftrace_unreg_event_<call>,
35 * }
36 *
37 *
157587d7 38 * For those macros defined with TRACE_EVENT:
c32e827b
SR
39 *
40 * static struct ftrace_event_call event_<call>;
41 *
42 * static void ftrace_raw_event_<call>(proto)
43 * {
44 * struct ring_buffer_event *event;
45 * struct ftrace_raw_<call> *entry; <-- defined in stage 1
46 * unsigned long irq_flags;
47 * int pc;
48 *
49 * local_save_flags(irq_flags);
50 * pc = preempt_count();
51 *
52 * event = trace_current_buffer_lock_reserve(event_<call>.id,
53 * sizeof(struct ftrace_raw_<call>),
54 * irq_flags, pc);
55 * if (!event)
56 * return;
57 * entry = ring_buffer_event_data(event);
58 *
0e3d0f05
SR
59 * <assign>; <-- Here we assign the entries by the __field and
60 * __array macros.
c32e827b
SR
61 *
62 * trace_current_buffer_unlock_commit(event, irq_flags, pc);
63 * }
64 *
65 * static int ftrace_raw_reg_event_<call>(void)
66 * {
67 * int ret;
68 *
69 * ret = register_trace_<call>(ftrace_raw_event_<call>);
70 * if (!ret)
71 * pr_info("event trace: Could not activate trace point "
72 * "probe to <call>");
73 * return ret;
74 * }
75 *
76 * static void ftrace_unreg_event_<call>(void)
77 * {
78 * unregister_trace_<call>(ftrace_raw_event_<call>);
79 * }
80 *
81 * static struct trace_event ftrace_event_type_<call> = {
82 * .trace = ftrace_raw_output_<call>, <-- stage 2
83 * };
84 *
85 * static int ftrace_raw_init_event_<call>(void)
86 * {
87 * int id;
88 *
89 * id = register_ftrace_event(&ftrace_event_type_<call>);
90 * if (!id)
91 * return -ENODEV;
92 * event_<call>.id = id;
93 * return 0;
94 * }
95 *
96 * static struct ftrace_event_call __used
97 * __attribute__((__aligned__(4)))
98 * __attribute__((section("_ftrace_events"))) event_<call> = {
99 * .name = "<call>",
0e3d0f05
SR
100 * .system = "<system>",
101 * .raw_init = ftrace_raw_init_event_<call>,
c32e827b
SR
102 * .regfunc = ftrace_reg_event_<call>,
103 * .unregfunc = ftrace_unreg_event_<call>,
981d081e 104 * .show_format = ftrace_format_<call>,
c32e827b
SR
105 * }
106 *
107 */
108
2939b046
SR
109#undef TP_FMT
110#define TP_FMT(fmt, args...) fmt "\n", ##args
c32e827b
SR
111
112#define _TRACE_FORMAT(call, proto, args, fmt) \
113static void ftrace_event_##call(proto) \
114{ \
efed792d 115 event_trace_printk(_RET_IP_, #call ": " fmt); \
c32e827b
SR
116} \
117 \
118static int ftrace_reg_event_##call(void) \
119{ \
120 int ret; \
121 \
122 ret = register_trace_##call(ftrace_event_##call); \
633ddaa7 123 if (ret) \
c32e827b 124 pr_info("event trace: Could not activate trace point " \
633ddaa7 125 "probe to " #call "\n"); \
c32e827b
SR
126 return ret; \
127} \
128 \
129static void ftrace_unreg_event_##call(void) \
130{ \
131 unregister_trace_##call(ftrace_event_##call); \
132} \
133
134
135#undef TRACE_FORMAT
136#define TRACE_FORMAT(call, proto, args, fmt) \
137_TRACE_FORMAT(call, PARAMS(proto), PARAMS(args), PARAMS(fmt)) \
138static struct ftrace_event_call __used \
139__attribute__((__aligned__(4))) \
140__attribute__((section("_ftrace_events"))) event_##call = { \
141 .name = #call, \
9cc26a26 142 .system = __stringify(TRACE_SYSTEM), \
c32e827b
SR
143 .regfunc = ftrace_reg_event_##call, \
144 .unregfunc = ftrace_unreg_event_##call, \
145}
146
da4d0302
SR
147#undef __entry
148#define __entry entry
d20e3b03 149
da4d0302 150#undef TRACE_EVENT
30a8fecc 151#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
c32e827b
SR
152 \
153static struct ftrace_event_call event_##call; \
154 \
155static void ftrace_raw_event_##call(proto) \
156{ \
157 struct ring_buffer_event *event; \
158 struct ftrace_raw_##call *entry; \
159 unsigned long irq_flags; \
160 int pc; \
161 \
162 local_save_flags(irq_flags); \
163 pc = preempt_count(); \
164 \
165 event = trace_current_buffer_lock_reserve(event_##call.id, \
166 sizeof(struct ftrace_raw_##call), \
167 irq_flags, pc); \
168 if (!event) \
169 return; \
170 entry = ring_buffer_event_data(event); \
171 \
da4d0302 172 assign; \
c32e827b
SR
173 \
174 trace_current_buffer_unlock_commit(event, irq_flags, pc); \
175} \
176 \
177static int ftrace_raw_reg_event_##call(void) \
178{ \
179 int ret; \
180 \
181 ret = register_trace_##call(ftrace_raw_event_##call); \
633ddaa7 182 if (ret) \
c32e827b 183 pr_info("event trace: Could not activate trace point " \
633ddaa7 184 "probe to " #call "\n"); \
c32e827b
SR
185 return ret; \
186} \
187 \
188static void ftrace_raw_unreg_event_##call(void) \
189{ \
190 unregister_trace_##call(ftrace_raw_event_##call); \
191} \
192 \
193static struct trace_event ftrace_event_type_##call = { \
194 .trace = ftrace_raw_output_##call, \
195}; \
196 \
197static int ftrace_raw_init_event_##call(void) \
198{ \
199 int id; \
200 \
201 id = register_ftrace_event(&ftrace_event_type_##call); \
202 if (!id) \
203 return -ENODEV; \
204 event_##call.id = id; \
205 return 0; \
206} \
207 \
208static struct ftrace_event_call __used \
209__attribute__((__aligned__(4))) \
210__attribute__((section("_ftrace_events"))) event_##call = { \
211 .name = #call, \
9cc26a26 212 .system = __stringify(TRACE_SYSTEM), \
c32e827b 213 .raw_init = ftrace_raw_init_event_##call, \
da4d0302
SR
214 .regfunc = ftrace_raw_reg_event_##call, \
215 .unregfunc = ftrace_raw_unreg_event_##call, \
981d081e 216 .show_format = ftrace_format_##call, \
c32e827b 217}