diff options
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r-- | kernel/trace/trace_events.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1d18315dc836..189b09baf4fb 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(trace_define_field); | |||
78 | if (ret) \ | 78 | if (ret) \ |
79 | return ret; | 79 | return ret; |
80 | 80 | ||
81 | int trace_define_common_fields(struct ftrace_event_call *call) | 81 | static int trace_define_common_fields(struct ftrace_event_call *call) |
82 | { | 82 | { |
83 | int ret; | 83 | int ret; |
84 | struct trace_entry ent; | 84 | struct trace_entry ent; |
@@ -91,7 +91,6 @@ int trace_define_common_fields(struct ftrace_event_call *call) | |||
91 | 91 | ||
92 | return ret; | 92 | return ret; |
93 | } | 93 | } |
94 | EXPORT_SYMBOL_GPL(trace_define_common_fields); | ||
95 | 94 | ||
96 | void trace_destroy_fields(struct ftrace_event_call *call) | 95 | void trace_destroy_fields(struct ftrace_event_call *call) |
97 | { | 96 | { |
@@ -105,9 +104,25 @@ void trace_destroy_fields(struct ftrace_event_call *call) | |||
105 | } | 104 | } |
106 | } | 105 | } |
107 | 106 | ||
108 | static void ftrace_event_enable_disable(struct ftrace_event_call *call, | 107 | int trace_event_raw_init(struct ftrace_event_call *call) |
108 | { | ||
109 | int id; | ||
110 | |||
111 | id = register_ftrace_event(call->event); | ||
112 | if (!id) | ||
113 | return -ENODEV; | ||
114 | call->id = id; | ||
115 | INIT_LIST_HEAD(&call->fields); | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | EXPORT_SYMBOL_GPL(trace_event_raw_init); | ||
120 | |||
121 | static int ftrace_event_enable_disable(struct ftrace_event_call *call, | ||
109 | int enable) | 122 | int enable) |
110 | { | 123 | { |
124 | int ret = 0; | ||
125 | |||
111 | switch (enable) { | 126 | switch (enable) { |
112 | case 0: | 127 | case 0: |
113 | if (call->enabled) { | 128 | if (call->enabled) { |
@@ -118,12 +133,20 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call, | |||
118 | break; | 133 | break; |
119 | case 1: | 134 | case 1: |
120 | if (!call->enabled) { | 135 | if (!call->enabled) { |
121 | call->enabled = 1; | ||
122 | tracing_start_cmdline_record(); | 136 | tracing_start_cmdline_record(); |
123 | call->regfunc(call); | 137 | ret = call->regfunc(call); |
138 | if (ret) { | ||
139 | tracing_stop_cmdline_record(); | ||
140 | pr_info("event trace: Could not enable event " | ||
141 | "%s\n", call->name); | ||
142 | break; | ||
143 | } | ||
144 | call->enabled = 1; | ||
124 | } | 145 | } |
125 | break; | 146 | break; |
126 | } | 147 | } |
148 | |||
149 | return ret; | ||
127 | } | 150 | } |
128 | 151 | ||
129 | static void ftrace_clear_events(void) | 152 | static void ftrace_clear_events(void) |
@@ -402,7 +425,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
402 | case 0: | 425 | case 0: |
403 | case 1: | 426 | case 1: |
404 | mutex_lock(&event_mutex); | 427 | mutex_lock(&event_mutex); |
405 | ftrace_event_enable_disable(call, val); | 428 | ret = ftrace_event_enable_disable(call, val); |
406 | mutex_unlock(&event_mutex); | 429 | mutex_unlock(&event_mutex); |
407 | break; | 430 | break; |
408 | 431 | ||
@@ -412,7 +435,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
412 | 435 | ||
413 | *ppos += cnt; | 436 | *ppos += cnt; |
414 | 437 | ||
415 | return cnt; | 438 | return ret ? ret : cnt; |
416 | } | 439 | } |
417 | 440 | ||
418 | static ssize_t | 441 | static ssize_t |
@@ -913,7 +936,9 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, | |||
913 | id); | 936 | id); |
914 | 937 | ||
915 | if (call->define_fields) { | 938 | if (call->define_fields) { |
916 | ret = call->define_fields(call); | 939 | ret = trace_define_common_fields(call); |
940 | if (!ret) | ||
941 | ret = call->define_fields(call); | ||
917 | if (ret < 0) { | 942 | if (ret < 0) { |
918 | pr_warning("Could not initialize trace point" | 943 | pr_warning("Could not initialize trace point" |
919 | " events/%s\n", call->name); | 944 | " events/%s\n", call->name); |