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
This commit is contained in:
parent
167cdaa7e3
commit
ec66cc955b
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user