Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932324AbbFRIRe (ORCPT ); Thu, 18 Jun 2015 04:17:34 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57256 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932276AbbFRIRW (ORCPT ); Thu, 18 Jun 2015 04:17:22 -0400 Date: Thu, 18 Jun 2015 01:16:43 -0700 From: tip-bot for Masami Hiramatsu Message-ID: Cc: namhyung@kernel.org, hpa@zytor.com, mingo@kernel.org, masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de, peterz@infradead.org, dsahern@gmail.com, naota@elisp.net, acme@redhat.com, jolsa@redhat.com, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, hpa@zytor.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, acme@redhat.com, jolsa@redhat.com, peterz@infradead.org, tglx@linutronix.de, dsahern@gmail.com, naota@elisp.net, masami.hiramatsu.pt@hitachi.com In-Reply-To: <20150616115057.19906.5502.stgit@localhost.localdomain> References: <20150616115057.19906.5502.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf probe: Show usage even if the last event is skipped Git-Commit-ID: d350bd571ffa89fc3bd07cfa9685d5210f459be8 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: 5544 Lines: 157 Commit-ID: d350bd571ffa89fc3bd07cfa9685d5210f459be8 Gitweb: http://git.kernel.org/tip/d350bd571ffa89fc3bd07cfa9685d5210f459be8 Author: Masami Hiramatsu AuthorDate: Tue, 16 Jun 2015 20:50:57 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 17 Jun 2015 16:31:42 -0300 perf probe: Show usage even if the last event is skipped When the last part of converted events are blacklisted or out-of-text, those are skipped and perf probe doesn't show usage examples. This fixes it to show the example even if the last part of event list is skipped. E.g. without this patch, events are added, but suddenly end: # perf probe vfs_* vfs_caches_init_early is out of .text, skip it. vfs_caches_init is out of .text, skip it. Added new events: probe:vfs_fallocate (on vfs_*) probe:vfs_open (on vfs_*) ... probe:vfs_dentry_acceptable (on vfs_*) probe:vfs_load_quota_inode (on vfs_*) # With this fix: # perf probe vfs_* vfs_caches_init_early is out of .text, skip it. vfs_caches_init is out of .text, skip it. Added new events: probe:vfs_fallocate (on vfs_*) ... probe:vfs_load_quota_inode (on vfs_*) You can now use it in all perf tools, such as: perf record -e probe:vfs_load_quota_inode -aR sleep 1 Note that this can be reproduced ONLY IF the vfs_caches_init* is the last part of matched symbol list. I've checked this happens on "3.19.0-generic #18-Ubuntu" kernel binary. Signed-off-by: Masami Hiramatsu Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Naohiro Aota Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20150616115057.19906.5502.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 85c8207..65a1c82 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2157,7 +2157,8 @@ static bool kprobe_blacklist__listed(unsigned long address) return !!kprobe_blacklist__find_by_address(&kprobe_blacklist, address); } -static int perf_probe_event__sprintf(struct perf_probe_event *pev, +static int perf_probe_event__sprintf(const char *group, const char *event, + struct perf_probe_event *pev, const char *module, struct strbuf *result) { @@ -2170,7 +2171,7 @@ static int perf_probe_event__sprintf(struct perf_probe_event *pev, if (!place) return -EINVAL; - ret = e_snprintf(buf, 128, "%s:%s", pev->group, pev->event); + ret = e_snprintf(buf, 128, "%s:%s", group, event); if (ret < 0) goto out; @@ -2195,13 +2196,14 @@ out: } /* Show an event */ -static int show_perf_probe_event(struct perf_probe_event *pev, +static int show_perf_probe_event(const char *group, const char *event, + struct perf_probe_event *pev, const char *module, bool use_stdout) { struct strbuf buf = STRBUF_INIT; int ret; - ret = perf_probe_event__sprintf(pev, module, &buf); + ret = perf_probe_event__sprintf(group, event, pev, module, &buf); if (ret >= 0) { if (use_stdout) printf("%s\n", buf.buf); @@ -2253,7 +2255,8 @@ static int __show_perf_probe_events(int fd, bool is_kprobe, is_kprobe); if (ret < 0) goto next; - ret = show_perf_probe_event(&pev, tev.point.module, + ret = show_perf_probe_event(pev.group, pev.event, + &pev, tev.point.module, true); } next: @@ -2438,7 +2441,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, int i, fd, ret; struct probe_trace_event *tev = NULL; char buf[64]; - const char *event, *group; + const char *event = NULL, *group = NULL; struct strlist *namelist; bool safename; @@ -2500,15 +2503,12 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, /* Add added event name to namelist */ strlist__add(namelist, event); - /* Trick here - save current event/group */ - event = pev->event; - group = pev->group; - pev->event = tev->event; - pev->group = tev->group; - show_perf_probe_event(pev, tev->point.module, false); - /* Trick here - restore current event/group */ - pev->event = (char *)event; - pev->group = (char *)group; + /* We use tev's name for showing new events */ + show_perf_probe_event(tev->group, tev->event, pev, + tev->point.module, false); + /* Save the last valid name */ + event = tev->event; + group = tev->group; /* * Probes after the first probe which comes from same @@ -2522,11 +2522,10 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, warn_uprobe_event_compat(tev); /* Note that it is possible to skip all events because of blacklist */ - if (ret >= 0 && tev->event) { + if (ret >= 0 && event) { /* 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", tev->group, - tev->event); + pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event); } strlist__delete(namelist); -- 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/