perf probe: Support SDT markers having reference counter (semaphore)
With this, perf buildid-cache will save SDT markers with reference counter in probe cache. Perf probe will be able to probe markers having reference counter. Ex, # readelf -n /tmp/tick | grep -A1 loop2 Name: loop2 ... Semaphore: 0x0000000010020036 # ./perf buildid-cache --add /tmp/tick # ./perf probe sdt_tick:loop2 # ./perf stat -e sdt_tick:loop2 /tmp/tick hi: 0 hi: 1 hi: 2 ^C Performance counter stats for '/tmp/tick': 3 sdt_tick:loop2 2.561851452 seconds time elapsed Link: http://lkml.kernel.org/r/20180820044250.11659-5-ravi.bangoria@linux.ibm.com Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Reviewed-by: Song Liu <songliubraving@fb.com> Tested-by: Song Liu <songliubraving@fb.com> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:

committed by
Steven Rostedt (VMware)

parent
ccea8727dc
commit
5a5e3d3cea
@@ -1819,6 +1819,12 @@ int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev)
|
||||
tp->offset = strtoul(fmt2_str, NULL, 10);
|
||||
}
|
||||
|
||||
if (tev->uprobes) {
|
||||
fmt2_str = strchr(p, '(');
|
||||
if (fmt2_str)
|
||||
tp->ref_ctr_offset = strtoul(fmt2_str + 1, NULL, 0);
|
||||
}
|
||||
|
||||
tev->nargs = argc - 2;
|
||||
tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs);
|
||||
if (tev->args == NULL) {
|
||||
@@ -2012,6 +2018,22 @@ static int synthesize_probe_trace_arg(struct probe_trace_arg *arg,
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
synthesize_uprobe_trace_def(struct probe_trace_event *tev, struct strbuf *buf)
|
||||
{
|
||||
struct probe_trace_point *tp = &tev->point;
|
||||
int err;
|
||||
|
||||
err = strbuf_addf(buf, "%s:0x%lx", tp->module, tp->address);
|
||||
|
||||
if (err >= 0 && tp->ref_ctr_offset) {
|
||||
if (!uprobe_ref_ctr_is_supported())
|
||||
return -1;
|
||||
err = strbuf_addf(buf, "(0x%lx)", tp->ref_ctr_offset);
|
||||
}
|
||||
return err >= 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
char *synthesize_probe_trace_command(struct probe_trace_event *tev)
|
||||
{
|
||||
struct probe_trace_point *tp = &tev->point;
|
||||
@@ -2041,15 +2063,17 @@ char *synthesize_probe_trace_command(struct probe_trace_event *tev)
|
||||
}
|
||||
|
||||
/* Use the tp->address for uprobes */
|
||||
if (tev->uprobes)
|
||||
err = strbuf_addf(&buf, "%s:0x%lx", tp->module, tp->address);
|
||||
else if (!strncmp(tp->symbol, "0x", 2))
|
||||
if (tev->uprobes) {
|
||||
err = synthesize_uprobe_trace_def(tev, &buf);
|
||||
} else if (!strncmp(tp->symbol, "0x", 2)) {
|
||||
/* Absolute address. See try_to_find_absolute_address() */
|
||||
err = strbuf_addf(&buf, "%s%s0x%lx", tp->module ?: "",
|
||||
tp->module ? ":" : "", tp->address);
|
||||
else
|
||||
} else {
|
||||
err = strbuf_addf(&buf, "%s%s%s+%lu", tp->module ?: "",
|
||||
tp->module ? ":" : "", tp->symbol, tp->offset);
|
||||
}
|
||||
|
||||
if (err)
|
||||
goto error;
|
||||
|
||||
@@ -2633,6 +2657,13 @@ static void warn_uprobe_event_compat(struct probe_trace_event *tev)
|
||||
{
|
||||
int i;
|
||||
char *buf = synthesize_probe_trace_command(tev);
|
||||
struct probe_trace_point *tp = &tev->point;
|
||||
|
||||
if (tp->ref_ctr_offset && !uprobe_ref_ctr_is_supported()) {
|
||||
pr_warning("A semaphore is associated with %s:%s and "
|
||||
"seems your kernel doesn't support it.\n",
|
||||
tev->group, tev->event);
|
||||
}
|
||||
|
||||
/* Old uprobe event doesn't support memory dereference */
|
||||
if (!tev->uprobes || tev->nargs == 0 || !buf)
|
||||
|
Reference in New Issue
Block a user