aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2009-03-22 04:30:39 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-22 13:11:22 -0400
commitcf027f645e6aee4f0ca6197a6b6a57f327fdb13f (patch)
treef8a20e8707967db5d9140f9069426f410a30dd32 /kernel/trace/trace_events.c
parent0cf53ff62b3e9e491ff5e5f05b193fb6ce643047 (diff)
tracing: add run-time field descriptions for event filtering
This patch makes the field descriptions defined for event tracing available at run-time, for the event-filtering mechanism introduced in a subsequent patch. The common event fields are prepended with 'common_' in the format display, allowing them to be distinguished from the other fields that might internally have same name and can therefore be unambiguously used in filters. Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <1237710639.7703.46.camel@charm-linux> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 3047b56f6637..961b057da28b 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -19,6 +19,34 @@
19 19
20static DEFINE_MUTEX(event_mutex); 20static DEFINE_MUTEX(event_mutex);
21 21
22int 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
22static void ftrace_clear_events(void) 50static void ftrace_clear_events(void)
23{ 51{
24 struct ftrace_event_call *call = (void *)__start_ftrace_events; 52 struct ftrace_event_call *call = (void *)__start_ftrace_events;
@@ -343,7 +371,8 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
343 371
344#undef FIELD 372#undef FIELD
345#define FIELD(type, name) \ 373#define FIELD(type, name) \
346 #type, #name, offsetof(typeof(field), name), sizeof(field.name) 374 #type, "common_" #name, offsetof(typeof(field), name), \
375 sizeof(field.name)
347 376
348static int trace_write_header(struct trace_seq *s) 377static int trace_write_header(struct trace_seq *s)
349{ 378{
@@ -581,6 +610,15 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events)
581 call->name); 610 call->name);
582 } 611 }
583 612
613 if (call->define_fields) {
614 ret = call->define_fields();
615 if (ret < 0) {
616 pr_warning("Could not initialize trace point"
617 " events/%s\n", call->name);
618 return ret;
619 }
620 }
621
584 /* A trace may not want to export its format */ 622 /* A trace may not want to export its format */
585 if (!call->show_format) 623 if (!call->show_format)
586 return 0; 624 return 0;