Since trace_event_call is a field of trace_probe, these operations should be done in trace_probe.c. trace_kprobe and trace_uprobe use new functions to register/unregister trace_event_call. Link: http://lkml.kernel.org/r/155931583643.28323.14828411185591538876.stgit@devnote2
Showing the changes to kernel/trace (4 of 4 files). Show all
Unified · Split
| @@ -1393,28 +1393,14 @@ static inline void init_trace_event_call(struct trace_kprobe *tk, · 1392 unmodified lines | ||
| 1393 | 1393 | |
| 1394 | 1394 | static int register_kprobe_event(struct trace_kprobe *tk) |
| 1395 | 1395 | { |
| 1396 | − struct trace_event_call *call = &tk->tp.call; | |
| 1397 | − int ret = 0; | |
| 1398 | − | |
| 1399 | − init_trace_event_call(tk, call); | |
| 1400 | − | |
| 1401 | − ret = register_trace_event(&call->event); | |
| 1402 | − if (!ret) | |
| 1403 | − return -ENODEV; | |
| 1396 | + init_trace_event_call(tk, &tk->tp.call); | |
| 1404 | 1397 | |
| 1405 | − ret = trace_add_event_call(call); | |
| 1406 | − if (ret) { | |
| 1407 | − pr_info("Failed to register kprobe event: %s\n", | |
| 1408 | − trace_event_name(call)); | |
| 1409 | − unregister_trace_event(&call->event); | |
| 1410 | − } | |
| 1411 | − return ret; | |
| 1398 | + return trace_probe_register_event_call(&tk->tp); | |
| 1412 | 1399 | } |
| 1413 | 1400 | |
| 1414 | 1401 | static int unregister_kprobe_event(struct trace_kprobe *tk) |
| 1415 | 1402 | { |
| 1416 | − /* tp->event is unregistered in trace_remove_event_call() */ | |
| 1417 | − return trace_remove_event_call(&tk->tp.call); | |
| 1403 | + return trace_probe_unregister_event_call(&tk->tp); | |
| 1418 | 1404 | } |
| 1419 | 1405 | |
| 1420 | 1406 | #ifdef CONFIG_PERF_EVENTS |
| @@ -920,3 +920,19 @@ int trace_probe_init(struct trace_probe *tp, const char *event, · 919 unmodified lines | ||
| 920 | 920 | |
| 921 | 921 | return 0; |
| 922 | 922 | } |
| 923 | + | |
| 924 | +int trace_probe_register_event_call(struct trace_probe *tp) | |
| 925 | +{ | |
| 926 | + struct trace_event_call *call = &tp->call; | |
| 927 | + int ret; | |
| 928 | + | |
| 929 | + ret = register_trace_event(&call->event); | |
| 930 | + if (!ret) | |
| 931 | + return -ENODEV; | |
| 932 | + | |
| 933 | + ret = trace_add_event_call(call); | |
| 934 | + if (ret) | |
| 935 | + unregister_trace_event(&call->event); | |
| 936 | + | |
| 937 | + return ret; | |
| 938 | +} | |
| @@ -251,6 +251,12 @@ static inline bool trace_probe_is_registered(struct trace_probe *tp) · 250 unmodified lines | ||
| 251 | 251 | int trace_probe_init(struct trace_probe *tp, const char *event, |
| 252 | 252 | const char *group); |
| 253 | 253 | void trace_probe_cleanup(struct trace_probe *tp); |
| 254 | +int trace_probe_register_event_call(struct trace_probe *tp); | |
| 255 | +static inline int trace_probe_unregister_event_call(struct trace_probe *tp) | |
| 256 | +{ | |
| 257 | + /* tp->event is unregistered in trace_remove_event_call() */ | |
| 258 | + return trace_remove_event_call(&tp->call); | |
| 259 | +} | |
| 254 | 260 | |
| 255 | 261 | /* Check the name is good for event/group/fields */ |
| 256 | 262 | static inline bool is_good_name(const char *name) |
| @@ -1345,30 +1345,14 @@ static inline void init_trace_event_call(struct trace_uprobe *tu, · 1344 unmodified lines | ||
| 1345 | 1345 | |
| 1346 | 1346 | static int register_uprobe_event(struct trace_uprobe *tu) |
| 1347 | 1347 | { |
| 1348 | − struct trace_event_call *call = &tu->tp.call; | |
| 1349 | − int ret = 0; | |
| 1350 | − | |
| 1351 | − init_trace_event_call(tu, call); | |
| 1352 | − | |
| 1353 | − ret = register_trace_event(&call->event); | |
| 1354 | − if (!ret) | |
| 1355 | − return -ENODEV; | |
| 1356 | − | |
| 1357 | − ret = trace_add_event_call(call); | |
| 1358 | − | |
| 1359 | − if (ret) { | |
| 1360 | − pr_info("Failed to register uprobe event: %s\n", | |
| 1361 | − trace_event_name(call)); | |
| 1362 | − unregister_trace_event(&call->event); | |
| 1363 | − } | |
| 1348 | + init_trace_event_call(tu, &tu->tp.call); | |
| 1364 | 1349 | |
| 1365 | − return ret; | |
| 1350 | + return trace_probe_register_event_call(&tu->tp); | |
| 1366 | 1351 | } |
| 1367 | 1352 | |
| 1368 | 1353 | static int unregister_uprobe_event(struct trace_uprobe *tu) |
| 1369 | 1354 | { |
| 1370 | − /* tu->event is unregistered in trace_remove_event_call() */ | |
| 1371 | − return trace_remove_event_call(&tu->tp.call); | |
| 1355 | + return trace_probe_unregister_event_call(&tu->tp); | |
| 1372 | 1356 | } |
| 1373 | 1357 | |
| 1374 | 1358 | #ifdef CONFIG_PERF_EVENTS |