Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo 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@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Masami Hiramatsu and committed by
Arnaldo Carvalho de Melo
72363540 15354d54

+15 -2
+7 -2
tools/perf/util/probe-event.c
··· 2738 2738 if (tev->event == NULL || tev->group == NULL) 2739 2739 return -ENOMEM; 2740 2740 2741 - /* Add added event name to namelist */ 2742 - strlist__add(namelist, event); 2741 + /* 2742 + * Add new event name to namelist if multiprobe event is NOT 2743 + * supported, since we have to use new event name for following 2744 + * probes in that case. 2745 + */ 2746 + if (!multiprobe_event_is_supported()) 2747 + strlist__add(namelist, event); 2743 2748 return 0; 2744 2749 } 2745 2750
+7
tools/perf/util/probe-file.c
··· 1007 1007 FTRACE_README_KRETPROBE_OFFSET, 1008 1008 FTRACE_README_UPROBE_REF_CTR, 1009 1009 FTRACE_README_USER_ACCESS, 1010 + FTRACE_README_MULTIPROBE_EVENT, 1010 1011 FTRACE_README_END, 1011 1012 }; 1012 1013 ··· 1021 1020 DEFINE_TYPE(FTRACE_README_KRETPROBE_OFFSET, "*place (kretprobe): *"), 1022 1021 DEFINE_TYPE(FTRACE_README_UPROBE_REF_CTR, "*ref_ctr_offset*"), 1023 1022 DEFINE_TYPE(FTRACE_README_USER_ACCESS, "*[u]<offset>*"), 1023 + DEFINE_TYPE(FTRACE_README_MULTIPROBE_EVENT, "*Create/append/*"), 1024 1024 }; 1025 1025 1026 1026 static bool scan_ftrace_readme(enum ftrace_readme type) ··· 1086 1084 bool user_access_is_supported(void) 1087 1085 { 1088 1086 return scan_ftrace_readme(FTRACE_README_USER_ACCESS); 1087 + } 1088 + 1089 + bool multiprobe_event_is_supported(void) 1090 + { 1091 + return scan_ftrace_readme(FTRACE_README_MULTIPROBE_EVENT); 1089 1092 }
+1
tools/perf/util/probe-file.h
··· 71 71 bool kretprobe_offset_is_supported(void); 72 72 bool uprobe_ref_ctr_is_supported(void); 73 73 bool user_access_is_supported(void); 74 + bool multiprobe_event_is_supported(void); 74 75 #else /* ! HAVE_LIBELF_SUPPORT */ 75 76 static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused, struct nsinfo *nsi __maybe_unused) 76 77 {