From: Hemant Kumar <hemant@linux.vnet.ibm.com>
To: Masami Hiramatsu <mhiramat@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Subject: Re: [PATCH perf/core v5 12/15] perf-list: Show SDT and pre-cached events
Date: Thu, 28 Apr 2016 02:16:58 +0530 [thread overview]
Message-ID: <57212542.5000106@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160427183858.23446.62061.stgit@devbox>
On 04/28/2016 12:08 AM, Masami Hiramatsu wrote:
> From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>
> Show SDT and pre-cached events by perf-list with "sdt". This also
> shows the binary and build-id where the events are placed only
> when there are same name events on different binaries.
> e.g.
> ----
> # perf list sdt
>
> List of pre-defined events (to be used in -e):
>
> sdt_libc:lll_futex_wake [SDT event]
> sdt_libc:lll_lock_wait_private [SDT event]
> sdt_libc:longjmp [SDT event]
> sdt_libc:longjmp_target [SDT event]
> ...
> sdt_libstdcxx:rethrow@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> sdt_libstdcxx:rethrow@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> sdt_libstdcxx:throw@/usr/bin/gcc(0cc207fc4b27) [SDT event]
> sdt_libstdcxx:throw@/usr/lib64/libstdc++.so.6.0.20(91c7a88fdf49)
> ----
>
> The binary path and build-id are shown in below format;
>
> <GROUP>:<EVENT>@<PATH>(<BUILD-ID>)
>
> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
> ---
> Changes in v5:
> - Fix a build error for minimal option.
>
> Changes in v4:
> - Update patch description.
> - Change event list format.
> ---
> tools/perf/builtin-list.c | 4 ++
> tools/perf/util/parse-events.c | 83 ++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/parse-events.h | 2 +
> tools/perf/util/probe-file.h | 9 ++++
> 4 files changed, 98 insertions(+)
>
> diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
> index 5e22db4..3cba865 100644
> --- a/tools/perf/builtin-list.c
> +++ b/tools/perf/builtin-list.c
> @@ -62,6 +62,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
> print_hwcache_events(NULL, raw_dump);
> else if (strcmp(argv[i], "pmu") == 0)
> print_pmu_events(NULL, raw_dump);
> + else if (strcmp(argv[i], "sdt") == 0)
> + print_sdt_events(NULL, NULL, raw_dump);
> else if ((sep = strchr(argv[i], ':')) != NULL) {
> int sep_idx;
>
> @@ -76,6 +78,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
>
> s[sep_idx] = '\0';
> print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
> + print_sdt_events(s, s + sep_idx + 1, raw_dump);
> free(s);
> } else {
> if (asprintf(&s, "*%s*", argv[i]) < 0) {
> @@ -89,6 +92,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
> print_hwcache_events(s, raw_dump);
> print_pmu_events(s, raw_dump);
> print_tracepoint_events(NULL, s, raw_dump);
> + print_sdt_events(NULL, s, raw_dump);
> free(s);
> }
> }
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index bcbc983..f9c8b7b 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -20,6 +20,7 @@
> #include "pmu.h"
> #include "thread_map.h"
> #include "cpumap.h"
> +#include "probe-file.h"
> #include "asm/bug.h"
>
> #define MAX_NAME_LEN 100
> @@ -1976,6 +1977,86 @@ static bool is_event_supported(u8 type, unsigned config)
> return ret;
> }
>
> +void print_sdt_events(const char *subsys_glob, const char *event_glob,
> + bool name_only)
> +{
> + struct probe_cache *pcache;
> + struct probe_cache_entry *ent;
> + struct strlist *bidlist, *sdtlist;
> + struct strlist_config cfg = {.dont_dupstr = true};
> + struct str_node *nd, *nd2;
> + char *buf, *path, *ptr = NULL;
> + bool show_detail = false;
> + int ret;
> +
> + sdtlist = strlist__new(NULL, &cfg);
> + if (!sdtlist) {
> + pr_debug("Failed to allocate new strlist for SDT\n");
> + return;
> + }
> + ret = build_id_cache__list_all(&bidlist);
> + if (ret < 0) {
> + pr_debug("Failed to get buildids: %d\n", ret);
> + return;
> + }
> + strlist__for_each(nd, bidlist) {
> + pcache = probe_cache__new(nd->s);
> + if (!pcache)
> + continue;
> + if (!list_empty(&pcache->list))
> + list_for_each_entry(ent, &pcache->list, list) {
> + if (!ent->sdt)
> + continue;
> + if (subsys_glob &&
> + !strglobmatch(ent->pev.group, subsys_glob))
> + continue;
> + if (event_glob &&
> + !strglobmatch(ent->pev.event, event_glob))
> + continue;
> + ret = asprintf(&buf, "%s:%s@%s", ent->pev.group,
> + ent->pev.event, nd->s);
> + if (ret > 0)
> + strlist__add(sdtlist, buf);
> + }
> + probe_cache__delete(pcache);
> + }
> + strlist__delete(bidlist);
> +
> + strlist__for_each(nd, sdtlist) {
> + buf = strchr(nd->s, '@');
> + if (buf)
> + *(buf++) = '\0';
> + if (name_only) {
> + printf("%s ", nd->s);
> + continue;
> + }
> + nd2 = strlist__next(nd);
> + if (nd2) {
> + ptr = strchr(nd2->s, '@');
> + if (ptr)
> + *ptr = '\0';
> + if (strcmp(nd->s, nd2->s) == 0)
> + show_detail = true;
> + }
> + if (show_detail) {
> + path = build_id_cache__origname(buf);
> + ret = asprintf(&buf, "%s@%s(%.12s)", nd->s, path, buf);
> + if (ret > 0) {
> + printf(" %-50s [%s]\n", buf, "SDT event");
> + free(buf);
> + }
> + } else
> + printf(" %-50s [%s]\n", nd->s, "SDT event");
> + if (nd2) {
> + if (strcmp(nd->s, nd2->s) != 0)
> + show_detail = false;
> + if (ptr)
> + *ptr = '@';
> + }
> + }
> + strlist__delete(sdtlist);
> +}
> +
> int print_hwcache_events(const char *event_glob, bool name_only)
> {
> unsigned int type, op, i, evt_i = 0, evt_num = 0;
> @@ -2158,6 +2239,8 @@ void print_events(const char *event_glob, bool name_only)
> }
>
> print_tracepoint_events(NULL, NULL, name_only);
> +
> + print_sdt_events(NULL, NULL, name_only);
> }
>
> int parse_events__is_hardcoded_term(struct parse_events_term *term)
> diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
> index d740c3c..c08daa9 100644
> --- a/tools/perf/util/parse-events.h
> +++ b/tools/perf/util/parse-events.h
> @@ -182,6 +182,8 @@ void print_symbol_events(const char *event_glob, unsigned type,
> void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
> bool name_only);
> int print_hwcache_events(const char *event_glob, bool name_only);
> +void print_sdt_events(const char *subsys_glob, const char *event_glob,
> + bool name_only);
> int is_valid_tracepoint(const char *event_string);
>
> int valid_event_mount(const char *eventfs);
> diff --git a/tools/perf/util/probe-file.h b/tools/perf/util/probe-file.h
> index 93aa193..ce98162 100644
> --- a/tools/perf/util/probe-file.h
> +++ b/tools/perf/util/probe-file.h
> @@ -22,6 +22,8 @@ struct probe_cache {
> #define PF_FL_UPROBE 1
> #define PF_FL_RW 2
>
> +/* probe-file.c depends on libelf */
> +#ifdef HAVE_LIBELF_SUPPORT
> int probe_file__open(int flag);
> int probe_file__open_both(int *kfd, int *ufd, int flag);
> struct strlist *probe_file__get_namelist(int fd);
> @@ -46,4 +48,11 @@ struct probe_cache_entry *probe_cache__find(struct probe_cache *pcache,
> struct probe_cache_entry *probe_cache__find_by_name(struct probe_cache *pcache,
> const char *group, const char *event);
> int probe_cache__show_all_caches(struct strfilter *filter);
> +#else /* ! HAVE_LIBELF_SUPPORT */
> +static inline struct probe_cache *probe_cache__new(const char *tgt __maybe_unused)
> +{
> + return NULL;
> +}
> +#define probe_cache__delete(pcache) do {} while(0)
> +#endif
> #endif
>
--
Thanks,
Hemant Kumar
next prev parent reply other threads:[~2016-04-27 20:48 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 18:37 [PATCH perf/core v5 00/15] perf-probe --cache and SDT support Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 01/15] perf probe: Use strbuf for making strings Masami Hiramatsu
2016-05-01 7:38 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 02/15] perf-buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid Masami Hiramatsu
2016-04-27 21:12 ` Arnaldo Carvalho de Melo
2016-04-28 1:52 ` Masami Hiramatsu
2016-04-27 21:23 ` Arnaldo Carvalho de Melo
2016-04-28 1:51 ` Masami Hiramatsu
2016-04-28 1:22 ` Namhyung Kim
2016-04-28 22:50 ` Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 03/15] perf-buildid-cache: Use lsdir for looking up buildid caches Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 04/15] perf probe: Add --cache option to cache the probe definitions Masami Hiramatsu
2016-04-28 2:12 ` Namhyung Kim
2016-04-28 23:14 ` Masami Hiramatsu
2016-04-28 2:32 ` Namhyung Kim
2016-04-28 23:06 ` Masami Hiramatsu
2016-04-27 18:37 ` [PATCH perf/core v5 05/15] perf probe: Use cache entry if possible Masami Hiramatsu
2016-04-28 2:47 ` Namhyung Kim
2016-04-28 23:52 ` Masami Hiramatsu
2016-04-29 11:33 ` Namhyung Kim
2016-04-27 18:38 ` [PATCH perf/core v5 06/15] perf probe: Show all cached probes Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 07/15] perf probe: Remove caches when --cache is given Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 08/15] perf/sdt: ELF support for SDT Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 09/15] perf probe: Add group name support Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 10/15] perf buildid-cache: Scan and import user SDT events to probe cache Masami Hiramatsu
2016-04-27 20:32 ` Hemant Kumar
2016-04-27 18:38 ` [PATCH perf/core v5 11/15] perf probe: Accept %sdt and %cached event name Masami Hiramatsu
2016-04-27 20:50 ` Hemant Kumar
2016-04-28 5:26 ` Namhyung Kim
2016-04-29 0:13 ` Masami Hiramatsu
2016-04-27 18:38 ` [PATCH perf/core v5 12/15] perf-list: Show SDT and pre-cached events Masami Hiramatsu
2016-04-27 20:46 ` Hemant Kumar [this message]
2016-04-27 18:39 ` [PATCH perf/core v5 13/15] perf-list: Skip SDTs placed in invalid binaries Masami Hiramatsu
2016-04-27 18:39 ` [PATCH perf/core v5 14/15] perf probe: Allow wildcard for cached events Masami Hiramatsu
2016-04-27 18:42 ` Masami Hiramatsu
2016-04-27 19:15 ` [PATCH perf/core v5.1 " Masami Hiramatsu
2016-04-27 20:36 ` Hemant Kumar
2016-04-27 18:39 ` [PATCH perf/core v5 15/15] perf probe: Support @BUILDID or @FILE suffix for SDT events Masami Hiramatsu
2016-04-29 13:53 ` [PATCH perf/core v5 00/15] perf-probe --cache and SDT support Hemant Kumar
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=57212542.5000106@linux.vnet.ibm.com \
--to=hemant@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=ananth@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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
Powered by JetHome