Skip to content

Commit 46e5376

Browse files
mhiramatrostedt
authored andcommitted
tracing/probe: Add trace_event_call register API for trace_probe
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 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 455b289 commit 46e5376

4 files changed

Lines changed: 28 additions & 36 deletions

File tree

‎kernel/trace/trace_kprobe.c‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,28 +1393,14 @@ static inline void init_trace_event_call(struct trace_kprobe *tk,
13931393

13941394
static int register_kprobe_event(struct trace_kprobe *tk)
13951395
{
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);
14041397

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);
14121399
}
14131400

14141401
static int unregister_kprobe_event(struct trace_kprobe *tk)
14151402
{
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);
14181404
}
14191405

14201406
#ifdef CONFIG_PERF_EVENTS

‎kernel/trace/trace_probe.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,3 +920,19 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
920920

921921
return 0;
922922
}
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+
}

‎kernel/trace/trace_probe.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ static inline bool trace_probe_is_registered(struct trace_probe *tp)
251251
int trace_probe_init(struct trace_probe *tp, const char *event,
252252
const char *group);
253253
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+
}
254260

255261
/* Check the name is good for event/group/fields */
256262
static inline bool is_good_name(const char *name)

‎kernel/trace/trace_uprobe.c‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,30 +1345,14 @@ static inline void init_trace_event_call(struct trace_uprobe *tu,
13451345

13461346
static int register_uprobe_event(struct trace_uprobe *tu)
13471347
{
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);
13641349

1365-
return ret;
1350+
return trace_probe_register_event_call(&tu->tp);
13661351
}
13671352

13681353
static int unregister_uprobe_event(struct trace_uprobe *tu)
13691354
{
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);
13721356
}
13731357

13741358
#ifdef CONFIG_PERF_EVENTS

0 commit comments

Comments
 (0)