From: tip-bot for Masami Hiramatsu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@kernel.org, adrian.hunter@intel.com, tglx@linutronix.de,
paulus@samba.org, hemant@linux.vnet.ibm.com,
a.p.zijlstra@chello.nl, bp@suse.de, mingo@kernel.org,
namhyung@kernel.org, masami.hiramatsu.pt@hitachi.com,
acme@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org
Subject: [tip:perf/core] perf probe: Simplify __add_probe_trace_events code
Date: Tue, 21 Jul 2015 02:34:49 -0700 [thread overview]
Message-ID: <tip-a3c9de6280b8d196ab89ca7fad143bfa2a949790@git.kernel.org> (raw)
In-Reply-To: <20150715091400.8915.85501.stgit@localhost.localdomain>
Commit-ID: a3c9de6280b8d196ab89ca7fad143bfa2a949790
Gitweb: http://git.kernel.org/tip/a3c9de6280b8d196ab89ca7fad143bfa2a949790
Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Wed, 15 Jul 2015 18:14:00 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 20 Jul 2015 17:49:49 -0300
perf probe: Simplify __add_probe_trace_events code
Simplify the __add_probe_trace_events() code by taking out the
probe_trace_event__set_name() and updating show_perf_probe_event()
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20150715091400.8915.85501.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 70 ++++++++++++++++++++++++++-----------------
1 file changed, 43 insertions(+), 27 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 7abaac4..54a91d7 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -2478,16 +2478,54 @@ out:
free(buf);
}
+/* Set new name from original perf_probe_event and namelist */
+static int probe_trace_event__set_name(struct probe_trace_event *tev,
+ struct perf_probe_event *pev,
+ struct strlist *namelist,
+ bool allow_suffix)
+{
+ const char *event, *group;
+ char buf[64];
+ int ret;
+
+ if (pev->event)
+ event = pev->event;
+ else
+ if (pev->point.function && !strisglob(pev->point.function))
+ event = pev->point.function;
+ else
+ event = tev->point.realname;
+ if (pev->group)
+ group = pev->group;
+ else
+ group = PERFPROBE_GROUP;
+
+ /* Get an unused new event name */
+ ret = get_new_event_name(buf, 64, event,
+ namelist, allow_suffix);
+ if (ret < 0)
+ return ret;
+
+ event = buf;
+
+ tev->event = strdup(event);
+ tev->group = strdup(group);
+ if (tev->event == NULL || tev->group == NULL)
+ return -ENOMEM;
+
+ /* Add added event name to namelist */
+ strlist__add(namelist, event);
+ return 0;
+}
+
static int __add_probe_trace_events(struct perf_probe_event *pev,
struct probe_trace_event *tevs,
int ntevs, bool allow_suffix)
{
int i, fd, ret;
struct probe_trace_event *tev = NULL;
- char buf[64];
const char *event = NULL, *group = NULL;
struct strlist *namelist;
- bool safename;
if (pev->uprobes)
fd = open_uprobe_events(true);
@@ -2507,7 +2545,6 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
goto close_out;
}
- safename = (pev->point.function && !strisglob(pev->point.function));
ret = 0;
pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
for (i = 0; i < ntevs; i++) {
@@ -2516,36 +2553,15 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
if (!tev->point.symbol)
continue;
- if (pev->event)
- event = pev->event;
- else
- if (safename)
- event = pev->point.function;
- else
- event = tev->point.realname;
- if (pev->group)
- group = pev->group;
- else
- group = PERFPROBE_GROUP;
-
- /* Get an unused new event name */
- ret = get_new_event_name(buf, 64, event,
- namelist, allow_suffix);
+ /* Set new name for tev (and update namelist) */
+ ret = probe_trace_event__set_name(tev, pev, namelist,
+ allow_suffix);
if (ret < 0)
break;
- event = buf;
- tev->event = strdup(event);
- tev->group = strdup(group);
- if (tev->event == NULL || tev->group == NULL) {
- ret = -ENOMEM;
- break;
- }
ret = write_probe_trace_event(fd, tev);
if (ret < 0)
break;
- /* Add added event name to namelist */
- strlist__add(namelist, event);
/* We use tev's name for showing new events */
show_perf_probe_event(tev->group, tev->event, pev,
next prev parent reply other threads:[~2015-07-21 9:35 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-15 9:13 [RFC PATCH perf/core v2 00/16] perf-probe --cache and SDT support Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 01/16] perf probe: Simplify __add_probe_trace_events code Masami Hiramatsu
2015-07-21 9:34 ` tip-bot for Masami Hiramatsu [this message]
2015-07-15 9:14 ` [RFC PATCH perf/core v2 02/16] perf probe: Move ftrace probe-event operations to probe-file.c Masami Hiramatsu
2015-07-21 9:35 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 03/16] perf probe: Use strbuf for making strings in probe-event.c Masami Hiramatsu
2015-07-17 7:42 ` Namhyung Kim
2015-07-17 10:16 ` Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 04/16] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 05/16] perf buildid: Use SBUILD_ID_SIZE macro Masami Hiramatsu
2015-07-20 18:47 ` Arnaldo Carvalho de Melo
2015-07-21 9:35 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 06/16] perf buildid: Introduce sysfs/filename__sprintf_build_id Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 07/16] perf: Add lsdir to read a directory Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 08/16] perf-buildid-cache: Use lsdir for looking up buildid caches Masami Hiramatsu
2015-07-15 9:14 ` [RFC PATCH perf/core v2 09/16] perf probe: Add --cache option to cache the probe definitions Masami Hiramatsu
2015-07-15 9:15 ` [RFC PATCH perf/core v2 10/16] perf probe: Use cache entry if possible Masami Hiramatsu
2015-07-15 9:15 ` [RFC PATCH perf/core v2 11/16] perf probe: Show all cached probes Masami Hiramatsu
2015-07-15 9:15 ` [RFC PATCH perf/core v2 12/16] perf probe: Remove caches when --cache is given Masami Hiramatsu
2015-07-15 9:15 ` [RFC PATCH perf/core v2 13/16] perf/sdt: ELF support for SDT Masami Hiramatsu
2015-07-15 9:15 ` [RFC PATCH perf/core v2 14/16] perf probe: Add group name support Masami Hiramatsu
2015-07-19 10:16 ` Namhyung Kim
2015-07-20 4:48 ` Masami Hiramatsu
2015-07-20 15:31 ` Namhyung Kim
2015-07-15 9:15 ` [RFC PATCH perf/core v2 15/16] perf buildid-cache: Scan and import user SDT events to probe cache Masami Hiramatsu
2015-07-19 10:46 ` Namhyung Kim
2015-07-20 3:19 ` Masami Hiramatsu
2015-07-20 15:52 ` Namhyung Kim
2015-07-21 10:42 ` Masami Hiramatsu
2015-07-15 9:15 ` [RFC PATCH perf/core v2 16/16] perf probe: Accept %sdt and %cached event name Masami Hiramatsu
2015-07-19 10:53 ` Namhyung Kim
2015-07-20 3:03 ` Masami Hiramatsu
2015-07-16 3:13 ` [RFC PATCH perf/core v2 00/16] perf-probe --cache and SDT support Hemant Kumar
2015-07-17 3:21 ` Masami Hiramatsu
2015-07-19 4:24 ` Namhyung Kim
2015-07-20 5:47 ` Brendan Gregg
2015-07-20 16:20 ` Namhyung Kim
2015-07-21 10:34 ` Masami Hiramatsu
2015-07-22 14:12 ` Hemant Kumar
2015-07-23 13:13 ` Masami Hiramatsu
2015-07-23 14:01 ` Arnaldo Carvalho de Melo
2015-07-23 16:24 ` Masami Hiramatsu
2015-07-23 16:42 ` Arnaldo Carvalho de Melo
2015-07-24 7:55 ` Namhyung Kim
2015-07-24 15:52 ` Arnaldo Carvalho de Melo
2015-07-25 0:51 ` Masami Hiramatsu
2015-07-27 14:03 ` Re: " Namhyung Kim
2015-07-27 15:16 ` Arnaldo Carvalho de Melo
2015-07-28 0:42 ` Masami Hiramatsu
2015-07-28 13:45 ` Arnaldo Carvalho de Melo
2015-07-20 18:36 ` Arnaldo Carvalho de Melo
2015-07-20 18:42 ` Arnaldo Carvalho de Melo
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=tip-a3c9de6280b8d196ab89ca7fad143bfa2a949790@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=bp@suse.de \
--cc=hemant@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).