perf probe: Add __return suffix for return events
Add __return suffix for function return events automatically. Without this, user have to give --force option and will see the number suffix for each event like "function_1", which is not easy to recognize. Instead, this adds __return suffix to it automatically. E.g. ===== # ./perf probe -x /lib64/libc-2.25.so 'malloc*%return' Added new events: probe_libc:malloc_printerr__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_consolidate__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_check__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_hook_ini__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_trim__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_usable_size__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_stats__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_info__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:mallochook__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_get_state__return (on malloc*%return in /usr/lib64/libc-2.25.so) probe_libc:malloc_set_state__return (on malloc*%return in /usr/lib64/libc-2.25.so) You can now use it in all perf tools, such as: perf record -e probe_libc:malloc_set_state__return -aR sleep 1 ===== Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Clarke <pc@us.ibm.com> Cc: bhargavb <bhargavaramudu@gmail.com> Cc: linux-rt-users@vger.kernel.org Link: http://lkml.kernel.org/r/151275046418.24652.6696011972866498489.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
a3110cd9d0
commit
e63c625a1e
@@ -2573,7 +2573,8 @@ int show_perf_probe_events(struct strfilter *filter)
|
||||
}
|
||||
|
||||
static int get_new_event_name(char *buf, size_t len, const char *base,
|
||||
struct strlist *namelist, bool allow_suffix)
|
||||
struct strlist *namelist, bool ret_event,
|
||||
bool allow_suffix)
|
||||
{
|
||||
int i, ret;
|
||||
char *p, *nbase;
|
||||
@@ -2590,7 +2591,7 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
|
||||
*p = '\0';
|
||||
|
||||
/* Try no suffix number */
|
||||
ret = e_snprintf(buf, len, "%s", nbase);
|
||||
ret = e_snprintf(buf, len, "%s%s", nbase, ret_event ? "__return" : "");
|
||||
if (ret < 0) {
|
||||
pr_debug("snprintf() failed: %d\n", ret);
|
||||
goto out;
|
||||
@@ -2689,8 +2690,8 @@ static int probe_trace_event__set_name(struct probe_trace_event *tev,
|
||||
group = PERFPROBE_GROUP;
|
||||
|
||||
/* Get an unused new event name */
|
||||
ret = get_new_event_name(buf, 64, event,
|
||||
namelist, allow_suffix);
|
||||
ret = get_new_event_name(buf, 64, event, namelist,
|
||||
tev->point.retprobe, allow_suffix);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
Reference in New Issue
Block a user