From owner-svn-src-head@freebsd.org Tue May 29 04:23:17 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 6E38FF9BACD; Tue, 29 May 2018 04:23:17 +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 21A0D75979; Tue, 29 May 2018 04:23:17 +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 043C9171F7; Tue, 29 May 2018 04:23:17 +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 w4T4NGLu059018; Tue, 29 May 2018 04:23:16 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4T4NGLw059016; Tue, 29 May 2018 04:23:16 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201805290423.w4T4NGLw059016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Tue, 29 May 2018 04:23:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334312 - head/lib/libpmc X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: head/lib/libpmc X-SVN-Commit-Revision: 334312 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: Tue, 29 May 2018 04:23:17 -0000 Author: mmacy Date: Tue May 29 04:23:16 2018 New Revision: 334312 URL: https://svnweb.freebsd.org/changeset/base/334312 Log: libpmc: export names of counters for stat mode, make get_by_idx name consistent with others Modified: head/lib/libpmc/libpmc_pmu_util.c (contents, props changed) head/lib/libpmc/pmc.h head/lib/libpmc/pmclog.c Modified: head/lib/libpmc/libpmc_pmu_util.c ============================================================================== --- head/lib/libpmc/libpmc_pmu_util.c Tue May 29 04:04:06 2018 (r334311) +++ head/lib/libpmc/libpmc_pmu_util.c Tue May 29 04:23:16 2018 (r334312) @@ -131,7 +131,7 @@ pmu_event_get(const char *event_name, int *idx) } const char * -pmu_event_get_by_idx(int idx) +pmc_pmu_event_get_by_idx(int idx) { const struct pmu_events_map *pme; const struct pmu_event *pe; @@ -321,6 +321,27 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc return (0); } +/* + * Ultimately rely on AMD calling theirs the same + */ +static const char *stat_mode_cntrs[] = { + "inst_retired.any", + "cpu_clk_unhalted.thread_p_any", + "br_inst_retired.all_branches", + "br_misp_retired.all_branches", + "cpu_clk_unhalted.thread_p_any" +}; + +int +pmc_pmu_stat_mode(const char ***cntrs) +{ + if (pmc_pmu_enabled()) { + *cntrs = stat_mode_cntrs; + return (0); + } + return (EOPNOTSUPP); +} + #else uint64_t pmc_pmu_sample_rate_get(const char *event_name __unused) { return (DEFAULT_SAMPLE_COUNT); } void pmc_pmu_print_counters(void) {} @@ -328,6 +349,7 @@ void pmc_pmu_print_counter_desc(const char *e __unused void pmc_pmu_print_counter_desc_long(const char *e __unused) {} int pmc_pmu_enabled(void) { return (0); } int pmc_pmu_pmcallocate(const char *e __unused, struct pmc_op_pmcallocate *p __unused) { return (EOPNOTSUPP); } -const char *pmu_event_get_by_idx(int idx __unused) { return (NULL); } +const char *pmc_pmu_event_get_by_idx(int idx __unused) { return (NULL); } +int pmc_pmu_stat_mode(const char ***a __unused) { return (EOPNOTSUPP); } #endif Modified: head/lib/libpmc/pmc.h ============================================================================== --- head/lib/libpmc/pmc.h Tue May 29 04:04:06 2018 (r334311) +++ head/lib/libpmc/pmc.h Tue May 29 04:23:16 2018 (r334312) @@ -119,7 +119,8 @@ void pmc_pmu_print_counter_desc(const char *); void pmc_pmu_print_counter_desc_long(const char *); uint64_t pmc_pmu_sample_rate_get(const char *); int pmc_pmu_pmcallocate(const char *, struct pmc_op_pmcallocate *); -const char *pmu_event_get_by_idx(int idx); +const char *pmc_pmu_event_get_by_idx(int idx); +int pmc_pmu_stat_mode(const char ***); __END_DECLS #endif Modified: head/lib/libpmc/pmclog.c ============================================================================== --- head/lib/libpmc/pmclog.c Tue May 29 04:04:06 2018 (r334311) +++ head/lib/libpmc/pmclog.c Tue May 29 04:23:16 2018 (r334312) @@ -368,7 +368,7 @@ pmclog_get_event(void *cookie, char **data, ssize_t *l PMCLOG_READ32(le,ev->pl_u.pl_a.pl_event); PMCLOG_READ32(le,ev->pl_u.pl_a.pl_flags); PMCLOG_READ32(le,noop); - ev->pl_u.pl_a.pl_evname = pmu_event_get_by_idx(ev->pl_u.pl_a.pl_event); + ev->pl_u.pl_a.pl_evname = pmc_pmu_event_get_by_idx(ev->pl_u.pl_a.pl_event); if (ev->pl_u.pl_a.pl_evname != NULL) break; else if ((ev->pl_u.pl_a.pl_evname =