tracing/kprobes: Fix trace_probe registration order
[deliverable/linux.git] / kernel / trace / trace_events.c
CommitLineData
b77e38aa
SR
1/*
2 * event tracer
3 *
4 * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
5 *
981d081e
SR
6 * - Added format output of fields of the trace point.
7 * This was based off of work by Tom Zanussi <tzanussi@gmail.com>.
8 *
b77e38aa
SR
9 */
10
e6187007
SR
11#include <linux/workqueue.h>
12#include <linux/spinlock.h>
13#include <linux/kthread.h>
b77e38aa
SR
14#include <linux/debugfs.h>
15#include <linux/uaccess.h>
16#include <linux/module.h>
17#include <linux/ctype.h>
e6187007 18#include <linux/delay.h>
b77e38aa 19
020e5f85
LZ
20#include <asm/setup.h>
21
91729ef9 22#include "trace_output.h"
b77e38aa 23
b628b3e6
SR
24#define TRACE_SYSTEM "TRACE_SYSTEM"
25
20c8928a 26DEFINE_MUTEX(event_mutex);
11a241a3 27
a59fd602
SR
28LIST_HEAD(ftrace_events);
29
aeaeae11
FW
30int trace_define_field(struct ftrace_event_call *call, const char *type,
31 const char *name, int offset, int size, int is_signed,
43b51ead 32 int filter_type)
cf027f64
TZ
33{
34 struct ftrace_event_field *field;
35
fe9f57f2 36 field = kzalloc(sizeof(*field), GFP_KERNEL);
cf027f64
TZ
37 if (!field)
38 goto err;
fe9f57f2 39
cf027f64
TZ
40 field->name = kstrdup(name, GFP_KERNEL);
41 if (!field->name)
42 goto err;
fe9f57f2 43
cf027f64
TZ
44 field->type = kstrdup(type, GFP_KERNEL);
45 if (!field->type)
46 goto err;
fe9f57f2 47
43b51ead
LZ
48 if (filter_type == FILTER_OTHER)
49 field->filter_type = filter_assign_type(type);
50 else
51 field->filter_type = filter_type;
52
cf027f64
TZ
53 field->offset = offset;
54 field->size = size;
a118e4d1 55 field->is_signed = is_signed;
aa38e9fc 56
cf027f64
TZ
57 list_add(&field->link, &call->fields);
58
59 return 0;
fe9f57f2 60
cf027f64
TZ
61err:
62 if (field) {
63 kfree(field->name);
64 kfree(field->type);
65 }
66 kfree(field);
fe9f57f2 67
cf027f64
TZ
68 return -ENOMEM;
69}
17c873ec 70EXPORT_SYMBOL_GPL(trace_define_field);
cf027f64 71
e647d6b3
LZ
72#define __common_field(type, item) \
73 ret = trace_define_field(call, #type, "common_" #item, \
74 offsetof(typeof(ent), item), \
75 sizeof(ent.item), \
43b51ead 76 is_signed_type(type), FILTER_OTHER); \
e647d6b3
LZ
77 if (ret) \
78 return ret;
79
80int trace_define_common_fields(struct ftrace_event_call *call)
81{
82 int ret;
83 struct trace_entry ent;
84
85 __common_field(unsigned short, type);
86 __common_field(unsigned char, flags);
87 __common_field(unsigned char, preempt_count);
88 __common_field(int, pid);
89 __common_field(int, tgid);
90
91 return ret;
92}
540b7b8d 93EXPORT_SYMBOL_GPL(trace_define_common_fields);
e647d6b3 94
bd1a5c84 95void trace_destroy_fields(struct ftrace_event_call *call)
2df75e41
LZ
96{
97 struct ftrace_event_field *field, *next;
98
99 list_for_each_entry_safe(field, next, &call->fields, link) {
100 list_del(&field->link);
101 kfree(field->type);
102 kfree(field->name);
103 kfree(field);
104 }
105}
106
fd994989
SR
107static void ftrace_event_enable_disable(struct ftrace_event_call *call,
108 int enable)
109{
fd994989
SR
110 switch (enable) {
111 case 0:
112 if (call->enabled) {
113 call->enabled = 0;
b11c53e1 114 tracing_stop_cmdline_record();
bd1a5c84 115 call->unregfunc(call);
fd994989 116 }
fd994989
SR
117 break;
118 case 1:
da4d0302 119 if (!call->enabled) {
fd994989 120 call->enabled = 1;
b11c53e1 121 tracing_start_cmdline_record();
bd1a5c84 122 call->regfunc(call);
fd994989 123 }
fd994989
SR
124 break;
125 }
126}
127
0e907c99
Z
128static void ftrace_clear_events(void)
129{
130 struct ftrace_event_call *call;
131
132 mutex_lock(&event_mutex);
133 list_for_each_entry(call, &ftrace_events, list) {
134 ftrace_event_enable_disable(call, 0);
135 }
136 mutex_unlock(&event_mutex);
137}
138
8f31bfe5
LZ
139/*
140 * __ftrace_set_clr_event(NULL, NULL, NULL, set) will set/unset all events.
141 */
142static int __ftrace_set_clr_event(const char *match, const char *sub,
143 const char *event, int set)
b77e38aa 144{
a59fd602 145 struct ftrace_event_call *call;
29f93943 146 int ret = -EINVAL;
8f31bfe5
LZ
147
148 mutex_lock(&event_mutex);
149 list_for_each_entry(call, &ftrace_events, list) {
150
151 if (!call->name || !call->regfunc)
152 continue;
153
154 if (match &&
155 strcmp(match, call->name) != 0 &&
156 strcmp(match, call->system) != 0)
157 continue;
158
159 if (sub && strcmp(sub, call->system) != 0)
160 continue;
161
162 if (event && strcmp(event, call->name) != 0)
163 continue;
164
165 ftrace_event_enable_disable(call, set);
166
167 ret = 0;
168 }
169 mutex_unlock(&event_mutex);
170
171 return ret;
172}
173
174static int ftrace_set_clr_event(char *buf, int set)
175{
b628b3e6 176 char *event = NULL, *sub = NULL, *match;
b628b3e6
SR
177
178 /*
179 * The buf format can be <subsystem>:<event-name>
180 * *:<event-name> means any event by that name.
181 * :<event-name> is the same.
182 *
183 * <subsystem>:* means all events in that subsystem
184 * <subsystem>: means the same.
185 *
186 * <name> (no ':') means all events in a subsystem with
187 * the name <name> or any event that matches <name>
188 */
189
190 match = strsep(&buf, ":");
191 if (buf) {
192 sub = match;
193 event = buf;
194 match = NULL;
195
196 if (!strlen(sub) || strcmp(sub, "*") == 0)
197 sub = NULL;
198 if (!strlen(event) || strcmp(event, "*") == 0)
199 event = NULL;
200 }
b77e38aa 201
8f31bfe5 202 return __ftrace_set_clr_event(match, sub, event, set);
b77e38aa
SR
203}
204
4671c794
SR
205/**
206 * trace_set_clr_event - enable or disable an event
207 * @system: system name to match (NULL for any system)
208 * @event: event name to match (NULL for all events, within system)
209 * @set: 1 to enable, 0 to disable
210 *
211 * This is a way for other parts of the kernel to enable or disable
212 * event recording.
213 *
214 * Returns 0 on success, -EINVAL if the parameters do not match any
215 * registered events.
216 */
217int trace_set_clr_event(const char *system, const char *event, int set)
218{
219 return __ftrace_set_clr_event(NULL, system, event, set);
220}
221
b77e38aa
SR
222/* 128 should be much more than enough */
223#define EVENT_BUF_SIZE 127
224
225static ssize_t
226ftrace_event_write(struct file *file, const char __user *ubuf,
227 size_t cnt, loff_t *ppos)
228{
229 size_t read = 0;
230 int i, set = 1;
231 ssize_t ret;
232 char *buf;
233 char ch;
234
235 if (!cnt || cnt < 0)
236 return 0;
237
1852fcce
SR
238 ret = tracing_update_buffers();
239 if (ret < 0)
240 return ret;
241
b77e38aa
SR
242 ret = get_user(ch, ubuf++);
243 if (ret)
244 return ret;
245 read++;
246 cnt--;
247
248 /* skip white space */
249 while (cnt && isspace(ch)) {
250 ret = get_user(ch, ubuf++);
251 if (ret)
252 return ret;
253 read++;
254 cnt--;
255 }
256
257 /* Only white space found? */
258 if (isspace(ch)) {
259 file->f_pos += read;
260 ret = read;
261 return ret;
262 }
263
264 buf = kmalloc(EVENT_BUF_SIZE+1, GFP_KERNEL);
265 if (!buf)
266 return -ENOMEM;
267
268 if (cnt > EVENT_BUF_SIZE)
269 cnt = EVENT_BUF_SIZE;
270
271 i = 0;
272 while (cnt && !isspace(ch)) {
273 if (!i && ch == '!')
274 set = 0;
275 else
276 buf[i++] = ch;
277
278 ret = get_user(ch, ubuf++);
279 if (ret)
280 goto out_free;
281 read++;
282 cnt--;
283 }
284 buf[i] = 0;
285
286 file->f_pos += read;
287
288 ret = ftrace_set_clr_event(buf, set);
289 if (ret)
290 goto out_free;
291
292 ret = read;
293
294 out_free:
295 kfree(buf);
296
297 return ret;
298}
299
300static void *
301t_next(struct seq_file *m, void *v, loff_t *pos)
302{
a59fd602
SR
303 struct list_head *list = m->private;
304 struct ftrace_event_call *call;
b77e38aa
SR
305
306 (*pos)++;
307
40e26815 308 for (;;) {
a59fd602 309 if (list == &ftrace_events)
40e26815
SR
310 return NULL;
311
a59fd602
SR
312 call = list_entry(list, struct ftrace_event_call, list);
313
40e26815
SR
314 /*
315 * The ftrace subsystem is for showing formats only.
316 * They can not be enabled or disabled via the event files.
317 */
318 if (call->regfunc)
319 break;
320
a59fd602 321 list = list->next;
40e26815 322 }
b77e38aa 323
a59fd602 324 m->private = list->next;
b77e38aa
SR
325
326 return call;
327}
328
329static void *t_start(struct seq_file *m, loff_t *pos)
330{
e1c7e2a6
LZ
331 struct ftrace_event_call *call = NULL;
332 loff_t l;
333
20c8928a 334 mutex_lock(&event_mutex);
e1c7e2a6
LZ
335
336 m->private = ftrace_events.next;
337 for (l = 0; l <= *pos; ) {
338 call = t_next(m, NULL, &l);
339 if (!call)
340 break;
341 }
342 return call;
b77e38aa
SR
343}
344
345static void *
346s_next(struct seq_file *m, void *v, loff_t *pos)
347{
a59fd602
SR
348 struct list_head *list = m->private;
349 struct ftrace_event_call *call;
b77e38aa
SR
350
351 (*pos)++;
352
353 retry:
a59fd602 354 if (list == &ftrace_events)
b77e38aa
SR
355 return NULL;
356
a59fd602
SR
357 call = list_entry(list, struct ftrace_event_call, list);
358
b77e38aa 359 if (!call->enabled) {
a59fd602 360 list = list->next;
b77e38aa
SR
361 goto retry;
362 }
363
a59fd602 364 m->private = list->next;
b77e38aa
SR
365
366 return call;
367}
368
369static void *s_start(struct seq_file *m, loff_t *pos)
370{
e1c7e2a6
LZ
371 struct ftrace_event_call *call = NULL;
372 loff_t l;
373
20c8928a 374 mutex_lock(&event_mutex);
e1c7e2a6
LZ
375
376 m->private = ftrace_events.next;
377 for (l = 0; l <= *pos; ) {
378 call = s_next(m, NULL, &l);
379 if (!call)
380 break;
381 }
382 return call;
b77e38aa
SR
383}
384
385static int t_show(struct seq_file *m, void *v)
386{
387 struct ftrace_event_call *call = v;
388
b628b3e6
SR
389 if (strcmp(call->system, TRACE_SYSTEM) != 0)
390 seq_printf(m, "%s:", call->system);
b77e38aa
SR
391 seq_printf(m, "%s\n", call->name);
392
393 return 0;
394}
395
396static void t_stop(struct seq_file *m, void *p)
397{
20c8928a 398 mutex_unlock(&event_mutex);
b77e38aa
SR
399}
400
401static int
402ftrace_event_seq_open(struct inode *inode, struct file *file)
403{
b77e38aa
SR
404 const struct seq_operations *seq_ops;
405
406 if ((file->f_mode & FMODE_WRITE) &&
8650ae32 407 (file->f_flags & O_TRUNC))
b77e38aa
SR
408 ftrace_clear_events();
409
410 seq_ops = inode->i_private;
20c8928a 411 return seq_open(file, seq_ops);
b77e38aa
SR
412}
413
1473e441
SR
414static ssize_t
415event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
416 loff_t *ppos)
417{
418 struct ftrace_event_call *call = filp->private_data;
419 char *buf;
420
da4d0302 421 if (call->enabled)
1473e441
SR
422 buf = "1\n";
423 else
424 buf = "0\n";
425
426 return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
427}
428
429static ssize_t
430event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
431 loff_t *ppos)
432{
433 struct ftrace_event_call *call = filp->private_data;
434 char buf[64];
435 unsigned long val;
436 int ret;
437
438 if (cnt >= sizeof(buf))
439 return -EINVAL;
440
441 if (copy_from_user(&buf, ubuf, cnt))
442 return -EFAULT;
443
444 buf[cnt] = 0;
445
446 ret = strict_strtoul(buf, 10, &val);
447 if (ret < 0)
448 return ret;
449
1852fcce
SR
450 ret = tracing_update_buffers();
451 if (ret < 0)
452 return ret;
453
1473e441
SR
454 switch (val) {
455 case 0:
1473e441 456 case 1:
11a241a3 457 mutex_lock(&event_mutex);
fd994989 458 ftrace_event_enable_disable(call, val);
11a241a3 459 mutex_unlock(&event_mutex);
1473e441
SR
460 break;
461
462 default:
463 return -EINVAL;
464 }
465
466 *ppos += cnt;
467
468 return cnt;
469}
470
8ae79a13
SR
471static ssize_t
472system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
473 loff_t *ppos)
474{
c142b15d 475 const char set_to_char[4] = { '?', '0', '1', 'X' };
8ae79a13
SR
476 const char *system = filp->private_data;
477 struct ftrace_event_call *call;
478 char buf[2];
c142b15d 479 int set = 0;
8ae79a13
SR
480 int ret;
481
8ae79a13
SR
482 mutex_lock(&event_mutex);
483 list_for_each_entry(call, &ftrace_events, list) {
484 if (!call->name || !call->regfunc)
485 continue;
486
8f31bfe5 487 if (system && strcmp(call->system, system) != 0)
8ae79a13
SR
488 continue;
489
490 /*
491 * We need to find out if all the events are set
492 * or if all events or cleared, or if we have
493 * a mixture.
494 */
c142b15d
LZ
495 set |= (1 << !!call->enabled);
496
8ae79a13
SR
497 /*
498 * If we have a mixture, no need to look further.
499 */
c142b15d 500 if (set == 3)
8ae79a13
SR
501 break;
502 }
503 mutex_unlock(&event_mutex);
504
c142b15d 505 buf[0] = set_to_char[set];
8ae79a13 506 buf[1] = '\n';
8ae79a13
SR
507
508 ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
509
510 return ret;
511}
512
513static ssize_t
514system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
515 loff_t *ppos)
516{
517 const char *system = filp->private_data;
518 unsigned long val;
8ae79a13
SR
519 char buf[64];
520 ssize_t ret;
521
522 if (cnt >= sizeof(buf))
523 return -EINVAL;
524
525 if (copy_from_user(&buf, ubuf, cnt))
526 return -EFAULT;
527
528 buf[cnt] = 0;
529
530 ret = strict_strtoul(buf, 10, &val);
531 if (ret < 0)
532 return ret;
533
534 ret = tracing_update_buffers();
535 if (ret < 0)
536 return ret;
537
8f31bfe5 538 if (val != 0 && val != 1)
8ae79a13 539 return -EINVAL;
8ae79a13 540
8f31bfe5 541 ret = __ftrace_set_clr_event(NULL, system, NULL, val);
8ae79a13 542 if (ret)
8f31bfe5 543 goto out;
8ae79a13
SR
544
545 ret = cnt;
546
8f31bfe5 547out:
8ae79a13
SR
548 *ppos += cnt;
549
550 return ret;
551}
552
75db37d2
SR
553extern char *__bad_type_size(void);
554
91729ef9 555#undef FIELD
156b5f17 556#define FIELD(type, name) \
75db37d2 557 sizeof(type) != sizeof(field.name) ? __bad_type_size() : \
cf027f64
TZ
558 #type, "common_" #name, offsetof(typeof(field), name), \
559 sizeof(field.name)
91729ef9
SR
560
561static int trace_write_header(struct trace_seq *s)
562{
563 struct trace_entry field;
564
565 /* struct trace_entry */
566 return trace_seq_printf(s,
ce8eb2bf
SR
567 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
568 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
569 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
570 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
571 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
91729ef9 572 "\n",
89ec0dee 573 FIELD(unsigned short, type),
91729ef9
SR
574 FIELD(unsigned char, flags),
575 FIELD(unsigned char, preempt_count),
576 FIELD(int, pid),
577 FIELD(int, tgid));
578}
da4d0302 579
981d081e
SR
580static ssize_t
581event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
582 loff_t *ppos)
583{
584 struct ftrace_event_call *call = filp->private_data;
585 struct trace_seq *s;
586 char *buf;
587 int r;
588
c269fc8c
TZ
589 if (*ppos)
590 return 0;
591
981d081e
SR
592 s = kmalloc(sizeof(*s), GFP_KERNEL);
593 if (!s)
594 return -ENOMEM;
595
596 trace_seq_init(s);
597
c5e4e192
SR
598 /* If any of the first writes fail, so will the show_format. */
599
600 trace_seq_printf(s, "name: %s\n", call->name);
601 trace_seq_printf(s, "ID: %d\n", call->id);
602 trace_seq_printf(s, "format:\n");
91729ef9
SR
603 trace_write_header(s);
604
e8f9f4d7 605 r = call->show_format(call, s);
981d081e
SR
606 if (!r) {
607 /*
608 * ug! The format output is bigger than a PAGE!!
609 */
610 buf = "FORMAT TOO BIG\n";
611 r = simple_read_from_buffer(ubuf, cnt, ppos,
612 buf, strlen(buf));
613 goto out;
614 }
615
616 r = simple_read_from_buffer(ubuf, cnt, ppos,
617 s->buffer, s->len);
618 out:
619 kfree(s);
620 return r;
621}
622
23725aee
PZ
623static ssize_t
624event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
625{
626 struct ftrace_event_call *call = filp->private_data;
627 struct trace_seq *s;
628 int r;
629
630 if (*ppos)
631 return 0;
632
633 s = kmalloc(sizeof(*s), GFP_KERNEL);
634 if (!s)
635 return -ENOMEM;
636
637 trace_seq_init(s);
638 trace_seq_printf(s, "%d\n", call->id);
639
640 r = simple_read_from_buffer(ubuf, cnt, ppos,
641 s->buffer, s->len);
642 kfree(s);
643 return r;
644}
645
7ce7e424
TZ
646static ssize_t
647event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
648 loff_t *ppos)
649{
650 struct ftrace_event_call *call = filp->private_data;
651 struct trace_seq *s;
652 int r;
653
654 if (*ppos)
655 return 0;
656
657 s = kmalloc(sizeof(*s), GFP_KERNEL);
658 if (!s)
659 return -ENOMEM;
660
661 trace_seq_init(s);
662
8b372562 663 print_event_filter(call, s);
4bda2d51 664 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
7ce7e424
TZ
665
666 kfree(s);
667
668 return r;
669}
670
671static ssize_t
672event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
673 loff_t *ppos)
674{
675 struct ftrace_event_call *call = filp->private_data;
8b372562 676 char *buf;
7ce7e424
TZ
677 int err;
678
8b372562 679 if (cnt >= PAGE_SIZE)
7ce7e424
TZ
680 return -EINVAL;
681
8b372562
TZ
682 buf = (char *)__get_free_page(GFP_TEMPORARY);
683 if (!buf)
7ce7e424
TZ
684 return -ENOMEM;
685
8b372562
TZ
686 if (copy_from_user(buf, ubuf, cnt)) {
687 free_page((unsigned long) buf);
688 return -EFAULT;
7ce7e424 689 }
8b372562 690 buf[cnt] = '\0';
7ce7e424 691
8b372562
TZ
692 err = apply_event_filter(call, buf);
693 free_page((unsigned long) buf);
694 if (err < 0)
44e9c8b7 695 return err;
0a19e53c 696
7ce7e424
TZ
697 *ppos += cnt;
698
699 return cnt;
700}
701
cfb180f3
TZ
702static ssize_t
703subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
704 loff_t *ppos)
705{
706 struct event_subsystem *system = filp->private_data;
707 struct trace_seq *s;
708 int r;
709
710 if (*ppos)
711 return 0;
712
713 s = kmalloc(sizeof(*s), GFP_KERNEL);
714 if (!s)
715 return -ENOMEM;
716
717 trace_seq_init(s);
718
8b372562 719 print_subsystem_event_filter(system, s);
4bda2d51 720 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
cfb180f3
TZ
721
722 kfree(s);
723
724 return r;
725}
726
727static ssize_t
728subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
729 loff_t *ppos)
730{
731 struct event_subsystem *system = filp->private_data;
8b372562 732 char *buf;
cfb180f3
TZ
733 int err;
734
8b372562 735 if (cnt >= PAGE_SIZE)
cfb180f3
TZ
736 return -EINVAL;
737
8b372562
TZ
738 buf = (char *)__get_free_page(GFP_TEMPORARY);
739 if (!buf)
cfb180f3
TZ
740 return -ENOMEM;
741
8b372562
TZ
742 if (copy_from_user(buf, ubuf, cnt)) {
743 free_page((unsigned long) buf);
744 return -EFAULT;
cfb180f3 745 }
8b372562 746 buf[cnt] = '\0';
cfb180f3 747
8b372562
TZ
748 err = apply_subsystem_event_filter(system, buf);
749 free_page((unsigned long) buf);
750 if (err < 0)
44e9c8b7 751 return err;
cfb180f3
TZ
752
753 *ppos += cnt;
754
755 return cnt;
756}
757
d1b182a8
SR
758static ssize_t
759show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
760{
761 int (*func)(struct trace_seq *s) = filp->private_data;
762 struct trace_seq *s;
763 int r;
764
765 if (*ppos)
766 return 0;
767
768 s = kmalloc(sizeof(*s), GFP_KERNEL);
769 if (!s)
770 return -ENOMEM;
771
772 trace_seq_init(s);
773
774 func(s);
775 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
776
777 kfree(s);
778
779 return r;
780}
781
b77e38aa
SR
782static const struct seq_operations show_event_seq_ops = {
783 .start = t_start,
784 .next = t_next,
785 .show = t_show,
786 .stop = t_stop,
787};
788
789static const struct seq_operations show_set_event_seq_ops = {
790 .start = s_start,
791 .next = s_next,
792 .show = t_show,
793 .stop = t_stop,
794};
795
2314c4ae
SR
796static const struct file_operations ftrace_avail_fops = {
797 .open = ftrace_event_seq_open,
798 .read = seq_read,
799 .llseek = seq_lseek,
800 .release = seq_release,
801};
802
b77e38aa
SR
803static const struct file_operations ftrace_set_event_fops = {
804 .open = ftrace_event_seq_open,
805 .read = seq_read,
806 .write = ftrace_event_write,
807 .llseek = seq_lseek,
808 .release = seq_release,
809};
810
1473e441
SR
811static const struct file_operations ftrace_enable_fops = {
812 .open = tracing_open_generic,
813 .read = event_enable_read,
814 .write = event_enable_write,
815};
816
981d081e
SR
817static const struct file_operations ftrace_event_format_fops = {
818 .open = tracing_open_generic,
819 .read = event_format_read,
820};
821
23725aee
PZ
822static const struct file_operations ftrace_event_id_fops = {
823 .open = tracing_open_generic,
824 .read = event_id_read,
825};
826
7ce7e424
TZ
827static const struct file_operations ftrace_event_filter_fops = {
828 .open = tracing_open_generic,
829 .read = event_filter_read,
830 .write = event_filter_write,
831};
832
cfb180f3
TZ
833static const struct file_operations ftrace_subsystem_filter_fops = {
834 .open = tracing_open_generic,
835 .read = subsystem_filter_read,
836 .write = subsystem_filter_write,
837};
838
8ae79a13
SR
839static const struct file_operations ftrace_system_enable_fops = {
840 .open = tracing_open_generic,
841 .read = system_enable_read,
842 .write = system_enable_write,
843};
844
d1b182a8
SR
845static const struct file_operations ftrace_show_header_fops = {
846 .open = tracing_open_generic,
847 .read = show_header,
848};
849
1473e441
SR
850static struct dentry *event_trace_events_dir(void)
851{
852 static struct dentry *d_tracer;
853 static struct dentry *d_events;
854
855 if (d_events)
856 return d_events;
857
858 d_tracer = tracing_init_dentry();
859 if (!d_tracer)
860 return NULL;
861
862 d_events = debugfs_create_dir("events", d_tracer);
863 if (!d_events)
864 pr_warning("Could not create debugfs "
865 "'events' directory\n");
866
867 return d_events;
868}
869
6ecc2d1c
SR
870static LIST_HEAD(event_subsystems);
871
872static struct dentry *
873event_subsystem_dir(const char *name, struct dentry *d_events)
874{
875 struct event_subsystem *system;
e1112b4d 876 struct dentry *entry;
6ecc2d1c
SR
877
878 /* First see if we did not already create this dir */
879 list_for_each_entry(system, &event_subsystems, list) {
dc82ec98
XG
880 if (strcmp(system->name, name) == 0) {
881 system->nr_events++;
6ecc2d1c 882 return system->entry;
dc82ec98 883 }
6ecc2d1c
SR
884 }
885
886 /* need to create new entry */
887 system = kmalloc(sizeof(*system), GFP_KERNEL);
888 if (!system) {
889 pr_warning("No memory to create event subsystem %s\n",
890 name);
891 return d_events;
892 }
893
894 system->entry = debugfs_create_dir(name, d_events);
895 if (!system->entry) {
896 pr_warning("Could not create event subsystem %s\n",
897 name);
898 kfree(system);
899 return d_events;
900 }
901
dc82ec98 902 system->nr_events = 1;
6d723736
SR
903 system->name = kstrdup(name, GFP_KERNEL);
904 if (!system->name) {
905 debugfs_remove(system->entry);
906 kfree(system);
907 return d_events;
908 }
909
6ecc2d1c
SR
910 list_add(&system->list, &event_subsystems);
911
30e673b2 912 system->filter = NULL;
cfb180f3 913
8b372562
TZ
914 system->filter = kzalloc(sizeof(struct event_filter), GFP_KERNEL);
915 if (!system->filter) {
916 pr_warning("Could not allocate filter for subsystem "
917 "'%s'\n", name);
918 return system->entry;
919 }
920
e1112b4d
TZ
921 entry = debugfs_create_file("filter", 0644, system->entry, system,
922 &ftrace_subsystem_filter_fops);
8b372562
TZ
923 if (!entry) {
924 kfree(system->filter);
925 system->filter = NULL;
e1112b4d
TZ
926 pr_warning("Could not create debugfs "
927 "'%s/filter' entry\n", name);
8b372562 928 }
e1112b4d 929
8ae79a13
SR
930 entry = trace_create_file("enable", 0644, system->entry,
931 (void *)system->name,
932 &ftrace_system_enable_fops);
933
6ecc2d1c
SR
934 return system->entry;
935}
936
1473e441 937static int
701970b3
SR
938event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
939 const struct file_operations *id,
940 const struct file_operations *enable,
941 const struct file_operations *filter,
942 const struct file_operations *format)
1473e441
SR
943{
944 struct dentry *entry;
fd994989 945 int ret;
1473e441 946
6ecc2d1c
SR
947 /*
948 * If the trace point header did not define TRACE_SYSTEM
949 * then the system would be called "TRACE_SYSTEM".
950 */
6d723736 951 if (strcmp(call->system, TRACE_SYSTEM) != 0)
6ecc2d1c
SR
952 d_events = event_subsystem_dir(call->system, d_events);
953
1473e441
SR
954 call->dir = debugfs_create_dir(call->name, d_events);
955 if (!call->dir) {
956 pr_warning("Could not create debugfs "
957 "'%s' directory\n", call->name);
958 return -1;
959 }
960
6d723736
SR
961 if (call->regfunc)
962 entry = trace_create_file("enable", 0644, call->dir, call,
701970b3 963 enable);
1473e441 964
af6af30c 965 if (call->id && call->profile_enable)
6d723736 966 entry = trace_create_file("id", 0444, call->dir, call,
701970b3 967 id);
23725aee 968
cf027f64 969 if (call->define_fields) {
14be96c9 970 ret = call->define_fields(call);
cf027f64
TZ
971 if (ret < 0) {
972 pr_warning("Could not initialize trace point"
973 " events/%s\n", call->name);
974 return ret;
975 }
6d723736 976 entry = trace_create_file("filter", 0644, call->dir, call,
701970b3 977 filter);
cf027f64
TZ
978 }
979
981d081e
SR
980 /* A trace may not want to export its format */
981 if (!call->show_format)
982 return 0;
983
6d723736 984 entry = trace_create_file("format", 0444, call->dir, call,
701970b3 985 format);
6d723736
SR
986
987 return 0;
988}
989
bd1a5c84
MH
990static int __trace_add_event_call(struct ftrace_event_call *call)
991{
992 struct dentry *d_events;
993 int ret;
6d723736 994
bd1a5c84
MH
995 if (!call->name)
996 return -EINVAL;
701970b3 997
bd1a5c84
MH
998 if (call->raw_init) {
999 ret = call->raw_init(call);
1000 if (ret < 0) {
1001 if (ret != -ENOSYS)
1002 pr_warning("Could not initialize trace "
1003 "events/%s\n", call->name);
1004 return ret;
1005 }
1006 }
701970b3 1007
bd1a5c84
MH
1008 d_events = event_trace_events_dir();
1009 if (!d_events)
1010 return -ENOENT;
1011
1012 list_add(&call->list, &ftrace_events);
1013 return event_create_dir(call, d_events, &ftrace_event_id_fops,
1014 &ftrace_enable_fops, &ftrace_event_filter_fops,
1015 &ftrace_event_format_fops);
1016}
1017
1018/* Add an additional event_call dynamically */
1019int trace_add_event_call(struct ftrace_event_call *call)
1020{
1021 int ret;
1022 mutex_lock(&event_mutex);
1023 ret = __trace_add_event_call(call);
1024 mutex_unlock(&event_mutex);
1025 return ret;
1026}
701970b3 1027
a2ca5e03
FW
1028static void remove_subsystem_dir(const char *name)
1029{
1030 struct event_subsystem *system;
1031
1032 if (strcmp(name, TRACE_SYSTEM) == 0)
1033 return;
1034
1035 list_for_each_entry(system, &event_subsystems, list) {
1036 if (strcmp(system->name, name) == 0) {
1037 if (!--system->nr_events) {
1038 struct event_filter *filter = system->filter;
1039
1040 debugfs_remove_recursive(system->entry);
1041 list_del(&system->list);
1042 if (filter) {
1043 kfree(filter->filter_string);
1044 kfree(filter);
1045 }
1046 kfree(system->name);
1047 kfree(system);
1048 }
1049 break;
1050 }
1051 }
1052}
1053
bd1a5c84
MH
1054static void __trace_remove_event_call(struct ftrace_event_call *call)
1055{
1056 ftrace_event_enable_disable(call, 0);
1057 if (call->event)
1058 __unregister_ftrace_event(call->event);
1059 debugfs_remove_recursive(call->dir);
1060 list_del(&call->list);
1061 trace_destroy_fields(call);
1062 destroy_preds(call);
1063 remove_subsystem_dir(call->system);
1064}
1065
1066/* Remove an event_call */
1067void trace_remove_event_call(struct ftrace_event_call *call)
1068{
1069 mutex_lock(&event_mutex);
1070 __trace_remove_event_call(call);
1071 mutex_unlock(&event_mutex);
1072}
1073
1074#define for_each_event(event, start, end) \
1075 for (event = start; \
1076 (unsigned long)event < (unsigned long)end; \
1077 event++)
1078
1079#ifdef CONFIG_MODULES
1080
1081static LIST_HEAD(ftrace_module_file_list);
1082
1083/*
1084 * Modules must own their file_operations to keep up with
1085 * reference counting.
1086 */
1087struct ftrace_module_file_ops {
1088 struct list_head list;
1089 struct module *mod;
1090 struct file_operations id;
1091 struct file_operations enable;
1092 struct file_operations format;
1093 struct file_operations filter;
1094};
1095
701970b3
SR
1096static struct ftrace_module_file_ops *
1097trace_create_file_ops(struct module *mod)
1098{
1099 struct ftrace_module_file_ops *file_ops;
1100
1101 /*
1102 * This is a bit of a PITA. To allow for correct reference
1103 * counting, modules must "own" their file_operations.
1104 * To do this, we allocate the file operations that will be
1105 * used in the event directory.
1106 */
1107
1108 file_ops = kmalloc(sizeof(*file_ops), GFP_KERNEL);
1109 if (!file_ops)
1110 return NULL;
1111
1112 file_ops->mod = mod;
1113
1114 file_ops->id = ftrace_event_id_fops;
1115 file_ops->id.owner = mod;
1116
1117 file_ops->enable = ftrace_enable_fops;
1118 file_ops->enable.owner = mod;
1119
1120 file_ops->filter = ftrace_event_filter_fops;
1121 file_ops->filter.owner = mod;
1122
1123 file_ops->format = ftrace_event_format_fops;
1124 file_ops->format.owner = mod;
1125
1126 list_add(&file_ops->list, &ftrace_module_file_list);
1127
1128 return file_ops;
1129}
1130
6d723736
SR
1131static void trace_module_add_events(struct module *mod)
1132{
701970b3 1133 struct ftrace_module_file_ops *file_ops = NULL;
6d723736
SR
1134 struct ftrace_event_call *call, *start, *end;
1135 struct dentry *d_events;
f744bd57 1136 int ret;
6d723736
SR
1137
1138 start = mod->trace_events;
1139 end = mod->trace_events + mod->num_trace_events;
1140
1141 if (start == end)
1142 return;
1143
1144 d_events = event_trace_events_dir();
1145 if (!d_events)
1146 return;
1147
1148 for_each_event(call, start, end) {
1149 /* The linker may leave blanks */
1150 if (!call->name)
1151 continue;
f744bd57 1152 if (call->raw_init) {
bd1a5c84 1153 ret = call->raw_init(call);
f744bd57
JB
1154 if (ret < 0) {
1155 if (ret != -ENOSYS)
1156 pr_warning("Could not initialize trace "
1157 "point events/%s\n", call->name);
1158 continue;
1159 }
1160 }
701970b3
SR
1161 /*
1162 * This module has events, create file ops for this module
1163 * if not already done.
1164 */
1165 if (!file_ops) {
1166 file_ops = trace_create_file_ops(mod);
1167 if (!file_ops)
1168 return;
1169 }
6d723736
SR
1170 call->mod = mod;
1171 list_add(&call->list, &ftrace_events);
701970b3
SR
1172 event_create_dir(call, d_events,
1173 &file_ops->id, &file_ops->enable,
1174 &file_ops->filter, &file_ops->format);
6d723736
SR
1175 }
1176}
1177
1178static void trace_module_remove_events(struct module *mod)
1179{
701970b3 1180 struct ftrace_module_file_ops *file_ops;
6d723736 1181 struct ftrace_event_call *call, *p;
9456f0fa 1182 bool found = false;
6d723736 1183
110bf2b7 1184 down_write(&trace_event_mutex);
6d723736
SR
1185 list_for_each_entry_safe(call, p, &ftrace_events, list) {
1186 if (call->mod == mod) {
9456f0fa 1187 found = true;
bd1a5c84 1188 __trace_remove_event_call(call);
6d723736
SR
1189 }
1190 }
701970b3
SR
1191
1192 /* Now free the file_operations */
1193 list_for_each_entry(file_ops, &ftrace_module_file_list, list) {
1194 if (file_ops->mod == mod)
1195 break;
1196 }
1197 if (&file_ops->list != &ftrace_module_file_list) {
1198 list_del(&file_ops->list);
1199 kfree(file_ops);
1200 }
9456f0fa
SR
1201
1202 /*
1203 * It is safest to reset the ring buffer if the module being unloaded
1204 * registered any events.
1205 */
1206 if (found)
1207 tracing_reset_current_online_cpus();
110bf2b7 1208 up_write(&trace_event_mutex);
6d723736
SR
1209}
1210
61f919a1
SR
1211static int trace_module_notify(struct notifier_block *self,
1212 unsigned long val, void *data)
6d723736
SR
1213{
1214 struct module *mod = data;
1215
1216 mutex_lock(&event_mutex);
1217 switch (val) {
1218 case MODULE_STATE_COMING:
1219 trace_module_add_events(mod);
1220 break;
1221 case MODULE_STATE_GOING:
1222 trace_module_remove_events(mod);
1223 break;
1224 }
1225 mutex_unlock(&event_mutex);
fd994989 1226
1473e441
SR
1227 return 0;
1228}
61f919a1
SR
1229#else
1230static int trace_module_notify(struct notifier_block *self,
1231 unsigned long val, void *data)
1232{
1233 return 0;
1234}
1235#endif /* CONFIG_MODULES */
1473e441 1236
6d723736
SR
1237struct notifier_block trace_module_nb = {
1238 .notifier_call = trace_module_notify,
1239 .priority = 0,
1240};
1241
a59fd602
SR
1242extern struct ftrace_event_call __start_ftrace_events[];
1243extern struct ftrace_event_call __stop_ftrace_events[];
1244
020e5f85
LZ
1245static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
1246
1247static __init int setup_trace_event(char *str)
1248{
1249 strlcpy(bootup_event_buf, str, COMMAND_LINE_SIZE);
1250 ring_buffer_expanded = 1;
1251 tracing_selftest_disabled = 1;
1252
1253 return 1;
1254}
1255__setup("trace_event=", setup_trace_event);
1256
b77e38aa
SR
1257static __init int event_trace_init(void)
1258{
a59fd602 1259 struct ftrace_event_call *call;
b77e38aa
SR
1260 struct dentry *d_tracer;
1261 struct dentry *entry;
1473e441 1262 struct dentry *d_events;
6d723736 1263 int ret;
020e5f85
LZ
1264 char *buf = bootup_event_buf;
1265 char *token;
b77e38aa
SR
1266
1267 d_tracer = tracing_init_dentry();
1268 if (!d_tracer)
1269 return 0;
1270
2314c4ae
SR
1271 entry = debugfs_create_file("available_events", 0444, d_tracer,
1272 (void *)&show_event_seq_ops,
1273 &ftrace_avail_fops);
1274 if (!entry)
1275 pr_warning("Could not create debugfs "
1276 "'available_events' entry\n");
1277
b77e38aa
SR
1278 entry = debugfs_create_file("set_event", 0644, d_tracer,
1279 (void *)&show_set_event_seq_ops,
1280 &ftrace_set_event_fops);
1281 if (!entry)
1282 pr_warning("Could not create debugfs "
1283 "'set_event' entry\n");
1284
1473e441
SR
1285 d_events = event_trace_events_dir();
1286 if (!d_events)
1287 return 0;
1288
d1b182a8
SR
1289 /* ring buffer internal formats */
1290 trace_create_file("header_page", 0444, d_events,
1291 ring_buffer_print_page_header,
1292 &ftrace_show_header_fops);
1293
1294 trace_create_file("header_event", 0444, d_events,
1295 ring_buffer_print_entry_header,
1296 &ftrace_show_header_fops);
1297
8ae79a13 1298 trace_create_file("enable", 0644, d_events,
8f31bfe5 1299 NULL, &ftrace_system_enable_fops);
8ae79a13 1300
6d723736 1301 for_each_event(call, __start_ftrace_events, __stop_ftrace_events) {
1473e441
SR
1302 /* The linker may leave blanks */
1303 if (!call->name)
1304 continue;
f744bd57 1305 if (call->raw_init) {
bd1a5c84 1306 ret = call->raw_init(call);
f744bd57
JB
1307 if (ret < 0) {
1308 if (ret != -ENOSYS)
1309 pr_warning("Could not initialize trace "
1310 "point events/%s\n", call->name);
1311 continue;
1312 }
1313 }
a59fd602 1314 list_add(&call->list, &ftrace_events);
701970b3
SR
1315 event_create_dir(call, d_events, &ftrace_event_id_fops,
1316 &ftrace_enable_fops, &ftrace_event_filter_fops,
1317 &ftrace_event_format_fops);
1473e441
SR
1318 }
1319
020e5f85
LZ
1320 while (true) {
1321 token = strsep(&buf, ",");
1322
1323 if (!token)
1324 break;
1325 if (!*token)
1326 continue;
1327
1328 ret = ftrace_set_clr_event(token, 1);
1329 if (ret)
1330 pr_warning("Failed to enable trace event: %s\n", token);
1331 }
1332
6d723736 1333 ret = register_module_notifier(&trace_module_nb);
55379376 1334 if (ret)
6d723736
SR
1335 pr_warning("Failed to register trace events module notifier\n");
1336
b77e38aa
SR
1337 return 0;
1338}
1339fs_initcall(event_trace_init);
e6187007
SR
1340
1341#ifdef CONFIG_FTRACE_STARTUP_TEST
1342
1343static DEFINE_SPINLOCK(test_spinlock);
1344static DEFINE_SPINLOCK(test_spinlock_irq);
1345static DEFINE_MUTEX(test_mutex);
1346
1347static __init void test_work(struct work_struct *dummy)
1348{
1349 spin_lock(&test_spinlock);
1350 spin_lock_irq(&test_spinlock_irq);
1351 udelay(1);
1352 spin_unlock_irq(&test_spinlock_irq);
1353 spin_unlock(&test_spinlock);
1354
1355 mutex_lock(&test_mutex);
1356 msleep(1);
1357 mutex_unlock(&test_mutex);
1358}
1359
1360static __init int event_test_thread(void *unused)
1361{
1362 void *test_malloc;
1363
1364 test_malloc = kmalloc(1234, GFP_KERNEL);
1365 if (!test_malloc)
1366 pr_info("failed to kmalloc\n");
1367
1368 schedule_on_each_cpu(test_work);
1369
1370 kfree(test_malloc);
1371
1372 set_current_state(TASK_INTERRUPTIBLE);
1373 while (!kthread_should_stop())
1374 schedule();
1375
1376 return 0;
1377}
1378
1379/*
1380 * Do various things that may trigger events.
1381 */
1382static __init void event_test_stuff(void)
1383{
1384 struct task_struct *test_thread;
1385
1386 test_thread = kthread_run(event_test_thread, NULL, "test-events");
1387 msleep(1);
1388 kthread_stop(test_thread);
1389}
1390
1391/*
1392 * For every trace event defined, we will test each trace point separately,
1393 * and then by groups, and finally all trace points.
1394 */
9ea21c1e 1395static __init void event_trace_self_tests(void)
e6187007
SR
1396{
1397 struct ftrace_event_call *call;
1398 struct event_subsystem *system;
e6187007
SR
1399 int ret;
1400
1401 pr_info("Running tests on trace events:\n");
1402
1403 list_for_each_entry(call, &ftrace_events, list) {
1404
1405 /* Only test those that have a regfunc */
1406 if (!call->regfunc)
1407 continue;
1408
1409 pr_info("Testing event %s: ", call->name);
1410
1411 /*
1412 * If an event is already enabled, someone is using
1413 * it and the self test should not be on.
1414 */
1415 if (call->enabled) {
1416 pr_warning("Enabled event during self test!\n");
1417 WARN_ON_ONCE(1);
1418 continue;
1419 }
1420
0e907c99 1421 ftrace_event_enable_disable(call, 1);
e6187007 1422 event_test_stuff();
0e907c99 1423 ftrace_event_enable_disable(call, 0);
e6187007
SR
1424
1425 pr_cont("OK\n");
1426 }
1427
1428 /* Now test at the sub system level */
1429
1430 pr_info("Running tests on trace event systems:\n");
1431
1432 list_for_each_entry(system, &event_subsystems, list) {
1433
1434 /* the ftrace system is special, skip it */
1435 if (strcmp(system->name, "ftrace") == 0)
1436 continue;
1437
1438 pr_info("Testing event system %s: ", system->name);
1439
8f31bfe5 1440 ret = __ftrace_set_clr_event(NULL, system->name, NULL, 1);
e6187007
SR
1441 if (WARN_ON_ONCE(ret)) {
1442 pr_warning("error enabling system %s\n",
1443 system->name);
1444 continue;
1445 }
1446
1447 event_test_stuff();
1448
8f31bfe5 1449 ret = __ftrace_set_clr_event(NULL, system->name, NULL, 0);
e6187007
SR
1450 if (WARN_ON_ONCE(ret))
1451 pr_warning("error disabling system %s\n",
1452 system->name);
1453
1454 pr_cont("OK\n");
1455 }
1456
1457 /* Test with all events enabled */
1458
1459 pr_info("Running tests on all trace events:\n");
1460 pr_info("Testing all events: ");
1461
8f31bfe5 1462 ret = __ftrace_set_clr_event(NULL, NULL, NULL, 1);
e6187007 1463 if (WARN_ON_ONCE(ret)) {
e6187007 1464 pr_warning("error enabling all events\n");
9ea21c1e 1465 return;
e6187007
SR
1466 }
1467
1468 event_test_stuff();
1469
1470 /* reset sysname */
8f31bfe5 1471 ret = __ftrace_set_clr_event(NULL, NULL, NULL, 0);
e6187007
SR
1472 if (WARN_ON_ONCE(ret)) {
1473 pr_warning("error disabling all events\n");
9ea21c1e 1474 return;
e6187007
SR
1475 }
1476
1477 pr_cont("OK\n");
9ea21c1e
SR
1478}
1479
1480#ifdef CONFIG_FUNCTION_TRACER
1481
1482static DEFINE_PER_CPU(atomic_t, test_event_disable);
1483
1484static void
1485function_test_events_call(unsigned long ip, unsigned long parent_ip)
1486{
1487 struct ring_buffer_event *event;
e77405ad 1488 struct ring_buffer *buffer;
9ea21c1e
SR
1489 struct ftrace_entry *entry;
1490 unsigned long flags;
1491 long disabled;
1492 int resched;
1493 int cpu;
1494 int pc;
1495
1496 pc = preempt_count();
1497 resched = ftrace_preempt_disable();
1498 cpu = raw_smp_processor_id();
1499 disabled = atomic_inc_return(&per_cpu(test_event_disable, cpu));
1500
1501 if (disabled != 1)
1502 goto out;
1503
1504 local_save_flags(flags);
1505
e77405ad
SR
1506 event = trace_current_buffer_lock_reserve(&buffer,
1507 TRACE_FN, sizeof(*entry),
9ea21c1e
SR
1508 flags, pc);
1509 if (!event)
1510 goto out;
1511 entry = ring_buffer_event_data(event);
1512 entry->ip = ip;
1513 entry->parent_ip = parent_ip;
1514
e77405ad 1515 trace_nowake_buffer_unlock_commit(buffer, event, flags, pc);
9ea21c1e
SR
1516
1517 out:
1518 atomic_dec(&per_cpu(test_event_disable, cpu));
1519 ftrace_preempt_enable(resched);
1520}
1521
1522static struct ftrace_ops trace_ops __initdata =
1523{
1524 .func = function_test_events_call,
1525};
1526
1527static __init void event_trace_self_test_with_function(void)
1528{
1529 register_ftrace_function(&trace_ops);
1530 pr_info("Running tests again, along with the function tracer\n");
1531 event_trace_self_tests();
1532 unregister_ftrace_function(&trace_ops);
1533}
1534#else
1535static __init void event_trace_self_test_with_function(void)
1536{
1537}
1538#endif
1539
1540static __init int event_trace_self_tests_init(void)
1541{
020e5f85
LZ
1542 if (!tracing_selftest_disabled) {
1543 event_trace_self_tests();
1544 event_trace_self_test_with_function();
1545 }
e6187007
SR
1546
1547 return 0;
1548}
1549
28d20e2d 1550late_initcall(event_trace_self_tests_init);
e6187007
SR
1551
1552#endif
This page took 0.124044 seconds and 5 git commands to generate.