Commit 72363540 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf probe: Support multiprobe event

Support multiprobe event if the event is based on function and lines and
kernel supports it. In this case, perf probe creates the first probe
with an event, and tries to append following probes on that event, since
those probes must be on the same source code line.

Before this patch;

  # perf probe -a vfs_read:18
  Added new events:
    probe:vfs_read_L18   (on vfs_read:18)
    probe:vfs_read_L18_1 (on vfs_read:18)

  You can now use it in all perf tools, such as:

  	perf record -e probe:vfs_read_L18_1 -aR sleep 1

  #

After this patch (on multiprobe supported kernel)
  # perf probe -a vfs_read:18
  Added new events:
    probe:vfs_read_L18   (on vfs_read:18)
    probe:vfs_read_L18   (on vfs_read:18)

  You can now use it in all perf tools, such as:

  	perf record -e probe:vfs_read_L18 -aR sleep 1

  #

Committer testing:

On a kernel that doesn't support multiprobe events, after this patch:

  # uname -a
  Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  # grep append /sys/kernel/debug/tracing/README
  	    be modified by appending '.descending' or '.ascending' to a
  	    can be modified by appending any of the following modifiers
  #
  # perf probe -a vfs_read:18
  Added new events:
    probe:vfs_read_L18   (on vfs_read:18)
    probe:vfs_read_L18_1 (on vfs_read:18)

  You can now use it in all perf tools, such as:

  	perf record -e probe:vfs_read_L18_1 -aR sleep 1

  # perf probe -l
    probe:vfs_read_L18   (on vfs_read:18@fs/read_write.c)
    probe:vfs_read_L18_1 (on vfs_read:18@fs/read_write.c)
  #
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Link: http://lore.kernel.org/lkml/157406475010.24476.586290752591512351.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 15354d54
...@@ -2738,8 +2738,13 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev, ...@@ -2738,8 +2738,13 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev,
if (tev->event == NULL || tev->group == NULL) if (tev->event == NULL || tev->group == NULL)
return -ENOMEM; return -ENOMEM;
/* Add added event name to namelist */ /*
strlist__add(namelist, event); * Add new event name to namelist if multiprobe event is NOT
* supported, since we have to use new event name for following
* probes in that case.
*/
if (!multiprobe_event_is_supported())
strlist__add(namelist, event);
return 0; return 0;
} }
......
...@@ -1007,6 +1007,7 @@ enum ftrace_readme { ...@@ -1007,6 +1007,7 @@ enum ftrace_readme {
FTRACE_README_KRETPROBE_OFFSET, FTRACE_README_KRETPROBE_OFFSET,
FTRACE_README_UPROBE_REF_CTR, FTRACE_README_UPROBE_REF_CTR,
FTRACE_README_USER_ACCESS, FTRACE_README_USER_ACCESS,
FTRACE_README_MULTIPROBE_EVENT,
FTRACE_README_END, FTRACE_README_END,
}; };
...@@ -1020,6 +1021,7 @@ static struct { ...@@ -1020,6 +1021,7 @@ static struct {
DEFINE_TYPE(FTRACE_README_KRETPROBE_OFFSET, "*place (kretprobe): *"), DEFINE_TYPE(FTRACE_README_KRETPROBE_OFFSET, "*place (kretprobe): *"),
DEFINE_TYPE(FTRACE_README_UPROBE_REF_CTR, "*ref_ctr_offset*"), DEFINE_TYPE(FTRACE_README_UPROBE_REF_CTR, "*ref_ctr_offset*"),
DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*[u]<offset>*"), DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*[u]<offset>*"),
DEFINE_TYPE(FTRACE_README_MULTIPROBE_EVENT, "*Create/append/*"),
}; };
static bool scan_ftrace_readme(enum ftrace_readme type) static bool scan_ftrace_readme(enum ftrace_readme type)
...@@ -1085,3 +1087,8 @@ bool user_access_is_supported(void) ...@@ -1085,3 +1087,8 @@ bool user_access_is_supported(void)
{ {
return scan_ftrace_readme(FTRACE_README_USER_ACCESS); return scan_ftrace_readme(FTRACE_README_USER_ACCESS);
} }
bool multiprobe_event_is_supported(void)
{
return scan_ftrace_readme(FTRACE_README_MULTIPROBE_EVENT);
}
...@@ -71,6 +71,7 @@ bool probe_type_is_available(enum probe_type type); ...@@ -71,6 +71,7 @@ bool probe_type_is_available(enum probe_type type);
bool kretprobe_offset_is_supported(void); bool kretprobe_offset_is_supported(void);
bool uprobe_ref_ctr_is_supported(void); bool uprobe_ref_ctr_is_supported(void);
bool user_access_is_supported(void); bool user_access_is_supported(void);
bool multiprobe_event_is_supported(void);
#else /* ! HAVE_LIBELF_SUPPORT */ #else /* ! HAVE_LIBELF_SUPPORT */
static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused) static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment