From owner-svn-src-head@freebsd.org Fri Jun 1 00:45:56 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6F48EF33EE; Fri, 1 Jun 2018 00:45:55 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DF0446A650; Fri, 1 Jun 2018 00:45:54 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C1C0521AAA; Fri, 1 Jun 2018 00:45:54 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w510jssW036406; Fri, 1 Jun 2018 00:45:54 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w510jsgX036403; Fri, 1 Jun 2018 00:45:54 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201806010045.w510jsgX036403@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Fri, 1 Jun 2018 00:45:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334464 - in head: lib/libpmc usr.sbin/pmcstat X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: in head: lib/libpmc usr.sbin/pmcstat X-SVN-Commit-Revision: 334464 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2018 00:45:56 -0000 Author: mmacy Date: Fri Jun 1 00:45:53 2018 New Revision: 334464 URL: https://svnweb.freebsd.org/changeset/base/334464 Log: libpmc: allow substring for list and add function for printing event details Modified: head/lib/libpmc/libpmc_pmu_util.c (contents, props changed) head/lib/libpmc/pmc.h head/usr.sbin/pmcstat/pmcstat.c Modified: head/lib/libpmc/libpmc_pmu_util.c ============================================================================== --- head/lib/libpmc/libpmc_pmu_util.c Fri Jun 1 00:45:48 2018 (r334463) +++ head/lib/libpmc/libpmc_pmu_util.c Fri Jun 1 00:45:53 2018 (r334464) @@ -235,7 +235,7 @@ pmc_pmu_enabled(void) } void -pmc_pmu_print_counters(void) +pmc_pmu_print_counters(const char *event_name) { const struct pmu_events_map *pme; const struct pmu_event *pe; @@ -253,6 +253,8 @@ pmc_pmu_print_counters(void) for (pe = pme->table; pe->name || pe->desc || pe->event; pe++) { if (pe->name == NULL) continue; + if (event_name != NULL && strcasestr(pe->name, event_name) == NULL) + continue; printf("\t%s\n", pe->name); if (do_debug) pmu_parse_event(&ped, pe->event); @@ -296,6 +298,43 @@ pmc_pmu_print_counter_desc_long(const char *ev) } } +void +pmc_pmu_print_counter_full(const char *ev) +{ + const struct pmu_events_map *pme; + const struct pmu_event *pe; + + if ((pme = pmu_events_map_get()) == NULL) + return; + for (pe = pme->table; pe->name || pe->desc || pe->event; pe++) { + if (pe->name == NULL) + continue; + if (strcasestr(pe->name, ev) == NULL) + continue; + printf("name: %s\n", pe->name); + if (pe->long_desc != NULL) + printf("desc: %s\n", pe->long_desc); + else if (pe->desc != NULL) + printf("desc: %s\n", pe->desc); + if (pe->event != NULL) + printf("event: %s\n", pe->event); + if (pe->topic != NULL) + printf("topic: %s\n", pe->topic); + if (pe->pmu != NULL) + printf("pmu: %s\n", pe->pmu); + if (pe->unit != NULL) + printf("unit: %s\n", pe->unit); + if (pe->perpkg != NULL) + printf("perpkg: %s\n", pe->perpkg); + if (pe->metric_expr != NULL) + printf("metric_expr: %s\n", pe->metric_expr); + if (pe->metric_name != NULL) + printf("metric_name: %s\n", pe->metric_name); + if (pe->metric_group != NULL) + printf("metric_group: %s\n", pe->metric_group); + } +} + int pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) { @@ -394,7 +433,7 @@ pmc_pmu_sample_rate_get(const char *event_name __unuse } void -pmc_pmu_print_counters(void) +pmc_pmu_print_counters(const char *event_name __unused) { } @@ -406,6 +445,12 @@ pmc_pmu_print_counter_desc(const char *e __unused) void pmc_pmu_print_counter_desc_long(const char *e __unused) { +} + +void +pmc_pmu_print_counter_full(const char *e __unused) +{ + } int Modified: head/lib/libpmc/pmc.h ============================================================================== --- head/lib/libpmc/pmc.h Fri Jun 1 00:45:48 2018 (r334463) +++ head/lib/libpmc/pmc.h Fri Jun 1 00:45:53 2018 (r334464) @@ -114,9 +114,10 @@ int pmc_event_names_of_class(enum pmc_class _cl, const int *_nevents); int pmc_pmu_enabled(void); -void pmc_pmu_print_counters(void); +void pmc_pmu_print_counters(const char *); void pmc_pmu_print_counter_desc(const char *); void pmc_pmu_print_counter_desc_long(const char *); +void pmc_pmu_print_counter_full(const char *); uint64_t pmc_pmu_sample_rate_get(const char *); int pmc_pmu_pmcallocate(const char *, struct pmc_op_pmcallocate *); const char *pmc_pmu_event_get_by_idx(int idx); Modified: head/usr.sbin/pmcstat/pmcstat.c ============================================================================== --- head/usr.sbin/pmcstat/pmcstat.c Fri Jun 1 00:45:48 2018 (r334463) +++ head/usr.sbin/pmcstat/pmcstat.c Fri Jun 1 00:45:53 2018 (r334464) @@ -820,7 +820,7 @@ main(int argc, char **argv) pmc_pmu_enabled() == 0) errx(EX_USAGE, "pmu features not supported on host or hwpmc not loaded"); if (do_listcounters) { - pmc_pmu_print_counters(); + pmc_pmu_print_counters(NULL); } else if (do_descr) { pmc_pmu_print_counter_desc(event); } else if (do_long_descr) {