libpmcstat: import aliases table and bug fixes
This commit is contained in:
parent
4bd2a4b58e
commit
f2597cf756
@ -42,6 +42,39 @@
|
||||
#include "pmu-events/pmu-events.h"
|
||||
|
||||
#if defined(__amd64__)
|
||||
struct pmu_alias {
|
||||
const char *pa_alias;
|
||||
const char *pa_name;
|
||||
};
|
||||
static struct pmu_alias pmu_alias_table[] = {
|
||||
{ "UNHALTED_CORE_CYCLES", "CPU_CLK_UNHALTED.THREAD_P_ANY"},
|
||||
{ "UNHALTED-CORE-CYCLES", "CPU_CLK_UNHALTED.THREAD_P_ANY"},
|
||||
{ "LLC_MISSES", "LONGEST_LAT_CACHE.MISS"},
|
||||
{ "LLC-MISSES", "LONGEST_LAT_CACHE.MISS"},
|
||||
{ "LLC_REFERENCE", "LONGEST_LAT_CACHE.REFERENCE"},
|
||||
{ "LLC-REFERENCE", "LONGEST_LAT_CACHE.REFERENCE"},
|
||||
{ "LLC_MISS_RHITM", "mem_load_l3_miss_retired.remote_hitm"},
|
||||
{ "LLC-MISS-RHITM", "mem_load_l3_miss_retired.remote_hitm"},
|
||||
{ "RESOURCE_STALL", "RESOURCE_STALLS.ANY"},
|
||||
{ "RESOURCE_STALLS_ANY", "RESOURCE_STALLS.ANY"},
|
||||
{ "BRANCH_INSTRUCTION_RETIRED", "BR_INST_RETIRED.ALL_BRANCHES"},
|
||||
{ "BRANCH-INSTRUCTION-RETIRED", "BR_INST_RETIRED.ALL_BRANCHES"},
|
||||
{ "BRANCH_MISSES_RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"},
|
||||
{ "BRANCH-MISSES-RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"},
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
static const char *
|
||||
pmu_alias_get(const char *name)
|
||||
{
|
||||
struct pmu_alias *pa;
|
||||
|
||||
for (pa = pmu_alias_table; pa->pa_alias != NULL; pa++)
|
||||
if (strcasecmp(name, pa->pa_alias) == 0)
|
||||
return (pa->pa_name);
|
||||
return (name);
|
||||
}
|
||||
|
||||
struct pmu_event_desc {
|
||||
uint32_t ped_umask;
|
||||
uint32_t ped_event;
|
||||
@ -75,9 +108,12 @@ pmu_event_get(const char *event_name)
|
||||
|
||||
if ((pme = pmu_events_map_get()) == NULL)
|
||||
return (NULL);
|
||||
for (pe = pme->table; pe->name != NULL; pe++)
|
||||
if (strcmp(pe->name, event_name) == 0)
|
||||
for (pe = pme->table; pe->name || pe->desc || pe->event; pe++) {
|
||||
if (pe->name == NULL)
|
||||
continue;
|
||||
if (strcasecmp(pe->name, event_name) == 0)
|
||||
return (pe);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -100,7 +136,7 @@ pmu_parse_event(struct pmu_event_desc *ped, const char *eventin)
|
||||
if (strcmp(key, "event") == 0)
|
||||
ped->ped_event = strtol(value, NULL, 16);
|
||||
if (strcmp(key, "period") == 0)
|
||||
ped->ped_umask = strtol(value, NULL, 10);
|
||||
ped->ped_period = strtol(value, NULL, 10);
|
||||
}
|
||||
free(event);
|
||||
return (0);
|
||||
@ -112,6 +148,7 @@ pmcstat_pmu_sample_rate_get(const char *event_name)
|
||||
const struct pmu_event *pe;
|
||||
struct pmu_event_desc ped;
|
||||
|
||||
event_name = pmu_alias_get(event_name);
|
||||
if ((pe = pmu_event_get(event_name)) == NULL)
|
||||
return (DEFAULT_SAMPLE_COUNT);
|
||||
if (pe->alias && (pe = pmu_event_get(pe->alias)) == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user