Commit | Line | Data |
---|---|---|
f0868d1e SR |
1 | /* |
2 | * trace_output.c | |
3 | * | |
4 | * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> | |
5 | * | |
6 | */ | |
7 | ||
8 | #include <linux/module.h> | |
9 | #include <linux/mutex.h> | |
10 | #include <linux/ftrace.h> | |
11 | ||
12 | #include "trace_output.h" | |
13 | ||
14 | /* must be a power of 2 */ | |
15 | #define EVENT_HASHSIZE 128 | |
16 | ||
4f535968 | 17 | static DECLARE_RWSEM(trace_event_mutex); |
be74b73a SR |
18 | |
19 | DEFINE_PER_CPU(struct trace_seq, ftrace_event_seq); | |
ec081ddc | 20 | EXPORT_PER_CPU_SYMBOL(ftrace_event_seq); |
be74b73a | 21 | |
f0868d1e SR |
22 | static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; |
23 | ||
24 | static int next_event_type = __TRACE_LAST_TYPE + 1; | |
25 | ||
0706f1c4 SR |
26 | void trace_print_seq(struct seq_file *m, struct trace_seq *s) |
27 | { | |
28 | int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len; | |
29 | ||
30 | s->buffer[len] = 0; | |
31 | seq_puts(m, s->buffer); | |
32 | ||
33 | trace_seq_init(s); | |
34 | } | |
35 | ||
5ef841f6 SR |
36 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) |
37 | { | |
38 | struct trace_seq *s = &iter->seq; | |
39 | struct trace_entry *entry = iter->ent; | |
40 | struct bprint_entry *field; | |
41 | int ret; | |
42 | ||
43 | trace_assign_type(field, entry); | |
44 | ||
45 | ret = trace_seq_bprintf(s, field->fmt, field->buf); | |
46 | if (!ret) | |
47 | return TRACE_TYPE_PARTIAL_LINE; | |
48 | ||
49 | return TRACE_TYPE_HANDLED; | |
50 | } | |
51 | ||
52 | enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) | |
53 | { | |
54 | struct trace_seq *s = &iter->seq; | |
55 | struct trace_entry *entry = iter->ent; | |
56 | struct print_entry *field; | |
57 | int ret; | |
58 | ||
59 | trace_assign_type(field, entry); | |
60 | ||
61 | ret = trace_seq_printf(s, "%s", field->buf); | |
62 | if (!ret) | |
63 | return TRACE_TYPE_PARTIAL_LINE; | |
64 | ||
65 | return TRACE_TYPE_HANDLED; | |
66 | } | |
67 | ||
f0868d1e SR |
68 | /** |
69 | * trace_seq_printf - sequence printing of trace information | |
70 | * @s: trace sequence descriptor | |
71 | * @fmt: printf format string | |
72 | * | |
73 | * The tracer may use either sequence operations or its own | |
74 | * copy to user routines. To simplify formating of a trace | |
75 | * trace_seq_printf is used to store strings into a special | |
76 | * buffer (@s). Then the output may be either used by | |
77 | * the sequencer or pulled into another buffer. | |
78 | */ | |
79 | int | |
80 | trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |
81 | { | |
82 | int len = (PAGE_SIZE - 1) - s->len; | |
83 | va_list ap; | |
84 | int ret; | |
85 | ||
86 | if (!len) | |
87 | return 0; | |
88 | ||
89 | va_start(ap, fmt); | |
90 | ret = vsnprintf(s->buffer + s->len, len, fmt, ap); | |
91 | va_end(ap); | |
92 | ||
93 | /* If we can't write it all, don't bother writing anything */ | |
94 | if (ret >= len) | |
95 | return 0; | |
96 | ||
97 | s->len += ret; | |
98 | ||
99 | return len; | |
100 | } | |
17c873ec | 101 | EXPORT_SYMBOL_GPL(trace_seq_printf); |
f0868d1e | 102 | |
769b0441 | 103 | int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) |
1427cdf0 LJ |
104 | { |
105 | int len = (PAGE_SIZE - 1) - s->len; | |
106 | int ret; | |
107 | ||
108 | if (!len) | |
109 | return 0; | |
110 | ||
111 | ret = bstr_printf(s->buffer + s->len, len, fmt, binary); | |
112 | ||
113 | /* If we can't write it all, don't bother writing anything */ | |
114 | if (ret >= len) | |
115 | return 0; | |
116 | ||
117 | s->len += ret; | |
118 | ||
119 | return len; | |
120 | } | |
121 | ||
f0868d1e SR |
122 | /** |
123 | * trace_seq_puts - trace sequence printing of simple string | |
124 | * @s: trace sequence descriptor | |
125 | * @str: simple string to record | |
126 | * | |
127 | * The tracer may use either the sequence operations or its own | |
128 | * copy to user routines. This function records a simple string | |
129 | * into a special buffer (@s) for later retrieval by a sequencer | |
130 | * or other mechanism. | |
131 | */ | |
132 | int trace_seq_puts(struct trace_seq *s, const char *str) | |
133 | { | |
134 | int len = strlen(str); | |
135 | ||
136 | if (len > ((PAGE_SIZE - 1) - s->len)) | |
137 | return 0; | |
138 | ||
139 | memcpy(s->buffer + s->len, str, len); | |
140 | s->len += len; | |
141 | ||
142 | return len; | |
143 | } | |
144 | ||
145 | int trace_seq_putc(struct trace_seq *s, unsigned char c) | |
146 | { | |
147 | if (s->len >= (PAGE_SIZE - 1)) | |
148 | return 0; | |
149 | ||
150 | s->buffer[s->len++] = c; | |
151 | ||
152 | return 1; | |
153 | } | |
154 | ||
b14b70a6 | 155 | int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len) |
f0868d1e SR |
156 | { |
157 | if (len > ((PAGE_SIZE - 1) - s->len)) | |
158 | return 0; | |
159 | ||
160 | memcpy(s->buffer + s->len, mem, len); | |
161 | s->len += len; | |
162 | ||
163 | return len; | |
164 | } | |
165 | ||
b14b70a6 | 166 | int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, size_t len) |
f0868d1e SR |
167 | { |
168 | unsigned char hex[HEX_CHARS]; | |
b14b70a6 | 169 | const unsigned char *data = mem; |
f0868d1e SR |
170 | int i, j; |
171 | ||
172 | #ifdef __BIG_ENDIAN | |
173 | for (i = 0, j = 0; i < len; i++) { | |
174 | #else | |
175 | for (i = len-1, j = 0; i >= 0; i--) { | |
176 | #endif | |
177 | hex[j++] = hex_asc_hi(data[i]); | |
178 | hex[j++] = hex_asc_lo(data[i]); | |
179 | } | |
180 | hex[j++] = ' '; | |
181 | ||
182 | return trace_seq_putmem(s, hex, j); | |
183 | } | |
184 | ||
bdd6df6a EGM |
185 | void *trace_seq_reserve(struct trace_seq *s, size_t len) |
186 | { | |
187 | void *ret; | |
188 | ||
189 | if (len > ((PAGE_SIZE - 1) - s->len)) | |
190 | return NULL; | |
191 | ||
192 | ret = s->buffer + s->len; | |
193 | s->len += len; | |
194 | ||
195 | return ret; | |
196 | } | |
197 | ||
f0868d1e SR |
198 | int trace_seq_path(struct trace_seq *s, struct path *path) |
199 | { | |
200 | unsigned char *p; | |
201 | ||
202 | if (s->len >= (PAGE_SIZE - 1)) | |
203 | return 0; | |
204 | p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len); | |
205 | if (!IS_ERR(p)) { | |
206 | p = mangle_path(s->buffer + s->len, p, "\n"); | |
207 | if (p) { | |
208 | s->len = p - s->buffer; | |
209 | return 1; | |
210 | } | |
211 | } else { | |
212 | s->buffer[s->len++] = '?'; | |
213 | return 1; | |
214 | } | |
215 | ||
216 | return 0; | |
217 | } | |
218 | ||
be74b73a SR |
219 | const char * |
220 | ftrace_print_flags_seq(struct trace_seq *p, const char *delim, | |
221 | unsigned long flags, | |
222 | const struct trace_print_flags *flag_array) | |
223 | { | |
224 | unsigned long mask; | |
225 | const char *str; | |
56d8bd3f | 226 | const char *ret = p->buffer + p->len; |
be74b73a SR |
227 | int i; |
228 | ||
be74b73a SR |
229 | for (i = 0; flag_array[i].name && flags; i++) { |
230 | ||
231 | mask = flag_array[i].mask; | |
232 | if ((flags & mask) != mask) | |
233 | continue; | |
234 | ||
235 | str = flag_array[i].name; | |
236 | flags &= ~mask; | |
237 | if (p->len && delim) | |
238 | trace_seq_puts(p, delim); | |
239 | trace_seq_puts(p, str); | |
240 | } | |
241 | ||
242 | /* check for left over flags */ | |
243 | if (flags) { | |
244 | if (p->len && delim) | |
245 | trace_seq_puts(p, delim); | |
246 | trace_seq_printf(p, "0x%lx", flags); | |
247 | } | |
248 | ||
249 | trace_seq_putc(p, 0); | |
250 | ||
56d8bd3f | 251 | return ret; |
be74b73a | 252 | } |
ec081ddc | 253 | EXPORT_SYMBOL(ftrace_print_flags_seq); |
be74b73a | 254 | |
0f4fc29d SR |
255 | const char * |
256 | ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, | |
257 | const struct trace_print_flags *symbol_array) | |
258 | { | |
259 | int i; | |
56d8bd3f | 260 | const char *ret = p->buffer + p->len; |
0f4fc29d SR |
261 | |
262 | for (i = 0; symbol_array[i].name; i++) { | |
263 | ||
264 | if (val != symbol_array[i].mask) | |
265 | continue; | |
266 | ||
267 | trace_seq_puts(p, symbol_array[i].name); | |
268 | break; | |
269 | } | |
270 | ||
271 | if (!p->len) | |
272 | trace_seq_printf(p, "0x%lx", val); | |
273 | ||
274 | trace_seq_putc(p, 0); | |
275 | ||
56d8bd3f | 276 | return ret; |
0f4fc29d | 277 | } |
ec081ddc | 278 | EXPORT_SYMBOL(ftrace_print_symbols_seq); |
0f4fc29d | 279 | |
f0868d1e SR |
280 | #ifdef CONFIG_KRETPROBES |
281 | static inline const char *kretprobed(const char *name) | |
282 | { | |
283 | static const char tramp_name[] = "kretprobe_trampoline"; | |
284 | int size = sizeof(tramp_name); | |
285 | ||
286 | if (strncmp(tramp_name, name, size) == 0) | |
287 | return "[unknown/kretprobe'd]"; | |
288 | return name; | |
289 | } | |
290 | #else | |
291 | static inline const char *kretprobed(const char *name) | |
292 | { | |
293 | return name; | |
294 | } | |
295 | #endif /* CONFIG_KRETPROBES */ | |
296 | ||
297 | static int | |
298 | seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) | |
299 | { | |
300 | #ifdef CONFIG_KALLSYMS | |
301 | char str[KSYM_SYMBOL_LEN]; | |
302 | const char *name; | |
303 | ||
304 | kallsyms_lookup(address, NULL, NULL, NULL, str); | |
305 | ||
306 | name = kretprobed(str); | |
307 | ||
308 | return trace_seq_printf(s, fmt, name); | |
309 | #endif | |
310 | return 1; | |
311 | } | |
312 | ||
313 | static int | |
314 | seq_print_sym_offset(struct trace_seq *s, const char *fmt, | |
315 | unsigned long address) | |
316 | { | |
317 | #ifdef CONFIG_KALLSYMS | |
318 | char str[KSYM_SYMBOL_LEN]; | |
319 | const char *name; | |
320 | ||
321 | sprint_symbol(str, address); | |
322 | name = kretprobed(str); | |
323 | ||
324 | return trace_seq_printf(s, fmt, name); | |
325 | #endif | |
326 | return 1; | |
327 | } | |
328 | ||
329 | #ifndef CONFIG_64BIT | |
330 | # define IP_FMT "%08lx" | |
331 | #else | |
332 | # define IP_FMT "%016lx" | |
333 | #endif | |
334 | ||
335 | int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, | |
336 | unsigned long ip, unsigned long sym_flags) | |
337 | { | |
338 | struct file *file = NULL; | |
339 | unsigned long vmstart = 0; | |
340 | int ret = 1; | |
341 | ||
342 | if (mm) { | |
343 | const struct vm_area_struct *vma; | |
344 | ||
345 | down_read(&mm->mmap_sem); | |
346 | vma = find_vma(mm, ip); | |
347 | if (vma) { | |
348 | file = vma->vm_file; | |
349 | vmstart = vma->vm_start; | |
350 | } | |
351 | if (file) { | |
352 | ret = trace_seq_path(s, &file->f_path); | |
353 | if (ret) | |
354 | ret = trace_seq_printf(s, "[+0x%lx]", | |
355 | ip - vmstart); | |
356 | } | |
357 | up_read(&mm->mmap_sem); | |
358 | } | |
359 | if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file)) | |
360 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); | |
361 | return ret; | |
362 | } | |
363 | ||
364 | int | |
365 | seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s, | |
366 | unsigned long sym_flags) | |
367 | { | |
368 | struct mm_struct *mm = NULL; | |
369 | int ret = 1; | |
370 | unsigned int i; | |
371 | ||
372 | if (trace_flags & TRACE_ITER_SYM_USEROBJ) { | |
373 | struct task_struct *task; | |
374 | /* | |
375 | * we do the lookup on the thread group leader, | |
376 | * since individual threads might have already quit! | |
377 | */ | |
378 | rcu_read_lock(); | |
379 | task = find_task_by_vpid(entry->ent.tgid); | |
380 | if (task) | |
381 | mm = get_task_mm(task); | |
382 | rcu_read_unlock(); | |
383 | } | |
384 | ||
385 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { | |
386 | unsigned long ip = entry->caller[i]; | |
387 | ||
388 | if (ip == ULONG_MAX || !ret) | |
389 | break; | |
048dc50c | 390 | if (ret) |
391 | ret = trace_seq_puts(s, " => "); | |
f0868d1e SR |
392 | if (!ip) { |
393 | if (ret) | |
394 | ret = trace_seq_puts(s, "??"); | |
048dc50c | 395 | if (ret) |
396 | ret = trace_seq_puts(s, "\n"); | |
f0868d1e SR |
397 | continue; |
398 | } | |
399 | if (!ret) | |
400 | break; | |
401 | if (ret) | |
402 | ret = seq_print_user_ip(s, mm, ip, sym_flags); | |
048dc50c | 403 | ret = trace_seq_puts(s, "\n"); |
f0868d1e SR |
404 | } |
405 | ||
406 | if (mm) | |
407 | mmput(mm); | |
408 | return ret; | |
409 | } | |
410 | ||
411 | int | |
412 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) | |
413 | { | |
414 | int ret; | |
415 | ||
416 | if (!ip) | |
417 | return trace_seq_printf(s, "0"); | |
418 | ||
419 | if (sym_flags & TRACE_ITER_SYM_OFFSET) | |
420 | ret = seq_print_sym_offset(s, "%s", ip); | |
421 | else | |
422 | ret = seq_print_sym_short(s, "%s", ip); | |
423 | ||
424 | if (!ret) | |
425 | return 0; | |
426 | ||
427 | if (sym_flags & TRACE_ITER_SYM_ADDR) | |
428 | ret = trace_seq_printf(s, " <" IP_FMT ">", ip); | |
429 | return ret; | |
430 | } | |
431 | ||
d9793bd8 | 432 | static int |
c4a8e8be FW |
433 | lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu) |
434 | { | |
435 | int hardirq, softirq; | |
4ca53085 | 436 | char comm[TASK_COMM_LEN]; |
c4a8e8be | 437 | |
4ca53085 | 438 | trace_find_cmdline(entry->pid, comm); |
c4a8e8be FW |
439 | hardirq = entry->flags & TRACE_FLAG_HARDIRQ; |
440 | softirq = entry->flags & TRACE_FLAG_SOFTIRQ; | |
d9793bd8 ACM |
441 | |
442 | if (!trace_seq_printf(s, "%8.8s-%-5d %3d%c%c%c", | |
443 | comm, entry->pid, cpu, | |
444 | (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' : | |
445 | (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? | |
446 | 'X' : '.', | |
447 | (entry->flags & TRACE_FLAG_NEED_RESCHED) ? | |
448 | 'N' : '.', | |
449 | (hardirq && softirq) ? 'H' : | |
450 | hardirq ? 'h' : softirq ? 's' : '.')) | |
451 | return 0; | |
c4a8e8be FW |
452 | |
453 | if (entry->preempt_count) | |
d9793bd8 ACM |
454 | return trace_seq_printf(s, "%x", entry->preempt_count); |
455 | return trace_seq_puts(s, "."); | |
c4a8e8be FW |
456 | } |
457 | ||
458 | static unsigned long preempt_mark_thresh = 100; | |
459 | ||
d9793bd8 | 460 | static int |
c4a8e8be FW |
461 | lat_print_timestamp(struct trace_seq *s, u64 abs_usecs, |
462 | unsigned long rel_usecs) | |
463 | { | |
d9793bd8 ACM |
464 | return trace_seq_printf(s, " %4lldus%c: ", abs_usecs, |
465 | rel_usecs > preempt_mark_thresh ? '!' : | |
466 | rel_usecs > 1 ? '+' : ' '); | |
c4a8e8be FW |
467 | } |
468 | ||
469 | int trace_print_context(struct trace_iterator *iter) | |
470 | { | |
471 | struct trace_seq *s = &iter->seq; | |
472 | struct trace_entry *entry = iter->ent; | |
c4a8e8be FW |
473 | unsigned long long t = ns2usecs(iter->ts); |
474 | unsigned long usec_rem = do_div(t, USEC_PER_SEC); | |
475 | unsigned long secs = (unsigned long)t; | |
4ca53085 SR |
476 | char comm[TASK_COMM_LEN]; |
477 | ||
478 | trace_find_cmdline(entry->pid, comm); | |
c4a8e8be | 479 | |
d9793bd8 | 480 | return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ", |
1830b52d | 481 | comm, entry->pid, iter->cpu, secs, usec_rem); |
c4a8e8be FW |
482 | } |
483 | ||
484 | int trace_print_lat_context(struct trace_iterator *iter) | |
485 | { | |
486 | u64 next_ts; | |
d9793bd8 | 487 | int ret; |
c4a8e8be FW |
488 | struct trace_seq *s = &iter->seq; |
489 | struct trace_entry *entry = iter->ent, | |
490 | *next_entry = trace_find_next_entry(iter, NULL, | |
491 | &next_ts); | |
492 | unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE); | |
493 | unsigned long abs_usecs = ns2usecs(iter->ts - iter->tr->time_start); | |
494 | unsigned long rel_usecs; | |
495 | ||
496 | if (!next_entry) | |
497 | next_ts = iter->ts; | |
498 | rel_usecs = ns2usecs(next_ts - iter->ts); | |
499 | ||
500 | if (verbose) { | |
4ca53085 SR |
501 | char comm[TASK_COMM_LEN]; |
502 | ||
503 | trace_find_cmdline(entry->pid, comm); | |
504 | ||
cf8e3474 | 505 | ret = trace_seq_printf(s, "%16s %5d %3d %d %08x %08lx [%08llx]" |
d9793bd8 | 506 | " %ld.%03ldms (+%ld.%03ldms): ", comm, |
1830b52d | 507 | entry->pid, iter->cpu, entry->flags, |
d9793bd8 ACM |
508 | entry->preempt_count, iter->idx, |
509 | ns2usecs(iter->ts), | |
510 | abs_usecs / USEC_PER_MSEC, | |
511 | abs_usecs % USEC_PER_MSEC, | |
512 | rel_usecs / USEC_PER_MSEC, | |
513 | rel_usecs % USEC_PER_MSEC); | |
c4a8e8be | 514 | } else { |
1830b52d | 515 | ret = lat_print_generic(s, entry, iter->cpu); |
d9793bd8 ACM |
516 | if (ret) |
517 | ret = lat_print_timestamp(s, abs_usecs, rel_usecs); | |
c4a8e8be FW |
518 | } |
519 | ||
d9793bd8 | 520 | return ret; |
c4a8e8be FW |
521 | } |
522 | ||
f633cef0 SR |
523 | static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; |
524 | ||
525 | static int task_state_char(unsigned long state) | |
526 | { | |
527 | int bit = state ? __ffs(state) + 1 : 0; | |
528 | ||
529 | return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; | |
530 | } | |
531 | ||
f0868d1e SR |
532 | /** |
533 | * ftrace_find_event - find a registered event | |
534 | * @type: the type of event to look for | |
535 | * | |
536 | * Returns an event of type @type otherwise NULL | |
4f535968 | 537 | * Called with trace_event_read_lock() held. |
f0868d1e SR |
538 | */ |
539 | struct trace_event *ftrace_find_event(int type) | |
540 | { | |
541 | struct trace_event *event; | |
542 | struct hlist_node *n; | |
543 | unsigned key; | |
544 | ||
545 | key = type & (EVENT_HASHSIZE - 1); | |
546 | ||
4f535968 | 547 | hlist_for_each_entry(event, n, &event_hash[key], node) { |
f0868d1e SR |
548 | if (event->type == type) |
549 | return event; | |
550 | } | |
551 | ||
552 | return NULL; | |
553 | } | |
554 | ||
060fa5c8 SR |
555 | static LIST_HEAD(ftrace_event_list); |
556 | ||
557 | static int trace_search_list(struct list_head **list) | |
558 | { | |
559 | struct trace_event *e; | |
560 | int last = __TRACE_LAST_TYPE; | |
561 | ||
562 | if (list_empty(&ftrace_event_list)) { | |
563 | *list = &ftrace_event_list; | |
564 | return last + 1; | |
565 | } | |
566 | ||
567 | /* | |
568 | * We used up all possible max events, | |
569 | * lets see if somebody freed one. | |
570 | */ | |
571 | list_for_each_entry(e, &ftrace_event_list, list) { | |
572 | if (e->type != last + 1) | |
573 | break; | |
574 | last++; | |
575 | } | |
576 | ||
577 | /* Did we used up all 65 thousand events??? */ | |
578 | if ((last + 1) > FTRACE_MAX_EVENT) | |
579 | return 0; | |
580 | ||
581 | *list = &e->list; | |
582 | return last + 1; | |
583 | } | |
584 | ||
4f535968 LJ |
585 | void trace_event_read_lock(void) |
586 | { | |
587 | down_read(&trace_event_mutex); | |
588 | } | |
589 | ||
590 | void trace_event_read_unlock(void) | |
591 | { | |
592 | up_read(&trace_event_mutex); | |
593 | } | |
594 | ||
f0868d1e SR |
595 | /** |
596 | * register_ftrace_event - register output for an event type | |
597 | * @event: the event type to register | |
598 | * | |
599 | * Event types are stored in a hash and this hash is used to | |
600 | * find a way to print an event. If the @event->type is set | |
601 | * then it will use that type, otherwise it will assign a | |
602 | * type to use. | |
603 | * | |
604 | * If you assign your own type, please make sure it is added | |
605 | * to the trace_type enum in trace.h, to avoid collisions | |
606 | * with the dynamic types. | |
607 | * | |
608 | * Returns the event type number or zero on error. | |
609 | */ | |
610 | int register_ftrace_event(struct trace_event *event) | |
611 | { | |
612 | unsigned key; | |
613 | int ret = 0; | |
614 | ||
4f535968 | 615 | down_write(&trace_event_mutex); |
f0868d1e | 616 | |
060fa5c8 | 617 | if (WARN_ON(!event)) |
28bea271 | 618 | goto out; |
28bea271 | 619 | |
060fa5c8 SR |
620 | INIT_LIST_HEAD(&event->list); |
621 | ||
622 | if (!event->type) { | |
48dd0fed | 623 | struct list_head *list = NULL; |
060fa5c8 SR |
624 | |
625 | if (next_event_type > FTRACE_MAX_EVENT) { | |
626 | ||
627 | event->type = trace_search_list(&list); | |
628 | if (!event->type) | |
629 | goto out; | |
630 | ||
631 | } else { | |
632 | ||
633 | event->type = next_event_type++; | |
634 | list = &ftrace_event_list; | |
635 | } | |
636 | ||
637 | if (WARN_ON(ftrace_find_event(event->type))) | |
638 | goto out; | |
639 | ||
640 | list_add_tail(&event->list, list); | |
641 | ||
642 | } else if (event->type > __TRACE_LAST_TYPE) { | |
f0868d1e SR |
643 | printk(KERN_WARNING "Need to add type to trace.h\n"); |
644 | WARN_ON(1); | |
f0868d1e | 645 | goto out; |
060fa5c8 SR |
646 | } else { |
647 | /* Is this event already used */ | |
648 | if (ftrace_find_event(event->type)) | |
649 | goto out; | |
650 | } | |
f0868d1e | 651 | |
268ccda0 ACM |
652 | if (event->trace == NULL) |
653 | event->trace = trace_nop_print; | |
268ccda0 ACM |
654 | if (event->raw == NULL) |
655 | event->raw = trace_nop_print; | |
656 | if (event->hex == NULL) | |
657 | event->hex = trace_nop_print; | |
658 | if (event->binary == NULL) | |
659 | event->binary = trace_nop_print; | |
660 | ||
f0868d1e SR |
661 | key = event->type & (EVENT_HASHSIZE - 1); |
662 | ||
4f535968 | 663 | hlist_add_head(&event->node, &event_hash[key]); |
f0868d1e SR |
664 | |
665 | ret = event->type; | |
666 | out: | |
4f535968 | 667 | up_write(&trace_event_mutex); |
f0868d1e SR |
668 | |
669 | return ret; | |
670 | } | |
17c873ec | 671 | EXPORT_SYMBOL_GPL(register_ftrace_event); |
f0868d1e SR |
672 | |
673 | /** | |
674 | * unregister_ftrace_event - remove a no longer used event | |
675 | * @event: the event to remove | |
676 | */ | |
677 | int unregister_ftrace_event(struct trace_event *event) | |
678 | { | |
4f535968 | 679 | down_write(&trace_event_mutex); |
f0868d1e | 680 | hlist_del(&event->node); |
060fa5c8 | 681 | list_del(&event->list); |
4f535968 | 682 | up_write(&trace_event_mutex); |
f0868d1e SR |
683 | |
684 | return 0; | |
685 | } | |
17c873ec | 686 | EXPORT_SYMBOL_GPL(unregister_ftrace_event); |
f633cef0 SR |
687 | |
688 | /* | |
689 | * Standard events | |
690 | */ | |
691 | ||
ae7462b4 | 692 | enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags) |
f633cef0 | 693 | { |
d9793bd8 | 694 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
695 | } |
696 | ||
697 | /* TRACE_FN */ | |
ae7462b4 | 698 | static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags) |
f633cef0 SR |
699 | { |
700 | struct ftrace_entry *field; | |
2c9b238e | 701 | struct trace_seq *s = &iter->seq; |
f633cef0 | 702 | |
2c9b238e | 703 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
704 | |
705 | if (!seq_print_ip_sym(s, field->ip, flags)) | |
706 | goto partial; | |
707 | ||
708 | if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) { | |
709 | if (!trace_seq_printf(s, " <-")) | |
710 | goto partial; | |
711 | if (!seq_print_ip_sym(s, | |
712 | field->parent_ip, | |
713 | flags)) | |
714 | goto partial; | |
715 | } | |
716 | if (!trace_seq_printf(s, "\n")) | |
717 | goto partial; | |
718 | ||
d9793bd8 | 719 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
720 | |
721 | partial: | |
722 | return TRACE_TYPE_PARTIAL_LINE; | |
723 | } | |
724 | ||
ae7462b4 | 725 | static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags) |
f633cef0 SR |
726 | { |
727 | struct ftrace_entry *field; | |
728 | ||
2c9b238e | 729 | trace_assign_type(field, iter->ent); |
f633cef0 | 730 | |
2c9b238e | 731 | if (!trace_seq_printf(&iter->seq, "%lx %lx\n", |
6c1a99af LJ |
732 | field->ip, |
733 | field->parent_ip)) | |
f633cef0 SR |
734 | return TRACE_TYPE_PARTIAL_LINE; |
735 | ||
d9793bd8 | 736 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
737 | } |
738 | ||
ae7462b4 | 739 | static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags) |
f633cef0 SR |
740 | { |
741 | struct ftrace_entry *field; | |
2c9b238e | 742 | struct trace_seq *s = &iter->seq; |
f633cef0 | 743 | |
2c9b238e | 744 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
745 | |
746 | SEQ_PUT_HEX_FIELD_RET(s, field->ip); | |
747 | SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip); | |
748 | ||
d9793bd8 | 749 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
750 | } |
751 | ||
ae7462b4 | 752 | static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags) |
f633cef0 SR |
753 | { |
754 | struct ftrace_entry *field; | |
2c9b238e | 755 | struct trace_seq *s = &iter->seq; |
f633cef0 | 756 | |
2c9b238e | 757 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
758 | |
759 | SEQ_PUT_FIELD_RET(s, field->ip); | |
760 | SEQ_PUT_FIELD_RET(s, field->parent_ip); | |
761 | ||
d9793bd8 | 762 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
763 | } |
764 | ||
765 | static struct trace_event trace_fn_event = { | |
ef18012b | 766 | .type = TRACE_FN, |
f633cef0 | 767 | .trace = trace_fn_trace, |
f633cef0 SR |
768 | .raw = trace_fn_raw, |
769 | .hex = trace_fn_hex, | |
770 | .binary = trace_fn_bin, | |
771 | }; | |
772 | ||
773 | /* TRACE_CTX an TRACE_WAKE */ | |
ae7462b4 ACM |
774 | static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter, |
775 | char *delim) | |
f633cef0 SR |
776 | { |
777 | struct ctx_switch_entry *field; | |
4ca53085 | 778 | char comm[TASK_COMM_LEN]; |
f633cef0 SR |
779 | int S, T; |
780 | ||
4ca53085 | 781 | |
2c9b238e | 782 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
783 | |
784 | T = task_state_char(field->next_state); | |
785 | S = task_state_char(field->prev_state); | |
4ca53085 | 786 | trace_find_cmdline(field->next_pid, comm); |
2c9b238e ACM |
787 | if (!trace_seq_printf(&iter->seq, |
788 | " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", | |
6c1a99af LJ |
789 | field->prev_pid, |
790 | field->prev_prio, | |
791 | S, delim, | |
792 | field->next_cpu, | |
793 | field->next_pid, | |
794 | field->next_prio, | |
795 | T, comm)) | |
f633cef0 SR |
796 | return TRACE_TYPE_PARTIAL_LINE; |
797 | ||
d9793bd8 | 798 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
799 | } |
800 | ||
ae7462b4 | 801 | static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags) |
f633cef0 | 802 | { |
2c9b238e | 803 | return trace_ctxwake_print(iter, "==>"); |
f633cef0 SR |
804 | } |
805 | ||
ae7462b4 ACM |
806 | static enum print_line_t trace_wake_print(struct trace_iterator *iter, |
807 | int flags) | |
f633cef0 | 808 | { |
2c9b238e | 809 | return trace_ctxwake_print(iter, " +"); |
f633cef0 SR |
810 | } |
811 | ||
2c9b238e | 812 | static int trace_ctxwake_raw(struct trace_iterator *iter, char S) |
f633cef0 SR |
813 | { |
814 | struct ctx_switch_entry *field; | |
815 | int T; | |
816 | ||
2c9b238e | 817 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
818 | |
819 | if (!S) | |
820 | task_state_char(field->prev_state); | |
821 | T = task_state_char(field->next_state); | |
2c9b238e | 822 | if (!trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n", |
6c1a99af LJ |
823 | field->prev_pid, |
824 | field->prev_prio, | |
825 | S, | |
826 | field->next_cpu, | |
827 | field->next_pid, | |
828 | field->next_prio, | |
829 | T)) | |
f633cef0 SR |
830 | return TRACE_TYPE_PARTIAL_LINE; |
831 | ||
d9793bd8 | 832 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
833 | } |
834 | ||
ae7462b4 | 835 | static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags) |
f633cef0 | 836 | { |
2c9b238e | 837 | return trace_ctxwake_raw(iter, 0); |
f633cef0 SR |
838 | } |
839 | ||
ae7462b4 | 840 | static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags) |
f633cef0 | 841 | { |
2c9b238e | 842 | return trace_ctxwake_raw(iter, '+'); |
f633cef0 SR |
843 | } |
844 | ||
845 | ||
2c9b238e | 846 | static int trace_ctxwake_hex(struct trace_iterator *iter, char S) |
f633cef0 SR |
847 | { |
848 | struct ctx_switch_entry *field; | |
2c9b238e | 849 | struct trace_seq *s = &iter->seq; |
f633cef0 SR |
850 | int T; |
851 | ||
2c9b238e | 852 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
853 | |
854 | if (!S) | |
855 | task_state_char(field->prev_state); | |
856 | T = task_state_char(field->next_state); | |
857 | ||
858 | SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid); | |
859 | SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio); | |
860 | SEQ_PUT_HEX_FIELD_RET(s, S); | |
861 | SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu); | |
862 | SEQ_PUT_HEX_FIELD_RET(s, field->next_pid); | |
863 | SEQ_PUT_HEX_FIELD_RET(s, field->next_prio); | |
864 | SEQ_PUT_HEX_FIELD_RET(s, T); | |
865 | ||
d9793bd8 | 866 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
867 | } |
868 | ||
ae7462b4 | 869 | static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags) |
f633cef0 | 870 | { |
2c9b238e | 871 | return trace_ctxwake_hex(iter, 0); |
f633cef0 SR |
872 | } |
873 | ||
ae7462b4 | 874 | static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags) |
f633cef0 | 875 | { |
2c9b238e | 876 | return trace_ctxwake_hex(iter, '+'); |
f633cef0 SR |
877 | } |
878 | ||
ae7462b4 ACM |
879 | static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter, |
880 | int flags) | |
f633cef0 SR |
881 | { |
882 | struct ctx_switch_entry *field; | |
2c9b238e | 883 | struct trace_seq *s = &iter->seq; |
f633cef0 | 884 | |
2c9b238e | 885 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
886 | |
887 | SEQ_PUT_FIELD_RET(s, field->prev_pid); | |
888 | SEQ_PUT_FIELD_RET(s, field->prev_prio); | |
889 | SEQ_PUT_FIELD_RET(s, field->prev_state); | |
890 | SEQ_PUT_FIELD_RET(s, field->next_pid); | |
891 | SEQ_PUT_FIELD_RET(s, field->next_prio); | |
892 | SEQ_PUT_FIELD_RET(s, field->next_state); | |
893 | ||
d9793bd8 | 894 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
895 | } |
896 | ||
897 | static struct trace_event trace_ctx_event = { | |
ef18012b | 898 | .type = TRACE_CTX, |
f633cef0 | 899 | .trace = trace_ctx_print, |
f633cef0 SR |
900 | .raw = trace_ctx_raw, |
901 | .hex = trace_ctx_hex, | |
902 | .binary = trace_ctxwake_bin, | |
903 | }; | |
904 | ||
905 | static struct trace_event trace_wake_event = { | |
ef18012b | 906 | .type = TRACE_WAKE, |
f633cef0 | 907 | .trace = trace_wake_print, |
f633cef0 SR |
908 | .raw = trace_wake_raw, |
909 | .hex = trace_wake_hex, | |
910 | .binary = trace_ctxwake_bin, | |
911 | }; | |
912 | ||
913 | /* TRACE_SPECIAL */ | |
ae7462b4 ACM |
914 | static enum print_line_t trace_special_print(struct trace_iterator *iter, |
915 | int flags) | |
f633cef0 SR |
916 | { |
917 | struct special_entry *field; | |
918 | ||
2c9b238e | 919 | trace_assign_type(field, iter->ent); |
f633cef0 | 920 | |
2c9b238e | 921 | if (!trace_seq_printf(&iter->seq, "# %ld %ld %ld\n", |
6c1a99af LJ |
922 | field->arg1, |
923 | field->arg2, | |
924 | field->arg3)) | |
f633cef0 SR |
925 | return TRACE_TYPE_PARTIAL_LINE; |
926 | ||
d9793bd8 | 927 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
928 | } |
929 | ||
ae7462b4 ACM |
930 | static enum print_line_t trace_special_hex(struct trace_iterator *iter, |
931 | int flags) | |
f633cef0 SR |
932 | { |
933 | struct special_entry *field; | |
2c9b238e | 934 | struct trace_seq *s = &iter->seq; |
f633cef0 | 935 | |
2c9b238e | 936 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
937 | |
938 | SEQ_PUT_HEX_FIELD_RET(s, field->arg1); | |
939 | SEQ_PUT_HEX_FIELD_RET(s, field->arg2); | |
940 | SEQ_PUT_HEX_FIELD_RET(s, field->arg3); | |
941 | ||
d9793bd8 | 942 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
943 | } |
944 | ||
ae7462b4 ACM |
945 | static enum print_line_t trace_special_bin(struct trace_iterator *iter, |
946 | int flags) | |
f633cef0 SR |
947 | { |
948 | struct special_entry *field; | |
2c9b238e | 949 | struct trace_seq *s = &iter->seq; |
f633cef0 | 950 | |
2c9b238e | 951 | trace_assign_type(field, iter->ent); |
f633cef0 SR |
952 | |
953 | SEQ_PUT_FIELD_RET(s, field->arg1); | |
954 | SEQ_PUT_FIELD_RET(s, field->arg2); | |
955 | SEQ_PUT_FIELD_RET(s, field->arg3); | |
956 | ||
d9793bd8 | 957 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
958 | } |
959 | ||
960 | static struct trace_event trace_special_event = { | |
ef18012b | 961 | .type = TRACE_SPECIAL, |
f633cef0 | 962 | .trace = trace_special_print, |
f633cef0 SR |
963 | .raw = trace_special_print, |
964 | .hex = trace_special_hex, | |
965 | .binary = trace_special_bin, | |
966 | }; | |
967 | ||
968 | /* TRACE_STACK */ | |
969 | ||
ae7462b4 ACM |
970 | static enum print_line_t trace_stack_print(struct trace_iterator *iter, |
971 | int flags) | |
f633cef0 SR |
972 | { |
973 | struct stack_entry *field; | |
2c9b238e | 974 | struct trace_seq *s = &iter->seq; |
f633cef0 SR |
975 | int i; |
976 | ||
2c9b238e | 977 | trace_assign_type(field, iter->ent); |
f633cef0 | 978 | |
563af16c | 979 | if (!trace_seq_puts(s, "<stack trace>\n")) |
f11b3f4e | 980 | goto partial; |
f633cef0 | 981 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { |
f11b3f4e | 982 | if (!field->caller[i] || (field->caller[i] == ULONG_MAX)) |
1ec7c484 | 983 | break; |
f11b3f4e | 984 | if (!trace_seq_puts(s, " => ")) |
985 | goto partial; | |
f633cef0 | 986 | |
f11b3f4e | 987 | if (!seq_print_ip_sym(s, field->caller[i], flags)) |
988 | goto partial; | |
6c1a99af | 989 | if (!trace_seq_puts(s, "\n")) |
f633cef0 SR |
990 | goto partial; |
991 | } | |
992 | ||
d9793bd8 | 993 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
994 | |
995 | partial: | |
996 | return TRACE_TYPE_PARTIAL_LINE; | |
997 | } | |
998 | ||
999 | static struct trace_event trace_stack_event = { | |
ef18012b | 1000 | .type = TRACE_STACK, |
f633cef0 | 1001 | .trace = trace_stack_print, |
f633cef0 SR |
1002 | .raw = trace_special_print, |
1003 | .hex = trace_special_hex, | |
1004 | .binary = trace_special_bin, | |
1005 | }; | |
1006 | ||
1007 | /* TRACE_USER_STACK */ | |
ae7462b4 ACM |
1008 | static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, |
1009 | int flags) | |
f633cef0 SR |
1010 | { |
1011 | struct userstack_entry *field; | |
2c9b238e | 1012 | struct trace_seq *s = &iter->seq; |
f633cef0 | 1013 | |
2c9b238e | 1014 | trace_assign_type(field, iter->ent); |
f633cef0 | 1015 | |
563af16c | 1016 | if (!trace_seq_puts(s, "<user stack trace>\n")) |
f633cef0 SR |
1017 | goto partial; |
1018 | ||
048dc50c | 1019 | if (!seq_print_userip_objs(field, s, flags)) |
f633cef0 SR |
1020 | goto partial; |
1021 | ||
d9793bd8 | 1022 | return TRACE_TYPE_HANDLED; |
f633cef0 SR |
1023 | |
1024 | partial: | |
1025 | return TRACE_TYPE_PARTIAL_LINE; | |
1026 | } | |
1027 | ||
1028 | static struct trace_event trace_user_stack_event = { | |
ef18012b | 1029 | .type = TRACE_USER_STACK, |
f633cef0 | 1030 | .trace = trace_user_stack_print, |
f633cef0 SR |
1031 | .raw = trace_special_print, |
1032 | .hex = trace_special_hex, | |
1033 | .binary = trace_special_bin, | |
1034 | }; | |
1035 | ||
48ead020 | 1036 | /* TRACE_BPRINT */ |
1427cdf0 | 1037 | static enum print_line_t |
48ead020 | 1038 | trace_bprint_print(struct trace_iterator *iter, int flags) |
1427cdf0 LJ |
1039 | { |
1040 | struct trace_entry *entry = iter->ent; | |
1041 | struct trace_seq *s = &iter->seq; | |
48ead020 | 1042 | struct bprint_entry *field; |
1427cdf0 LJ |
1043 | |
1044 | trace_assign_type(field, entry); | |
1045 | ||
1046 | if (!seq_print_ip_sym(s, field->ip, flags)) | |
1047 | goto partial; | |
1048 | ||
1049 | if (!trace_seq_puts(s, ": ")) | |
1050 | goto partial; | |
1051 | ||
1052 | if (!trace_seq_bprintf(s, field->fmt, field->buf)) | |
1053 | goto partial; | |
1054 | ||
1055 | return TRACE_TYPE_HANDLED; | |
1056 | ||
1057 | partial: | |
1058 | return TRACE_TYPE_PARTIAL_LINE; | |
1059 | } | |
1060 | ||
769b0441 | 1061 | |
48ead020 FW |
1062 | static enum print_line_t |
1063 | trace_bprint_raw(struct trace_iterator *iter, int flags) | |
1427cdf0 | 1064 | { |
48ead020 | 1065 | struct bprint_entry *field; |
1427cdf0 | 1066 | struct trace_seq *s = &iter->seq; |
1427cdf0 | 1067 | |
769b0441 | 1068 | trace_assign_type(field, iter->ent); |
1427cdf0 LJ |
1069 | |
1070 | if (!trace_seq_printf(s, ": %lx : ", field->ip)) | |
1071 | goto partial; | |
1072 | ||
1073 | if (!trace_seq_bprintf(s, field->fmt, field->buf)) | |
1074 | goto partial; | |
1075 | ||
1076 | return TRACE_TYPE_HANDLED; | |
1077 | ||
1078 | partial: | |
1079 | return TRACE_TYPE_PARTIAL_LINE; | |
1080 | } | |
1081 | ||
769b0441 | 1082 | |
48ead020 FW |
1083 | static struct trace_event trace_bprint_event = { |
1084 | .type = TRACE_BPRINT, | |
1085 | .trace = trace_bprint_print, | |
1086 | .raw = trace_bprint_raw, | |
1087 | }; | |
1088 | ||
1089 | /* TRACE_PRINT */ | |
1090 | static enum print_line_t trace_print_print(struct trace_iterator *iter, | |
1091 | int flags) | |
1092 | { | |
1093 | struct print_entry *field; | |
1094 | struct trace_seq *s = &iter->seq; | |
1095 | ||
1096 | trace_assign_type(field, iter->ent); | |
1097 | ||
1098 | if (!seq_print_ip_sym(s, field->ip, flags)) | |
1099 | goto partial; | |
1100 | ||
1101 | if (!trace_seq_printf(s, ": %s", field->buf)) | |
1102 | goto partial; | |
1103 | ||
1104 | return TRACE_TYPE_HANDLED; | |
1105 | ||
1106 | partial: | |
1107 | return TRACE_TYPE_PARTIAL_LINE; | |
1108 | } | |
1109 | ||
1110 | static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags) | |
1111 | { | |
1112 | struct print_entry *field; | |
1113 | ||
1114 | trace_assign_type(field, iter->ent); | |
1115 | ||
1116 | if (!trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf)) | |
1117 | goto partial; | |
1118 | ||
1119 | return TRACE_TYPE_HANDLED; | |
1120 | ||
1121 | partial: | |
1122 | return TRACE_TYPE_PARTIAL_LINE; | |
1123 | } | |
1124 | ||
769b0441 | 1125 | static struct trace_event trace_print_event = { |
48ead020 | 1126 | .type = TRACE_PRINT, |
769b0441 FW |
1127 | .trace = trace_print_print, |
1128 | .raw = trace_print_raw, | |
1427cdf0 LJ |
1129 | }; |
1130 | ||
48ead020 | 1131 | |
f633cef0 SR |
1132 | static struct trace_event *events[] __initdata = { |
1133 | &trace_fn_event, | |
1134 | &trace_ctx_event, | |
1135 | &trace_wake_event, | |
1136 | &trace_special_event, | |
1137 | &trace_stack_event, | |
1138 | &trace_user_stack_event, | |
48ead020 | 1139 | &trace_bprint_event, |
f633cef0 SR |
1140 | &trace_print_event, |
1141 | NULL | |
1142 | }; | |
1143 | ||
1144 | __init static int init_events(void) | |
1145 | { | |
1146 | struct trace_event *event; | |
1147 | int i, ret; | |
1148 | ||
1149 | for (i = 0; events[i]; i++) { | |
1150 | event = events[i]; | |
1151 | ||
1152 | ret = register_ftrace_event(event); | |
1153 | if (!ret) { | |
1154 | printk(KERN_WARNING "event %d failed to register\n", | |
1155 | event->type); | |
1156 | WARN_ON_ONCE(1); | |
1157 | } | |
1158 | } | |
1159 | ||
1160 | return 0; | |
1161 | } | |
1162 | device_initcall(init_events); |