Skip to content

Commit b55ce20

Browse files
mhiramatrostedt
authored andcommitted
tracing/probe: Add probe event name and group name accesses APIs
Add trace_probe_name() and trace_probe_group_name() functions for accessing probe name and group name of trace_probe. Link: http://lkml.kernel.org/r/155931586717.28323.8738615064952254761.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 747774d commit b55ce20

3 files changed

Lines changed: 33 additions & 23 deletions

File tree

‎kernel/trace/trace_kprobe.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ static bool trace_kprobe_match(const char *system, const char *event,
142142
{
143143
struct trace_kprobe *tk = to_trace_kprobe(ev);
144144

145-
return strcmp(trace_event_name(&tk->tp.call), event) == 0 &&
146-
(!system || strcmp(tk->tp.call.class->system, system) == 0);
145+
return strcmp(trace_probe_name(&tk->tp), event) == 0 &&
146+
(!system || strcmp(trace_probe_group_name(&tk->tp), system) == 0);
147147
}
148148

149149
static nokprobe_inline unsigned long trace_kprobe_nhit(struct trace_kprobe *tk)
@@ -263,8 +263,8 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
263263
struct trace_kprobe *tk;
264264

265265
for_each_trace_kprobe(tk, pos)
266-
if (strcmp(trace_event_name(&tk->tp.call), event) == 0 &&
267-
strcmp(tk->tp.call.class->system, group) == 0)
266+
if (strcmp(trace_probe_name(&tk->tp), event) == 0 &&
267+
strcmp(trace_probe_group_name(&tk->tp), group) == 0)
268268
return tk;
269269
return NULL;
270270
}
@@ -453,8 +453,8 @@ static int register_trace_kprobe(struct trace_kprobe *tk)
453453
mutex_lock(&event_mutex);
454454

455455
/* Delete old (same name) event if exist */
456-
old_tk = find_trace_kprobe(trace_event_name(&tk->tp.call),
457-
tk->tp.call.class->system);
456+
old_tk = find_trace_kprobe(trace_probe_name(&tk->tp),
457+
trace_probe_group_name(&tk->tp));
458458
if (old_tk) {
459459
ret = unregister_trace_kprobe(old_tk);
460460
if (ret < 0)
@@ -507,7 +507,7 @@ static int trace_kprobe_module_callback(struct notifier_block *nb,
507507
ret = __register_trace_kprobe(tk);
508508
if (ret)
509509
pr_warn("Failed to re-register probe %s on %s: %d\n",
510-
trace_event_name(&tk->tp.call),
510+
trace_probe_name(&tk->tp),
511511
mod->name, ret);
512512
}
513513
}
@@ -737,8 +737,8 @@ static int trace_kprobe_show(struct seq_file *m, struct dyn_event *ev)
737737
int i;
738738

739739
seq_putc(m, trace_kprobe_is_return(tk) ? 'r' : 'p');
740-
seq_printf(m, ":%s/%s", tk->tp.call.class->system,
741-
trace_event_name(&tk->tp.call));
740+
seq_printf(m, ":%s/%s", trace_probe_group_name(&tk->tp),
741+
trace_probe_name(&tk->tp));
742742

743743
if (!tk->symbol)
744744
seq_printf(m, " 0x%p", tk->rp.kp.addr);
@@ -812,7 +812,7 @@ static int probes_profile_seq_show(struct seq_file *m, void *v)
812812

813813
tk = to_trace_kprobe(ev);
814814
seq_printf(m, " %-44s %15lu %15lu\n",
815-
trace_event_name(&tk->tp.call),
815+
trace_probe_name(&tk->tp),
816816
trace_kprobe_nhit(tk),
817817
tk->rp.kp.nmissed);
818818

@@ -1084,7 +1084,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags,
10841084
field = (struct kprobe_trace_entry_head *)iter->ent;
10851085
tp = container_of(event, struct trace_probe, call.event);
10861086

1087-
trace_seq_printf(s, "%s: (", trace_event_name(&tp->call));
1087+
trace_seq_printf(s, "%s: (", trace_probe_name(tp));
10881088

10891089
if (!seq_print_ip_sym(s, field->ip, flags | TRACE_ITER_SYM_OFFSET))
10901090
goto out;
@@ -1111,7 +1111,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags,
11111111
field = (struct kretprobe_trace_entry_head *)iter->ent;
11121112
tp = container_of(event, struct trace_probe, call.event);
11131113

1114-
trace_seq_printf(s, "%s: (", trace_event_name(&tp->call));
1114+
trace_seq_printf(s, "%s: (", trace_probe_name(tp));
11151115

