aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-19 15:26:13 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-20 05:17:05 -0400
commit23725aeeab10ba02bcf10ec49ad73146b54cb52f (patch)
tree02d5932639e8d76be42a057d8d6ff73026949d12 /kernel/trace/trace_events.c
parent44fc6ee92356aa3be31798ced220ab5abd898781 (diff)
ftrace: provide an id file for each event
Since not every event has a format file to read the id from, expose it explicitly in a separate file. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <20090319194233.372534033@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index c88227b3b9db..7763db8fd0b3 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -412,6 +412,29 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
412 return r; 412 return r;
413} 413}
414 414
415static ssize_t
416event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
417{
418 struct ftrace_event_call *call = filp->private_data;
419 struct trace_seq *s;
420 int r;
421
422 if (*ppos)
423 return 0;
424
425 s = kmalloc(sizeof(*s), GFP_KERNEL);
426 if (!s)
427 return -ENOMEM;
428
429 trace_seq_init(s);
430 trace_seq_printf(s, "%d\n", call->id);
431
432 r = simple_read_from_buffer(ubuf, cnt, ppos,
433 s->buffer, s->len);
434 kfree(s);
435 return r;
436}
437
415static const struct seq_operations show_event_seq_ops = { 438static const struct seq_operations show_event_seq_ops = {
416 .start = t_start, 439 .start = t_start,
417 .next = t_next, 440 .next = t_next,
@@ -452,6 +475,11 @@ static const struct file_operations ftrace_event_format_fops = {
452 .read = event_format_read, 475 .read = event_format_read,
453}; 476};
454 477
478static const struct file_operations ftrace_event_id_fops = {
479 .open = tracing_open_generic,
480 .read = event_id_read,
481};
482
455static struct dentry *event_trace_events_dir(void) 483static struct dentry *event_trace_events_dir(void)
456{ 484{
457 static struct dentry *d_tracer; 485 static struct dentry *d_tracer;
@@ -550,6 +578,14 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
550 "'%s/enable' entry\n", call->name); 578 "'%s/enable' entry\n", call->name);
551 } 579 }
552 580
581 if (call->id) {
582 entry = debugfs_create_file("id", 0444, call->dir, call,
583 &ftrace_event_id_fops);
584 if (!entry)
585 pr_warning("Could not create debugfs '%s/id' entry\n",
586 call->name);
587 }
588
553 /* A trace may not want to export its format */ 589 /* A trace may not want to export its format */
554 if (!call->show_format) 590 if (!call->show_format)
555 return 0; 591 return 0;