Date: Fri, 1 Jun 2018 00:45:54 +0000 (UTC) From: Matt Macy <mmacy@FreeBSD.org> 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 Message-ID: <201806010045.w510jsgX036403@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806010045.w510jsgX036403>