public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ingo Molnar <mingo@redhat.com>, Paul Mackerras <paulus@samba.org>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Borislav Petkov <bp@suse.de>,
	Hemant Kumar <hemant@linux.vnet.ibm.com>
Subject: [RFC PATCH perf/core v3 17/17] perf record: Support recording SDT events
Date: Sat, 15 Aug 2015 20:43:29 +0900	[thread overview]
Message-ID: <20150815114329.13642.11554.stgit@localhost.localdomain> (raw)
In-Reply-To: <20150815114252.13642.62690.stgit@localhost.localdomain>

perf record -e "sdt_PROVIDER:EVENT" is available as same as
other tracepoint events.
In this version, the wildcard and @filename or build-id are not
supported yet.

Note that this doesn't clear (unregister) probe event after recorded
events, since that can skip to register same event next time and
anyway we can not unregister it if someone use the event via ftrace.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/builtin-probe.c     |    3 --
 tools/perf/util/parse-events.c |   59 +++++++++++++++++++++++++++++++++++++++-
 tools/perf/util/probe-event.c  |   18 ++++++++----
 tools/perf/util/probe-event.h  |    1 +
 4 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 5d0c246..a94e54f 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -441,9 +441,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
 		verbose = -1;
 	}
 
-	if (probe_conf.max_probes == 0)
-		probe_conf.max_probes = MAX_PROBES;
-
 	/*
 	 * Only consider the user's kernel image path if given.
 	 */
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index a19f7f9..36d88f0 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -473,8 +473,8 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
 	return ret;
 }
 
-int parse_events_add_tracepoint(struct list_head *list, int *idx,
-				char *sys, char *event)
+static int __parse_events_add_tracepoint(struct list_head *list, int *idx,
+					 char *sys, char *event)
 {
 	if (strpbrk(sys, "*?"))
 		return add_tracepoint_multi_sys(list, idx, sys, event);
@@ -482,6 +482,61 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
 		return add_tracepoint_event(list, idx, sys, event);
 }
 
+static int activate_sdt_events(char *sys, char *event)
+{
+	struct probe_cache *cache;
+	struct probe_cache_entry *entry;
+	struct strlist *bidlist;
+	struct str_node *nd;
+	struct perf_probe_event pev;
+	char *path = NULL;
+	int ret;
+
+	ret = build_id_cache__list_all(&bidlist, true);
+	if (ret < 0) {
+		pr_debug("Failed to get buildids: %d\n", ret);
+		return ret;
+	}
+
+	strlist__for_each(nd, bidlist) {
+		cache = probe_cache__new(nd->s);
+		if (!cache)
+			continue;
+		entry = probe_cache__find_by_name(cache, sys, event);
+		probe_cache__delete(cache);
+		if (entry) {
+			path = build_id_cache__origname(nd->s);
+			break;
+		}
+	}
+	if (!path) {
+		pr_debug("Failed to find %s:%s in probe cache\n", sys, event);
+		return -ENOENT;
+	}
+
+	memset(&pev, 0, sizeof(pev));
+	pev.point.function = event;
+	pev.event = event;
+	pev.group = sys;
+	pev.sdt = true;
+	pev.uprobes = true;
+	pev.target = path;
+	probe_conf.internal_call = true;
+	ret = add_perf_probe_events(&pev, 1);
+	free(path);
+	return ret;
+}
+
+int parse_events_add_tracepoint(struct list_head *list, int *idx,
+				char *sys, char *event)
+{
+	int ret = __parse_events_add_tracepoint(list, idx, sys, event);
+	/* Retry with activating SDTs */
+	if (ret < 0 && activate_sdt_events(sys, event) > 0)
+		return  __parse_events_add_tracepoint(list, idx, sys, event);
+	return ret;
+}
+
 static int
 parse_breakpoint_type(const char *type, struct perf_event_attr *attr)
 {
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index d2fa266..ecb953c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -52,7 +52,9 @@
 #define PERFPROBE_GROUP "probe"
 
 bool probe_event_dry_run;	/* Dry run flag */
-struct probe_conf probe_conf;
+struct probe_conf probe_conf = {
+	.max_probes = MAX_PROBES,
+};
 
 #define semantic_error(msg ...) pr_err("Semantic error :" msg)
 
@@ -2404,7 +2406,8 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
 	}
 
 	ret = 0;
