Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754702AbbGUJfW (ORCPT ); Tue, 21 Jul 2015 05:35:22 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40226 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753373AbbGUJfR (ORCPT ); Tue, 21 Jul 2015 05:35:17 -0400 Date: Tue, 21 Jul 2015 02:34:49 -0700 From: tip-bot for Masami Hiramatsu Message-ID: 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 Reply-To: 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, namhyung@kernel.org, mingo@kernel.org, masami.hiramatsu.pt@hitachi.com, hpa@zytor.com, linux-kernel@vger.kernel.org, acme@redhat.com In-Reply-To: <20150715091400.8915.85501.stgit@localhost.localdomain> References: <20150715091400.8915.85501.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf probe: Simplify __add_probe_trace_events code Git-Commit-ID: a3c9de6280b8d196ab89ca7fad143bfa2a949790 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4272 Lines: 140 Commit-ID: a3c9de6280b8d196ab89ca7fad143bfa2a949790 Gitweb: http://git.kernel.org/tip/a3c9de6280b8d196ab89ca7fad143bfa2a949790 Author: Masami Hiramatsu AuthorDate: Wed, 15 Jul 2015 18:14:00 +0900 Committer: Arnaldo Carvalho de Melo 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 Cc: Adrian Hunter Cc: Borislav Petkov Cc: Hemant Kumar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20150715091400.8915.85501.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo --- 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, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/