Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic...
[deliverable/linux.git] / kernel / trace / trace_events.c
index e0cbede9678317a9936eea9859e27f4f09dfb783..78b1ed230177246349d10ba83615b99f3adcbde3 100644 (file)
@@ -27,8 +27,9 @@ DEFINE_MUTEX(event_mutex);
 
 LIST_HEAD(ftrace_events);
 
-int trace_define_field(struct ftrace_event_call *call, char *type,
-                      char *name, int offset, int size, int is_signed)
+int trace_define_field(struct ftrace_event_call *call, const char *type,
+                      const char *name, int offset, int size, int is_signed,
+                      int filter_type)
 {
        struct ftrace_event_field *field;
 
@@ -44,9 +45,15 @@ int trace_define_field(struct ftrace_event_call *call, char *type,
        if (!field->type)
                goto err;
 
+       if (filter_type == FILTER_OTHER)
+               field->filter_type = filter_assign_type(type);
+       else
+               field->filter_type = filter_type;
+
        field->offset = offset;
        field->size = size;
        field->is_signed = is_signed;
+
        list_add(&field->link, &call->fields);
 
        return 0;
@@ -62,6 +69,29 @@ err:
 }
 EXPORT_SYMBOL_GPL(trace_define_field);
 
+#define __common_field(type, item)                                     \
+       ret = trace_define_field(call, #type, "common_" #item,          \
+                                offsetof(typeof(ent), item),           \
+                                sizeof(ent.item),                      \
+                                is_signed_type(type), FILTER_OTHER);   \
+       if (ret)                                                        \
+               return ret;
+
+int trace_define_common_fields(struct ftrace_event_call *call)
+{
+       int ret;
+       struct trace_entry ent;
+
+       __common_field(unsigned short, type);
+       __common_field(unsigned char, flags);
+       __common_field(unsigned char, preempt_count);
+       __common_field(int, pid);
+       __common_field(int, tgid);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(trace_define_common_fields);
+
 #ifdef CONFIG_MODULES
 
 static void trace_destroy_fields(struct ftrace_event_call *call)
@@ -86,14 +116,14 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call,
                if (call->enabled) {
                        call->enabled = 0;
                        tracing_stop_cmdline_record();
-                       call->unregfunc();
+                       call->unregfunc(call->data);
                }
                break;
        case 1:
                if (!call->enabled) {
                        call->enabled = 1;
                        tracing_start_cmdline_record();
-                       call->regfunc();
+                       call->regfunc(call->data);
                }
                break;
        }
@@ -576,7 +606,7 @@ event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
        trace_seq_printf(s, "format:\n");
        trace_write_header(s);
 
-       r = call->show_format(s);
+       r = call->show_format(call, s);
        if (!r) {
                /*
                 * ug!  The format output is bigger than a PAGE!!
@@ -925,15 +955,6 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
        if (strcmp(call->system, TRACE_SYSTEM) != 0)
                d_events = event_subsystem_dir(call->system, d_events);
 
-       if (call->raw_init) {
-               ret = call->raw_init();
-               if (ret < 0) {
-                       pr_warning("Could not initialize trace point"
-                                  " events/%s\n", call->name);
-                       return ret;
-               }
-       }
-
        call->dir = debugfs_create_dir(call->name, d_events);
        if (!call->dir) {
                pr_warning("Could not create debugfs "
@@ -950,7 +971,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
                                          id);
 
        if (call->define_fields) {
-               ret = call->define_fields();
+               ret = call->define_fields(call);
                if (ret < 0) {
                        pr_warning("Could not initialize trace point"
                                   " events/%s\n", call->name);
@@ -1058,6 +1079,7 @@ static void trace_module_add_events(struct module *mod)
        struct ftrace_module_file_ops *file_ops = NULL;
        struct ftrace_event_call *call, *start, *end;
        struct dentry *d_events;
+       int ret;
 
        start = mod->trace_events;
        end = mod->trace_events + mod->num_trace_events;
@@ -1073,7 +1095,15 @@ static void trace_module_add_events(struct module *mod)
                /* The linker may leave blanks */
                if (!call->name)
                        continue;
-
+               if (call->raw_init) {
+                       ret = call->raw_init();
+                       if (ret < 0) {
+                               if (ret != -ENOSYS)
+                                       pr_warning("Could not initialize trace "
+                                       "point events/%s\n", call->name);
+                               continue;
+                       }
+               }
                /*
                 * This module has events, create file ops for this module
                 * if not already done.
@@ -1225,6 +1255,15 @@ static __init int event_trace_init(void)
                /* The linker may leave blanks */
                if (!call->name)
                        continue;
+               if (call->raw_init) {
+                       ret = call->raw_init();
+                       if (ret < 0) {
+                               if (ret != -ENOSYS)
+                                       pr_warning("Could not initialize trace "
+                                       "point events/%s\n", call->name);
+                               continue;
+                       }
+               }
                list_add(&call->list, &ftrace_events);
                event_create_dir(call, d_events, &ftrace_event_id_fops,
                                 &ftrace_enable_fops, &ftrace_event_filter_fops,
@@ -1399,6 +1438,7 @@ static void
 function_test_events_call(unsigned long ip, unsigned long parent_ip)
 {
        struct ring_buffer_event *event;
+       struct ring_buffer *buffer;
        struct ftrace_entry *entry;
        unsigned long flags;
        long disabled;
@@ -1416,7 +1456,8 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip)
 
        local_save_flags(flags);
 
-       event = trace_current_buffer_lock_reserve(TRACE_FN, sizeof(*entry),
+       event = trace_current_buffer_lock_reserve(&buffer,
+                                                 TRACE_FN, sizeof(*entry),
                                                  flags, pc);
        if (!event)
                goto out;
@@ -1424,7 +1465,7 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip)
        entry->ip                       = ip;
        entry->parent_ip                = parent_ip;
 
-       trace_nowake_buffer_unlock_commit(event, flags, pc);
+       trace_nowake_buffer_unlock_commit(buffer, event, flags, pc);
 
  out:
        atomic_dec(&per_cpu(test_event_disable, cpu));
This page took 0.039485 seconds and 5 git commands to generate.