11161116
if (!seq_print_ip_sym(s, field->ret_ip, flags | TRACE_ITER_SYM_OFFSET))
11171117
goto out;

‎kernel/trace/trace_probe.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ static inline bool trace_probe_is_registered(struct trace_probe *tp)
266266
return trace_probe_test_flag(tp, TP_FLAG_REGISTERED);
267267
}
268268

269+
static inline const char *trace_probe_name(struct trace_probe *tp)
270+
{
271+
return trace_event_name(&tp->call);
272+
}
273+
274+
static inline const char *trace_probe_group_name(struct trace_probe *tp)
275+
{
276+
return tp->call.class->system;
277+
}
278+
269279
static inline int trace_probe_unregister_event_call(struct trace_probe *tp)
270280
{
271281
/* tp->event is unregistered in trace_remove_event_call() */

‎kernel/trace/trace_uprobe.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ static bool trace_uprobe_match(const char *system, const char *event,
289289
{
290290
struct trace_uprobe *tu = to_trace_uprobe(ev);
291291

292-
return strcmp(trace_event_name(&tu->tp.call), event) == 0 &&
293-
(!system || strcmp(tu->tp.call.class->system, system) == 0);
292+
return strcmp(trace_probe_name(&tu->tp), event) == 0 &&
293+
(!system || strcmp(trace_probe_group_name(&tu->tp), system) == 0);
294294
}
295295

296296
/*
@@ -340,8 +340,8 @@ static struct trace_uprobe *find_probe_event(const char *event, const char *grou
340340
struct trace_uprobe *tu;
341341

342342
for_each_trace_uprobe(tu, pos)
343-
if (strcmp(trace_event_name(&tu->tp.call), event) == 0 &&
344-
strcmp(tu->tp.call.class->system, group) == 0)
343+
if (strcmp(trace_probe_name(&tu->tp), event) == 0 &&
344+
strcmp(trace_probe_group_name(&tu->tp), group) == 0)
345345
return tu;
346346

347347
return NULL;
@@ -376,8 +376,8 @@ static struct trace_uprobe *find_old_trace_uprobe(struct trace_uprobe *new)
376376
struct trace_uprobe *tmp, *old = NULL;
377377
struct inode *new_inode = d_real_inode(new->path.dentry);
378378

379-
old = find_probe_event(trace_event_name(&new->tp.call),
380-
new->tp.call.class->system);
379+
old = find_probe_event(trace_probe_name(&new->tp),
380+
trace_probe_group_name(&new->tp));
381381

382382
for_each_trace_uprobe(tmp, pos) {
383383
if ((old ? old != tmp : true) &&
@@ -624,8 +624,8 @@ static int trace_uprobe_show(struct seq_file *m, struct dyn_event *ev)
624624
char c = is_ret_probe(tu) ? 'r' : 'p';
625625
int i;
626626

627-
seq_printf(m, "%c:%s/%s %s:0x%0*lx", c, tu->tp.call.class->system,
628-
trace_event_name(&tu->tp.call), tu->filename,
627+
seq_printf(m, "%c:%s/%s %s:0x%0*lx", c, trace_probe_group_name(&tu->tp),
628+
trace_probe_name(&tu->tp), tu->filename,
629629
(int)(sizeof(void *) * 2), tu->offset);
630630

631631
if (tu->ref_ctr_offset)
@@ -695,7 +695,7 @@ static int probes_profile_seq_show(struct seq_file *m, void *v)
695695

696696
tu = to_trace_uprobe(ev);
697697
seq_printf(m, " %s %-44s %15lu\n", tu->filename,
698-
trace_event_name(&tu->tp.call), tu->nhit);
698+
trace_probe_name(&tu->tp), tu->nhit);
699699
return 0;
700700
}
701701

@@ -896,12 +896,12 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e
896896

897897
if (is_ret_probe(tu)) {
898898
trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)",
899-
trace_event_name(&tu->tp.call),
899+
trace_probe_name(&tu->tp),
900900
entry->vaddr[1], entry->vaddr[0]);
901901
data = DATAOF_TRACE_ENTRY(entry, true);
902902
} else {
903903
trace_seq_printf(s, "%s: (0x%lx)",
904-
trace_event_name(&tu->tp.call),
904+
trace_probe_name(&tu->tp),
905905
entry->vaddr[0]);
906906
data = DATAOF_TRACE_ENTRY(entry, false);
907907
}

0 commit comments

Comments
 (0)