Date: Mon, 31 May 2021 20:39:19 GMT From: Mitchell Horne <mhorne@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ec66cc955b62 - main - libpmc: eliminate pmc_pmu_stat_mode() Message-ID: <202105312039.14VKdJL3040637@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=ec66cc955b629e614cf493bf168048de033f6a2c commit ec66cc955b629e614cf493bf168048de033f6a2c Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2021-05-31 14:21:57 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2021-05-31 20:39:05 +0000 libpmc: eliminate pmc_pmu_stat_mode() There is a single consumer, the pmc utility, that clearly has knowledge of which counters it is expecting. Remove this function and have it use common counter aliases instead. Reviewed by: gnn MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30528 --- lib/libpmc/libpmc_pmu_util.c | 22 ---------------------- lib/libpmc/pmc.h | 1 - usr.sbin/pmc/cmd_pmc_stat.c | 15 +++++++++++---- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c index 1b2c10e07368..a525a0067822 100644 --- a/lib/libpmc/libpmc_pmu_util.c +++ b/lib/libpmc/libpmc_pmu_util.c @@ -542,28 +542,6 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) return (pmc_pmu_amd_pmcallocate(event_name, pm, &ped)); } -/* - * Ultimately rely on AMD calling theirs the same - */ -static const char *stat_mode_cntrs[] = { - "cpu_clk_unhalted.thread", - "inst_retired.any", - "br_inst_retired.all_branches", - "br_misp_retired.all_branches", - "longest_lat_cache.reference", - "longest_lat_cache.miss", -}; - -int -pmc_pmu_stat_mode(const char ***cntrs) -{ - if (pmc_pmu_enabled()) { - *cntrs = stat_mode_cntrs; - return (0); - } - return (EOPNOTSUPP); -} - #else uint64_t diff --git a/lib/libpmc/pmc.h b/lib/libpmc/pmc.h index 9d12085364e5..7579f93a42b1 100644 --- a/lib/libpmc/pmc.h +++ b/lib/libpmc/pmc.h @@ -122,7 +122,6 @@ 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(const char *, int idx); int pmc_pmu_idx_get_by_event(const char*, const char *); -int pmc_pmu_stat_mode(const char ***); __END_DECLS #endif diff --git a/usr.sbin/pmc/cmd_pmc_stat.c b/usr.sbin/pmc/cmd_pmc_stat.c index 44ca7b92dea7..55d1f1ca7a3b 100644 --- a/usr.sbin/pmc/cmd_pmc_stat.c +++ b/usr.sbin/pmc/cmd_pmc_stat.c @@ -104,6 +104,16 @@ static const char *pmc_stat_mode_names[] = { "cache-misses", }; +/* Common aliases for the desired stat counter */ +static const char *pmc_stat_mode_aliases[] = { + "unhalted-cycles", + "instructions", + "branches", + "branch-mispredicts", + "LLC-REFERENCE", + "LLC-MISSES", +}; + static int pmcstat_sockpair[NSOCKPAIRFD]; static void __dead2 @@ -153,7 +163,6 @@ static void pmc_stat_setup_stat(int system_mode, const char *arg) { const char *new_cntrs[STAT_MODE_NPMCS]; - static const char **pmc_stat_mode_cntrs; struct pmcstat_ev *ev; char *counters, *counter; int i, c, start, newcnt; @@ -164,13 +173,11 @@ pmc_stat_setup_stat(int system_mode, const char *arg) err(EX_OSERR, "ERROR: Cannot determine the root set of CPUs"); CPU_COPY(&rootmask, &cpumask); - if (pmc_pmu_stat_mode(&pmc_stat_mode_cntrs) != 0) - errx(EX_USAGE, "ERROR: hwmpc.ko not loaded or stat not supported on host."); if (system_mode && geteuid() != 0) errx(EX_USAGE, "ERROR: system mode counters can only be used as root"); counters = NULL; for (i = 0; i < STAT_MODE_NPMCS; i++) { - stat_mode_cntrs[i] = pmc_stat_mode_cntrs[i]; + stat_mode_cntrs[i] = pmc_stat_mode_aliases[i]; stat_mode_names[i] = pmc_stat_mode_names[i]; } if (arg) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105312039.14VKdJL3040637>