From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755596AbcETDj5 (ORCPT ); Thu, 19 May 2016 23:39:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58080 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752598AbcETDjz (ORCPT ); Thu, 19 May 2016 23:39:55 -0400 X-Greylist: delayed 3061 seconds by postgrey-1.27 at vger.kernel.org; Thu, 19 May 2016 23:39:55 EDT Message-Id: <201605200248.u4K2i3Ho006543@mx0a-001b2d01.pphosted.com> X-IBM-Helo: d28dlp03.in.ibm.com X-IBM-MailFrom: hemant@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Fri, 20 May 2016 08:18:45 +0530 From: Hemant Kumar User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Masami Hiramatsu , Arnaldo Carvalho de Melo CC: linux-kernel@vger.kernel.org, Namhyung Kim , Peter Zijlstra , Ingo Molnar , Ananth N Mavinakayanahalli , Brendan Gregg Subject: Re: [PATCH perf/core v8 12/16] perf-list: Show SDT and pre-cached events References: <20160515031922.4017.13932.stgit@devbox> <20160515032139.4017.86190.stgit@devbox> In-Reply-To: <20160515032139.4017.86190.stgit@devbox> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052002-0012-0000-0000-0000027C6D2A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16052002-0013-0000-0000-00000CB118FD X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-05-19_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_policy_notspam policy=outbound_spam_policy score=0 spamscore=0 suspectscore=25 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1605200033 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/15/2016 08:51 AM, Masami Hiramatsu wrote: > From: Masami Hiramatsu > > 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; > > :@() > > Signed-off-by: Masami Hiramatsu > Signed-off-by: Masami Hiramatsu > --- > 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); We will also need to add "sdt" to list_usage[] variable in this function : const char * const list_usage[] = { "perf list [hw|sw|cache|tracepoint|pmu|sdt|event_glob]", NULL }; > 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