Linux-rt-users archive on
 help / color / Atom feed
From: Masami Hiramatsu <>
To: Arnaldo Carvalho de Melo <>
Cc: Masami Hiramatsu <>,
	bhargavb <>,, Paul Clarke <>,
	Ravi Bangoria <>,
	Thomas Richter <>,,
Subject: [PATCH v3 3/5] perf-probe: Add __return suffix for return events
Date: Sat,  9 Dec 2017 01:27:44 +0900
Message-ID: <151275046418.24652.6696011972866498489.stgit@devbox> (raw)
In-Reply-To: <151275037752.24652.5169845651138876257.stgit@devbox>

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.

  # ./perf probe -x /lib64/ 'malloc*%return'
  Added new events:
    probe_libc:malloc_printerr__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_consolidate__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_check__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_hook_ini__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_trim__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_usable_size__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_stats__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_info__return (on malloc*%return in /usr/lib64/
    probe_libc:mallochook__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_get_state__return (on malloc*%return in /usr/lib64/
    probe_libc:malloc_set_state__return (on malloc*%return in /usr/lib64/

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

	  perf record -e probe_libc:malloc_set_state__return -aR sleep 1


Signed-off-by: Masami Hiramatsu <>
Reported-by: Arnaldo Carvalho de Melo <>
Acked-by: Ravi Bangoria <>
  Changes in v2:
   - Add a description in Documentation/perf-probe.txt.
 tools/perf/Documentation/perf-probe.txt |    2 +-
 tools/perf/util/probe-event.c           |    9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index d7e4869905f1..f96382692f42 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -170,7 +170,7 @@ Probe points are defined by following syntax.
-'EVENT' specifies the name of new event, if omitted, it will be set the name of the probed function. You can also specify a group name by 'GROUP', if omitted, set 'probe' is used for kprobe and 'probe_<bin>' is used for uprobe.
+'EVENT' specifies the name of new event, if omitted, it will be set the name of the probed function, and for return probes, a "\_\_return" suffix is automatically added to the function name. You can also specify a group name by 'GROUP', if omitted, set 'probe' is used for kprobe and 'probe_<bin>' is used for uprobe.
 Note that using existing group name can conflict with other events. Especially, using the group name reserved for kernel modules can hide embedded events in the
 'FUNC' specifies a probed function name, and it may have one of the following options; '+OFFS' is the offset from function entry address in bytes, ':RLN' is the relative-line number from function entry line, and '%return' means that it probes function return. And ';PTN' means lazy matching pattern (see LAZY MATCHING). Note that ';PTN' must be the end of the probe point definition.  In addition, '@SRC' specifies a source file which has that function.
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7e582547ac07..a68141d360b0 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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,
 	/* 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;

  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 16:26 [PATCH v3 0/5] perf-probe: Improve probing on versioned symbols Masami Hiramatsu
2017-12-08 16:26 ` [PATCH v3 1/5] perf-probe: Add warning message if there is unexpected event name Masami Hiramatsu
2017-12-08 16:27 ` [PATCH v3 2/5] perf-probe: Cut off the version suffix from " Masami Hiramatsu
2017-12-08 16:27 ` Masami Hiramatsu [this message]
2017-12-08 16:28 ` [PATCH v3 4/5] perf-probe: Find versioned symbols from map Masami Hiramatsu
2017-12-08 16:28 ` [PATCH v3 5/5] perf-probe: Support escaped character in parser Masami Hiramatsu
2017-12-11 20:03   ` Arnaldo Carvalho de Melo
2017-12-12 14:46     ` Masami Hiramatsu
2017-12-12 15:01       ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151275046418.24652.6696011972866498489.stgit@devbox \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-rt-users archive on

Archives are clonable:
	git clone --mirror linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ \
	public-inbox-index linux-rt-users

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone