blob: 97470c48956ecf3d6a79effaebf45a359710e2ca [file] [log] [blame]
Steven Rostedtb77e38a2009-02-24 10:21:36 -05001/*
2 * event tracer
3 *
4 * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
5 *
Steven Rostedt981d0812009-03-02 13:53:59 -05006 * - Added format output of fields of the trace point.
7 * This was based off of work by Tom Zanussi <tzanussi@gmail.com>.
8 *
Steven Rostedtb77e38a2009-02-24 10:21:36 -05009 */
10
11#include <linux/debugfs.h>
12#include <linux/uaccess.h>
13#include <linux/module.h>
14#include <linux/ctype.h>
15
Steven Rostedt91729ef92009-03-02 15:03:01 -050016#include "trace_output.h"
Steven Rostedtb77e38a2009-02-24 10:21:36 -050017
Steven Rostedtb628b3e2009-02-27 23:32:58 -050018#define TRACE_SYSTEM "TRACE_SYSTEM"
19
Steven Rostedt11a241a2009-03-02 11:49:04 -050020static DEFINE_MUTEX(event_mutex);
21
Tom Zanussicf027f62009-03-22 03:30:39 -050022int trace_define_field(struct ftrace_event_call *call, char *type,
23 char *name, int offset, int size)
24{
25 struct ftrace_event_field *field;
26
27 field = kmalloc(sizeof(*field), GFP_KERNEL);
28 if (!field)
29 goto err;
30 field->name = kstrdup(name, GFP_KERNEL);
31 if (!field->name)
32 goto err;
33 field->type = kstrdup(type, GFP_KERNEL);
34 if (!field->type)
35 goto err;
36 field->offset = offset;
37 field->size = size;
38 list_add(&field->link, &call->fields);
39
40 return 0;
41err:
42 if (field) {
43 kfree(field->name);
44 kfree(field->type);
45 }
46 kfree(field);
47 return -ENOMEM;
48}
49
Steven Rostedtb77e38a2009-02-24 10:21:36 -050050static void ftrace_clear_events(void)
51{
52 struct ftrace_event_call *call = (void *)__start_ftrace_events;
53
54
55 while ((unsigned long)call < (unsigned long)__stop_ftrace_events) {
56
57 if (call->enabled) {
58 call->enabled = 0;
59 call->unregfunc();
60 }
61 call++;
62 }
63}
64
Steven Rostedtfd994982009-02-28 02:41:25 -050065static void ftrace_event_enable_disable(struct ftrace_event_call *call,
66 int enable)
67{
68
69 switch (enable) {
70 case 0:
71 if (call->enabled) {
72 call->enabled = 0;
73 call->unregfunc();
74 }
Steven Rostedtfd994982009-02-28 02:41:25 -050075 break;
76 case 1:
Steven Rostedtda4d0302009-03-09 17:14:30 -040077 if (!call->enabled) {
Steven Rostedtfd994982009-02-28 02:41:25 -050078 call->enabled = 1;
79 call->regfunc();
80 }
Steven Rostedtfd994982009-02-28 02:41:25 -050081 break;
82 }
83}
84
Steven Rostedtb77e38a2009-02-24 10:21:36 -050085static int ftrace_set_clr_event(char *buf, int set)
86{
Steven Rostedt1473e442009-02-24 14:15:08 -050087 struct ftrace_event_call *call = __start_ftrace_events;
Steven Rostedtb628b3e2009-02-27 23:32:58 -050088 char *event = NULL, *sub = NULL, *match;
89 int ret = -EINVAL;
Steven Rostedtb77e38a2009-02-24 10:21:36 -050090
Steven Rostedtb628b3e2009-02-27 23:32:58 -050091 /*
92 * The buf format can be <subsystem>:<event-name>
93 * *:<event-name> means any event by that name.
94 * :<event-name> is the same.
95 *
96 * <subsystem>:* means all events in that subsystem
97 * <subsystem>: means the same.
98 *
99 * <name> (no ':') means all events in a subsystem with
100 * the name <name> or any event that matches <name>
101 */
102
103 match = strsep(&buf, ":");
104 if (buf) {
105 sub = match;
106 event = buf;
107 match = NULL;
108
109 if (!strlen(sub) || strcmp(sub, "*") == 0)
110 sub = NULL;
111 if (!strlen(event) || strcmp(event, "*") == 0)
112 event = NULL;
113 }
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500114
Steven Rostedt11a241a2009-03-02 11:49:04 -0500115 mutex_lock(&event_mutex);
Peter Zijlstraac199db2009-03-19 20:26:15 +0100116 for_each_event(call) {
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500117
Steven Rostedt40e26812009-03-10 11:32:40 -0400118 if (!call->name || !call->regfunc)
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500119 continue;
Steven Rostedt1473e442009-02-24 14:15:08 -0500120
Steven Rostedtb628b3e2009-02-27 23:32:58 -0500121 if (match &&
122 strcmp(match, call->name) != 0 &&
123 strcmp(match, call->system) != 0)
124 continue;
125
126 if (sub && strcmp(sub, call->system) != 0)
127 continue;
128
129 if (event && strcmp(event, call->name) != 0)
Steven Rostedt1473e442009-02-24 14:15:08 -0500130 continue;
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500131
Steven Rostedtfd994982009-02-28 02:41:25 -0500132 ftrace_event_enable_disable(call, set);
133
Steven Rostedtb628b3e2009-02-27 23:32:58 -0500134 ret = 0;
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500135 }
Steven Rostedt11a241a2009-03-02 11:49:04 -0500136 mutex_unlock(&event_mutex);
137
Steven Rostedtb628b3e2009-02-27 23:32:58 -0500138 return ret;
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500139}
140
141/* 128 should be much more than enough */
142#define EVENT_BUF_SIZE 127
143
144static ssize_t
145ftrace_event_write(struct file *file, const char __user *ubuf,
146 size_t cnt, loff_t *ppos)
147{
148 size_t read = 0;
149 int i, set = 1;
150 ssize_t ret;
151 char *buf;
152 char ch;
153
154 if (!cnt || cnt < 0)
155 return 0;
156
Steven Rostedt1852fcc2009-03-11 14:33:00 -0400157 ret = tracing_update_buffers();
158 if (ret < 0)
159 return ret;
160
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500161 ret = get_user(ch, ubuf++);
162 if (ret)
163 return ret;
164 read++;
165 cnt--;
166
167 /* skip white space */
168 while (cnt && isspace(ch)) {
169 ret = get_user(ch, ubuf++);
170 if (ret)
171 return ret;
172 read++;
173 cnt--;
174 }
175
176 /* Only white space found? */
177 if (isspace(ch)) {
178 file->f_pos += read;
179 ret = read;
180 return ret;
181 }
182
183 buf = kmalloc(EVENT_BUF_SIZE+1, GFP_KERNEL);
184 if (!buf)
185 return -ENOMEM;
186
187 if (cnt > EVENT_BUF_SIZE)
188 cnt = EVENT_BUF_SIZE;
189
190 i = 0;
191 while (cnt && !isspace(ch)) {
192 if (!i && ch == '!')
193 set = 0;
194 else
195 buf[i++] = ch;
196
197 ret = get_user(ch, ubuf++);
198 if (ret)
199 goto out_free;
200 read++;
201 cnt--;
202 }
203 buf[i] = 0;
204
205 file->f_pos += read;
206
207 ret = ftrace_set_clr_event(buf, set);
208 if (ret)
209 goto out_free;
210
211 ret = read;
212
213 out_free:
214 kfree(buf);
215
216 return ret;
217}
218
219static void *
220t_next(struct seq_file *m, void *v, loff_t *pos)
221{
222 struct ftrace_event_call *call = m->private;
223 struct ftrace_event_call *next = call;
224
225 (*pos)++;
226
Steven Rostedt40e26812009-03-10 11:32:40 -0400227 for (;;) {
228 if ((unsigned long)call >= (unsigned long)__stop_ftrace_events)
229 return NULL;
230
231 /*
232 * The ftrace subsystem is for showing formats only.
233 * They can not be enabled or disabled via the event files.
234 */
235 if (call->regfunc)
236 break;
237
238 call++;
239 next = call;
240 }
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500241
242 m->private = ++next;
243
244 return call;
245}
246
247static void *t_start(struct seq_file *m, loff_t *pos)
248{
249 return t_next(m, NULL, pos);
250}
251
252static void *
253s_next(struct seq_file *m, void *v, loff_t *pos)
254{
255 struct ftrace_event_call *call = m->private;
256 struct ftrace_event_call *next;
257
258 (*pos)++;
259
260 retry:
261 if ((unsigned long)call >= (unsigned long)__stop_ftrace_events)
262 return NULL;
263
264 if (!call->enabled) {
265 call++;
266 goto retry;
267 }
268
269 next = call;
270 m->private = ++next;
271
272 return call;
273}
274
275static void *s_start(struct seq_file *m, loff_t *pos)
276{
277 return s_next(m, NULL, pos);
278}
279
280static int t_show(struct seq_file *m, void *v)
281{
282 struct ftrace_event_call *call = v;
283
Steven Rostedtb628b3e2009-02-27 23:32:58 -0500284 if (strcmp(call->system, TRACE_SYSTEM) != 0)
285 seq_printf(m, "%s:", call->system);
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500286 seq_printf(m, "%s\n", call->name);
287
288 return 0;
289}
290
291static void t_stop(struct seq_file *m, void *p)
292{
293}
294
295static int
296ftrace_event_seq_open(struct inode *inode, struct file *file)
297{
298 int ret;
299 const struct seq_operations *seq_ops;
300
301 if ((file->f_mode & FMODE_WRITE) &&
302 !(file->f_flags & O_APPEND))
303 ftrace_clear_events();
304
305 seq_ops = inode->i_private;
306 ret = seq_open(file, seq_ops);
307 if (!ret) {
308 struct seq_file *m = file->private_data;
309
310 m->private = __start_ftrace_events;
311 }
312 return ret;
313}
314
Steven Rostedt1473e442009-02-24 14:15:08 -0500315static ssize_t
316event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
317 loff_t *ppos)
318{
319 struct ftrace_event_call *call = filp->private_data;
320 char *buf;
321
Steven Rostedtda4d0302009-03-09 17:14:30 -0400322 if (call->enabled)
Steven Rostedt1473e442009-02-24 14:15:08 -0500323 buf = "1\n";
324 else
325 buf = "0\n";
326
327 return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
328}
329
330static ssize_t
331event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
332 loff_t *ppos)
333{
334 struct ftrace_event_call *call = filp->private_data;
335 char buf[64];
336 unsigned long val;
337 int ret;
338
339 if (cnt >= sizeof(buf))
340 return -EINVAL;
341
342 if (copy_from_user(&buf, ubuf, cnt))
343 return -EFAULT;
344
345 buf[cnt] = 0;
346
347 ret = strict_strtoul(buf, 10, &val);
348 if (ret < 0)
349 return ret;
350
Steven Rostedt1852fcc2009-03-11 14:33:00 -0400351 ret = tracing_update_buffers();
352 if (ret < 0)
353 return ret;
354
Steven Rostedt1473e442009-02-24 14:15:08 -0500355 switch (val) {
356 case 0:
Steven Rostedt1473e442009-02-24 14:15:08 -0500357 case 1:
Steven Rostedt11a241a2009-03-02 11:49:04 -0500358 mutex_lock(&event_mutex);
Steven Rostedtfd994982009-02-28 02:41:25 -0500359 ftrace_event_enable_disable(call, val);
Steven Rostedt11a241a2009-03-02 11:49:04 -0500360 mutex_unlock(&event_mutex);
Steven Rostedt1473e442009-02-24 14:15:08 -0500361 break;
362
363 default:
364 return -EINVAL;
365 }
366
367 *ppos += cnt;
368
369 return cnt;
370}
371
Steven Rostedt91729ef92009-03-02 15:03:01 -0500372#undef FIELD
Steven Rostedt156b5f12009-03-06 10:50:53 -0500373#define FIELD(type, name) \
Tom Zanussicf027f62009-03-22 03:30:39 -0500374 #type, "common_" #name, offsetof(typeof(field), name), \
375 sizeof(field.name)
Steven Rostedt91729ef92009-03-02 15:03:01 -0500376
377static int trace_write_header(struct trace_seq *s)
378{
379 struct trace_entry field;
380
381 /* struct trace_entry */
382 return trace_seq_printf(s,
Steven Rostedtce8eb2b2009-03-10 10:14:35 -0400383 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
384 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
385 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
386 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
387 "\tfield:%s %s;\toffset:%zu;\tsize:%zu;\n"
Steven Rostedt91729ef92009-03-02 15:03:01 -0500388 "\n",
389 FIELD(unsigned char, type),
390 FIELD(unsigned char, flags),
391 FIELD(unsigned char, preempt_count),
392 FIELD(int, pid),
393 FIELD(int, tgid));
394}
Steven Rostedtda4d0302009-03-09 17:14:30 -0400395
Steven Rostedt981d0812009-03-02 13:53:59 -0500396static ssize_t
397event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
398 loff_t *ppos)
399{
400 struct ftrace_event_call *call = filp->private_data;
401 struct trace_seq *s;
402 char *buf;
403 int r;
404
Tom Zanussic269fc82009-03-17 01:20:59 -0500405 if (*ppos)
406 return 0;
407
Steven Rostedt981d0812009-03-02 13:53:59 -0500408 s = kmalloc(sizeof(*s), GFP_KERNEL);
409 if (!s)
410 return -ENOMEM;
411
412 trace_seq_init(s);
413
Steven Rostedtc5e4e192009-03-02 15:10:02 -0500414 /* If any of the first writes fail, so will the show_format. */
415
416 trace_seq_printf(s, "name: %s\n", call->name);
417 trace_seq_printf(s, "ID: %d\n", call->id);
418 trace_seq_printf(s, "format:\n");
Steven Rostedt91729ef92009-03-02 15:03:01 -0500419 trace_write_header(s);
420
Steven Rostedt981d0812009-03-02 13:53:59 -0500421 r = call->show_format(s);
422 if (!r) {
423 /*
424 * ug! The format output is bigger than a PAGE!!
425 */
426 buf = "FORMAT TOO BIG\n";
427 r = simple_read_from_buffer(ubuf, cnt, ppos,
428 buf, strlen(buf));
429 goto out;
430 }
431
432 r = simple_read_from_buffer(ubuf, cnt, ppos,
433 s->buffer, s->len);
434 out:
435 kfree(s);
436 return r;
437}
438
Peter Zijlstra23725ae2009-03-19 20:26:13 +0100439static ssize_t
440event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
441{
442 struct ftrace_event_call *call = filp->private_data;
443 struct trace_seq *s;
444 int r;
445
446 if (*ppos)
447 return 0;
448
449 s = kmalloc(sizeof(*s), GFP_KERNEL);
450 if (!s)
451 return -ENOMEM;
452
453 trace_seq_init(s);
454 trace_seq_printf(s, "%d\n", call->id);
455
456 r = simple_read_from_buffer(ubuf, cnt, ppos,
457 s->buffer, s->len);
458 kfree(s);
459 return r;
460}
461
Tom Zanussi7ce7e422009-03-22 03:31:04 -0500462static ssize_t
463event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
464 loff_t *ppos)
465{
466 struct ftrace_event_call *call = filp->private_data;
467 struct trace_seq *s;
468 int r;
469
470 if (*ppos)
471 return 0;
472
473 s = kmalloc(sizeof(*s), GFP_KERNEL);
474 if (!s)
475 return -ENOMEM;
476
477 trace_seq_init(s);
478
479 r = filter_print_preds(call->preds, s->buffer);
480 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, r);
481
482 kfree(s);
483
484 return r;
485}
486
487static ssize_t
488event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
489 loff_t *ppos)
490{
491 struct ftrace_event_call *call = filp->private_data;
492 char buf[64], *pbuf = buf;
493 struct filter_pred *pred;
494 int err;
495
496 if (cnt >= sizeof(buf))
497 return -EINVAL;
498
499 if (copy_from_user(&buf, ubuf, cnt))
500 return -EFAULT;
501
502 pred = kzalloc(sizeof(*pred), GFP_KERNEL);
503 if (!pred)
504 return -ENOMEM;
505
506 err = filter_parse(&pbuf, pred);
507 if (err < 0) {
508 filter_free_pred(pred);
509 return err;
510 }
511
512 if (pred->clear) {
513 filter_free_preds(call);
514 return cnt;
515 }
516
517 if (filter_add_pred(call, pred)) {
518 filter_free_pred(pred);
519 return -EINVAL;
520 }
521
522 *ppos += cnt;
523
524 return cnt;
525}
526
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500527static const struct seq_operations show_event_seq_ops = {
528 .start = t_start,
529 .next = t_next,
530 .show = t_show,
531 .stop = t_stop,
532};
533
534static const struct seq_operations show_set_event_seq_ops = {
535 .start = s_start,
536 .next = s_next,
537 .show = t_show,
538 .stop = t_stop,
539};
540
Steven Rostedt2314c4a2009-03-10 12:04:02 -0400541static const struct file_operations ftrace_avail_fops = {
542 .open = ftrace_event_seq_open,
543 .read = seq_read,
544 .llseek = seq_lseek,
545 .release = seq_release,
546};
547
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500548static const struct file_operations ftrace_set_event_fops = {
549 .open = ftrace_event_seq_open,
550 .read = seq_read,
551 .write = ftrace_event_write,
552 .llseek = seq_lseek,
553 .release = seq_release,
554};
555
Steven Rostedt1473e442009-02-24 14:15:08 -0500556static const struct file_operations ftrace_enable_fops = {
557 .open = tracing_open_generic,
558 .read = event_enable_read,
559 .write = event_enable_write,
560};
561
Steven Rostedt981d0812009-03-02 13:53:59 -0500562static const struct file_operations ftrace_event_format_fops = {
563 .open = tracing_open_generic,
564 .read = event_format_read,
565};
566
Peter Zijlstra23725ae2009-03-19 20:26:13 +0100567static const struct file_operations ftrace_event_id_fops = {
568 .open = tracing_open_generic,
569 .read = event_id_read,
570};
571
Tom Zanussi7ce7e422009-03-22 03:31:04 -0500572static const struct file_operations ftrace_event_filter_fops = {
573 .open = tracing_open_generic,
574 .read = event_filter_read,
575 .write = event_filter_write,
576};
577
Steven Rostedt1473e442009-02-24 14:15:08 -0500578static struct dentry *event_trace_events_dir(void)
579{
580 static struct dentry *d_tracer;
581 static struct dentry *d_events;
582
583 if (d_events)
584 return d_events;
585
586 d_tracer = tracing_init_dentry();
587 if (!d_tracer)
588 return NULL;
589
590 d_events = debugfs_create_dir("events", d_tracer);
591 if (!d_events)
592 pr_warning("Could not create debugfs "
593 "'events' directory\n");
594
595 return d_events;
596}
597
Steven Rostedt6ecc2d12009-02-27 21:33:02 -0500598struct event_subsystem {
599 struct list_head list;
600 const char *name;
601 struct dentry *entry;
602};
603
604static LIST_HEAD(event_subsystems);
605
606static struct dentry *
607event_subsystem_dir(const char *name, struct dentry *d_events)
608{
609 struct event_subsystem *system;
610
611 /* First see if we did not already create this dir */
612 list_for_each_entry(system, &event_subsystems, list) {
613 if (strcmp(system->name, name) == 0)
614 return system->entry;
615 }
616
617 /* need to create new entry */
618 system = kmalloc(sizeof(*system), GFP_KERNEL);
619 if (!system) {
620 pr_warning("No memory to create event subsystem %s\n",
621 name);
622 return d_events;
623 }
624
625 system->entry = debugfs_create_dir(name, d_events);
626 if (!system->entry) {
627 pr_warning("Could not create event subsystem %s\n",
628 name);
629 kfree(system);
630 return d_events;
631 }
632
633 system->name = name;
634 list_add(&system->list, &event_subsystems);
635
636 return system->entry;
637}
638
Steven Rostedt1473e442009-02-24 14:15:08 -0500639static int
640event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
641{
642 struct dentry *entry;
Steven Rostedtfd994982009-02-28 02:41:25 -0500643 int ret;
Steven Rostedt1473e442009-02-24 14:15:08 -0500644
Steven Rostedt6ecc2d12009-02-27 21:33:02 -0500645 /*
646 * If the trace point header did not define TRACE_SYSTEM
647 * then the system would be called "TRACE_SYSTEM".
648 */
649 if (strcmp(call->system, "TRACE_SYSTEM") != 0)
650 d_events = event_subsystem_dir(call->system, d_events);
651
Steven Rostedtfd994982009-02-28 02:41:25 -0500652 if (call->raw_init) {
653 ret = call->raw_init();
654 if (ret < 0) {
655 pr_warning("Could not initialize trace point"
656 " events/%s\n", call->name);
657 return ret;
658 }
659 }
660
Steven Rostedt1473e442009-02-24 14:15:08 -0500661 call->dir = debugfs_create_dir(call->name, d_events);
662 if (!call->dir) {
663 pr_warning("Could not create debugfs "
664 "'%s' directory\n", call->name);
665 return -1;
666 }
667
Steven Rostedt770cb242009-03-05 21:35:29 -0500668 if (call->regfunc) {
669 entry = debugfs_create_file("enable", 0644, call->dir, call,
670 &ftrace_enable_fops);
671 if (!entry)
672 pr_warning("Could not create debugfs "
673 "'%s/enable' entry\n", call->name);
674 }
Steven Rostedt1473e442009-02-24 14:15:08 -0500675
Peter Zijlstra23725ae2009-03-19 20:26:13 +0100676 if (call->id) {
677 entry = debugfs_create_file("id", 0444, call->dir, call,
678 &ftrace_event_id_fops);
679 if (!entry)
680 pr_warning("Could not create debugfs '%s/id' entry\n",
681 call->name);
682 }
683
Tom Zanussicf027f62009-03-22 03:30:39 -0500684 if (call->define_fields) {
685 ret = call->define_fields();
686 if (ret < 0) {
687 pr_warning("Could not initialize trace point"
688 " events/%s\n", call->name);
689 return ret;
690 }
691 }
692
Tom Zanussi7ce7e422009-03-22 03:31:04 -0500693 entry = debugfs_create_file("filter", 0444, call->dir, call,
694 &ftrace_event_filter_fops);
695 if (!entry)
696 pr_warning("Could not create debugfs "
697 "'%s/filter' entry\n", call->name);
698
Steven Rostedt981d0812009-03-02 13:53:59 -0500699 /* A trace may not want to export its format */
700 if (!call->show_format)
701 return 0;
702
703 entry = debugfs_create_file("format", 0444, call->dir, call,
704 &ftrace_event_format_fops);
705 if (!entry)
706 pr_warning("Could not create debugfs "
707 "'%s/format' entry\n", call->name);
Steven Rostedtfd994982009-02-28 02:41:25 -0500708
Steven Rostedt1473e442009-02-24 14:15:08 -0500709 return 0;
710}
711
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500712static __init int event_trace_init(void)
713{
Steven Rostedt1473e442009-02-24 14:15:08 -0500714 struct ftrace_event_call *call = __start_ftrace_events;
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500715 struct dentry *d_tracer;
716 struct dentry *entry;
Steven Rostedt1473e442009-02-24 14:15:08 -0500717 struct dentry *d_events;
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500718
719 d_tracer = tracing_init_dentry();
720 if (!d_tracer)
721 return 0;
722
Steven Rostedt2314c4a2009-03-10 12:04:02 -0400723 entry = debugfs_create_file("available_events", 0444, d_tracer,
724 (void *)&show_event_seq_ops,
725 &ftrace_avail_fops);
726 if (!entry)
727 pr_warning("Could not create debugfs "
728 "'available_events' entry\n");
729
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500730 entry = debugfs_create_file("set_event", 0644, d_tracer,
731 (void *)&show_set_event_seq_ops,
732 &ftrace_set_event_fops);
733 if (!entry)
734 pr_warning("Could not create debugfs "
735 "'set_event' entry\n");
736
Steven Rostedt1473e442009-02-24 14:15:08 -0500737 d_events = event_trace_events_dir();
738 if (!d_events)
739 return 0;
740
Peter Zijlstraac199db2009-03-19 20:26:15 +0100741 for_each_event(call) {
Steven Rostedt1473e442009-02-24 14:15:08 -0500742 /* The linker may leave blanks */
743 if (!call->name)
744 continue;
745 event_create_dir(call, d_events);
746 }
747
Steven Rostedtb77e38a2009-02-24 10:21:36 -0500748 return 0;
749}
750fs_initcall(event_trace_init);