diff options
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace_events.c | 70 |
1 files changed, 19 insertions, 51 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 5bad9cbbf974..69bee4cc0e10 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -1009,11 +1009,17 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, | |||
1009 | return 0; | 1009 | return 0; |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | static int __trace_add_event_call(struct ftrace_event_call *call) | 1012 | static int |
1013 | __trace_add_event_call(struct ftrace_event_call *call, struct module *mod, | ||
1014 | const struct file_operations *id, | ||
1015 | const struct file_operations *enable, | ||
1016 | const struct file_operations *filter, | ||
1017 | const struct file_operations *format) | ||
1013 | { | 1018 | { |
1014 | struct dentry *d_events; | 1019 | struct dentry *d_events; |
1015 | int ret; | 1020 | int ret; |
1016 | 1021 | ||
1022 | /* The linker may leave blanks */ | ||
1017 | if (!call->name) | 1023 | if (!call->name) |
1018 | return -EINVAL; | 1024 | return -EINVAL; |
1019 | 1025 | ||
@@ -1021,8 +1027,8 @@ static int __trace_add_event_call(struct ftrace_event_call *call) | |||
1021 | ret = call->class->raw_init(call); | 1027 | ret = call->class->raw_init(call); |
1022 | if (ret < 0) { | 1028 | if (ret < 0) { |
1023 | if (ret != -ENOSYS) | 1029 | if (ret != -ENOSYS) |
1024 | pr_warning("Could not initialize trace " | 1030 | pr_warning("Could not initialize trace events/%s\n", |
1025 | "events/%s\n", call->name); | 1031 | call->name); |
1026 | return ret; | 1032 | return ret; |
1027 | } | 1033 | } |
1028 | } | 1034 | } |
@@ -1031,11 +1037,10 @@ static int __trace_add_event_call(struct ftrace_event_call *call) | |||
1031 | if (!d_events) | 1037 | if (!d_events) |
1032 | return -ENOENT; | 1038 | return -ENOENT; |
1033 | 1039 | ||
1034 | ret = event_create_dir(call, d_events, &ftrace_event_id_fops, | 1040 | ret = event_create_dir(call, d_events, id, enable, filter, format); |
1035 | &ftrace_enable_fops, &ftrace_event_filter_fops, | ||
1036 | &ftrace_event_format_fops); | ||
1037 | if (!ret) | 1041 | if (!ret) |
1038 | list_add(&call->list, &ftrace_events); | 1042 | list_add(&call->list, &ftrace_events); |
1043 | call->mod = mod; | ||
1039 | 1044 | ||
1040 | return ret; | 1045 | return ret; |
1041 | } | 1046 | } |
@@ -1045,7 +1050,10 @@ int trace_add_event_call(struct ftrace_event_call *call) | |||
1045 | { | 1050 | { |
1046 | int ret; | 1051 | int ret; |
1047 | mutex_lock(&event_mutex); | 1052 | mutex_lock(&event_mutex); |
1048 | ret = __trace_add_event_call(call); | 1053 | ret = __trace_add_event_call(call, NULL, &ftrace_event_id_fops, |
1054 | &ftrace_enable_fops, | ||
1055 | &ftrace_event_filter_fops, | ||
1056 | &ftrace_event_format_fops); | ||
1049 | mutex_unlock(&event_mutex); | 1057 | mutex_unlock(&event_mutex); |
1050 | return ret; | 1058 | return ret; |
1051 | } | 1059 | } |
@@ -1162,8 +1170,6 @@ static void trace_module_add_events(struct module *mod) | |||
1162 | { | 1170 | { |
1163 | struct ftrace_module_file_ops *file_ops = NULL; | 1171 | struct ftrace_module_file_ops *file_ops = NULL; |
1164 | struct ftrace_event_call *call, *start, *end; | 1172 | struct ftrace_event_call *call, *start, *end; |
1165 | struct dentry *d_events; | ||
1166 | int ret; | ||
1167 | 1173 | ||
1168 | start = mod->trace_events; | 1174 | start = mod->trace_events; |
1169 | end = mod->trace_events + mod->num_trace_events; | 1175 | end = mod->trace_events + mod->num_trace_events; |
@@ -1171,38 +1177,14 @@ static void trace_module_add_events(struct module *mod) | |||
1171 | if (start == end) | 1177 | if (start == end) |
1172 | return; | 1178 | return; |
1173 | 1179 | ||
1174 | d_events = event_trace_events_dir(); | 1180 | file_ops = trace_create_file_ops(mod); |
1175 | if (!d_events) | 1181 | if (!file_ops) |
1176 | return; | 1182 | return; |
1177 | 1183 | ||
1178 | for_each_event(call, start, end) { | 1184 | for_each_event(call, start, end) { |
1179 | /* The linker may leave blanks */ | 1185 | __trace_add_event_call(call, mod, |
1180 | if (!call->name) | ||
1181 | continue; | ||
1182 | if (call->class->raw_init) { | ||
1183 | ret = call->class->raw_init(call); | ||
1184 | if (ret < 0) { | ||
1185 | if (ret != -ENOSYS) | ||
1186 | pr_warning("Could not initialize trace " | ||
1187 | "point events/%s\n", call->name); | ||
1188 | continue; | ||
1189 | } | ||
1190 | } | ||
1191 | /* | ||
1192 | * This module has events, create file ops for this module | ||
1193 | * if not already done. | ||
1194 | */ | ||
1195 | if (!file_ops) { | ||
1196 | file_ops = trace_create_file_ops(mod); | ||
1197 | if (!file_ops) | ||
1198 | return; | ||
1199 | } | ||
1200 | call->mod = mod; | ||
1201 | ret = event_create_dir(call, d_events, | ||
1202 | &file_ops->id, &file_ops->enable, | 1186 | &file_ops->id, &file_ops->enable, |
1203 | &file_ops->filter, &file_ops->format); | 1187 | &file_ops->filter, &file_ops->format); |
1204 | if (!ret) | ||
1205 | list_add(&call->list, &ftrace_events); | ||
1206 | } | 1188 | } |
1207 | } | 1189 | } |
1208 | 1190 | ||
@@ -1333,24 +1315,10 @@ static __init int event_trace_init(void) | |||
1333 | pr_warning("tracing: Failed to allocate common fields"); | 1315 | pr_warning("tracing: Failed to allocate common fields"); |
1334 | 1316 | ||
1335 | for_each_event(call, __start_ftrace_events, __stop_ftrace_events) { | 1317 | for_each_event(call, __start_ftrace_events, __stop_ftrace_events) { |
1336 | /* The linker may leave blanks */ | 1318 | __trace_add_event_call(call, NULL, &ftrace_event_id_fops, |
1337 | if (!call->name) | ||
1338 | continue; | ||
1339 | if (call->class->raw_init) { | ||
1340 | ret = call->class->raw_init(call); | ||
1341 | if (ret < 0) { | ||
1342 | if (ret != -ENOSYS) | ||
1343 | pr_warning("Could not initialize trace " | ||
1344 | "point events/%s\n", call->name); | ||
1345 | continue; | ||
1346 | } | ||
1347 | } | ||
1348 | ret = event_create_dir(call, d_events, &ftrace_event_id_fops, | ||
1349 | &ftrace_enable_fops, | 1319 | &ftrace_enable_fops, |
1350 | &ftrace_event_filter_fops, | 1320 | &ftrace_event_filter_fops, |
1351 | &ftrace_event_format_fops); | 1321 | &ftrace_event_format_fops); |
1352 | if (!ret) | ||
1353 | list_add(&call->list, &ftrace_events); | ||
1354 | } | 1322 | } |
1355 | 1323 | ||
1356 | while (true) { | 1324 | while (true) { |