Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pmc/cmd_pmc_stat.c
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | static const char *pmc_stat_mode_names[] = { | ||||
"cycles", | "cycles", | ||||
"instructions", | "instructions", | ||||
"branches", | "branches", | ||||
"branch-misses", | "branch-misses", | ||||
"cache-references", | "cache-references", | ||||
"cache-misses", | "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", | |||||
mhorne: Since it is not obvious from the diff, these aliases refer to the same counters as the names… | |||||
}; | |||||
static int pmcstat_sockpair[NSOCKPAIRFD]; | static int pmcstat_sockpair[NSOCKPAIRFD]; | ||||
static void __dead2 | static void __dead2 | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
errx(EX_USAGE, | errx(EX_USAGE, | ||||
"\t get basic stats from command line program\n" | "\t get basic stats from command line program\n" | ||||
"\t -j <eventlist>, --events <eventlist> comma-delimited list of event specifiers\n" | "\t -j <eventlist>, --events <eventlist> comma-delimited list of event specifiers\n" | ||||
Show All 33 Lines | |||||
static const char *stat_mode_cntrs[STAT_MODE_NPMCS]; | static const char *stat_mode_cntrs[STAT_MODE_NPMCS]; | ||||
static const char *stat_mode_names[STAT_MODE_NPMCS]; | static const char *stat_mode_names[STAT_MODE_NPMCS]; | ||||
static void | static void | ||||
pmc_stat_setup_stat(int system_mode, const char *arg) | pmc_stat_setup_stat(int system_mode, const char *arg) | ||||
{ | { | ||||
const char *new_cntrs[STAT_MODE_NPMCS]; | const char *new_cntrs[STAT_MODE_NPMCS]; | ||||
static const char **pmc_stat_mode_cntrs; | |||||
struct pmcstat_ev *ev; | struct pmcstat_ev *ev; | ||||
char *counters, *counter; | char *counters, *counter; | ||||
int i, c, start, newcnt; | int i, c, start, newcnt; | ||||
cpuset_t cpumask, rootmask; | cpuset_t cpumask, rootmask; | ||||
if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1, | if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1, | ||||
sizeof(rootmask), &rootmask) == -1) | sizeof(rootmask), &rootmask) == -1) | ||||
err(EX_OSERR, "ERROR: Cannot determine the root set of CPUs"); | err(EX_OSERR, "ERROR: Cannot determine the root set of CPUs"); | ||||
CPU_COPY(&rootmask, &cpumask); | 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) | if (system_mode && geteuid() != 0) | ||||
errx(EX_USAGE, "ERROR: system mode counters can only be used as root"); | errx(EX_USAGE, "ERROR: system mode counters can only be used as root"); | ||||
counters = NULL; | counters = NULL; | ||||
for (i = 0; i < STAT_MODE_NPMCS; i++) { | 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]; | stat_mode_names[i] = pmc_stat_mode_names[i]; | ||||
} | } | ||||
if (arg) { | if (arg) { | ||||
counters = strdup(arg); | counters = strdup(arg); | ||||
newcnt = 0; | newcnt = 0; | ||||
while ((counter = strsep(&counters, ",")) != NULL && | while ((counter = strsep(&counters, ",")) != NULL && | ||||
newcnt < STAT_MODE_NPMCS - IAP_START) { | newcnt < STAT_MODE_NPMCS - IAP_START) { | ||||
new_cntrs[newcnt++] = counter; | new_cntrs[newcnt++] = counter; | ||||
▲ Show 20 Lines • Show All 308 Lines • Show Last 20 Lines |
Since it is not obvious from the diff, these aliases refer to the same counters as the names being removed above (on intel at least). Therefore, later calls to pmc_allocate() in this file will behave the same.