-	pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
+	if (!probe_conf.internal_call)
+		pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
 	for (i = 0; i < ntevs; i++) {
 		tev = &tevs[i];
 		/* Skip if the symbol is out of .text or blacklisted */
@@ -2422,8 +2425,9 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
 			break;
 
 		/* We use tev's name for showing new events */
-		show_perf_probe_event(tev->group, tev->event, pev,
-				      tev->point.module, false);
+		if (!probe_conf.internal_call)
+			show_perf_probe_event(tev->group, tev->event, pev,
+					      tev->point.module, false);
 		/* Save the last valid name */
 		event = tev->event;
 		group = tev->group;
@@ -2452,8 +2456,10 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
 			}
 		}
 		/* Show how to use the event. */
-		pr_info("\nYou can now use it in all perf tools, such as:\n\n");
-		pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event);
+		if (!probe_conf.internal_call) {
+			pr_info("\nYou can now use it in all perf tools, such as:\n\n");
+			pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event);
+		}
 	}
 
 	strlist__delete(namelist);
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 2cd60e6..8cab4a6 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -13,6 +13,7 @@ struct probe_conf {
 	bool	force_add;
 	bool	no_inlines;
 	bool	cache;
+	bool	internal_call;	/* Internal use */
 	int	max_probes;
 };
 extern struct probe_conf probe_conf;


  parent reply	other threads:[~2015-08-15 11:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-15 11:42 [RFC PATCH perf/core v3 00/17] perf-probe --cache and SDT support Masami Hiramatsu
2015-08-15 11:42 ` [RFC PATCH perf/core v3 01/17] perf probe: Use strbuf for making strings in probe-event.c Masami Hiramatsu
2015-08-28 15:56   ` Arnaldo Carvalho de Melo
2015-08-15 11:42 ` [RFC PATCH perf/core v3 02/17] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid Masami Hiramatsu
2015-08-28 16:07   ` Arnaldo Carvalho de Melo
2015-08-15 11:42 ` [RFC PATCH perf/core v3 03/17] perf buildid: Introduce sysfs/filename__sprintf_build_id Masami Hiramatsu
2015-08-28 16:14   ` Arnaldo Carvalho de Melo
2015-08-31  8:32   ` [tip:perf/core] perf buildid: Introduce sysfs/ filename__sprintf_build_id tip-bot for Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 04/17] perf: Add lsdir to read a directory Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 05/17] perf-buildid-cache: Use lsdir for looking up buildid caches Masami Hiramatsu
2015-08-28 16:17   ` Arnaldo Carvalho de Melo
2015-08-15 11:43 ` [RFC PATCH perf/core v3 06/17] perf probe: Add --cache option to cache the probe definitions Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 07/17] perf probe: Use cache entry if possible Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 08/17] perf probe: Show all cached probes Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 09/17] perf probe: Remove caches when --cache is given Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 10/17] perf/sdt: ELF support for SDT Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 11/17] perf probe: Add group name support Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 12/17] perf-probe: Set default kprobe group name if it is not given Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 13/17] perf buildid-cache: Scan and import user SDT events to probe cache Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 14/17] perf probe: Accept %sdt and %cached event name Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 15/17] perf-list: Show SDT events Masami Hiramatsu
2015-08-15 11:43 ` [RFC PATCH perf/core v3 16/17] perf-list: Skip SDTs placed in invalid binaries Masami Hiramatsu
2015-08-15 11:43 ` Masami Hiramatsu [this message]
2015-08-19  8:30 ` [RFC PATCH perf/core v3 00/17] perf-probe --cache and SDT support Namhyung Kim
2015-08-19 15:15   ` 平松雅巳 / HIRAMATU,MASAMI

Reply instructions:

You may reply publicly 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20150815114329.13642.11554.stgit@localhost.localdomain \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=bp@suse.de \
    --cc=hemant@linux.vnet.ibm.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox