Changeset View
Changeset View
Standalone View
Standalone View
lib/libpmc/libpmc_pmu_util.c
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | else | |||||||||
return (name); | return (name); | |||||||||
for (pa = pmu_alias_table; pa->pa_alias != NULL; pa++) | for (pa = pmu_alias_table; pa->pa_alias != NULL; pa++) | |||||||||
if (strcasecmp(name, pa->pa_alias) == 0) | if (strcasecmp(name, pa->pa_alias) == 0) | |||||||||
return (pa->pa_name); | return (pa->pa_name); | |||||||||
return (name); | return (name); | |||||||||
} | } | |||||||||
#elif defined(__powerpc64__) | ||||||||||
static const char * | ||||||||||
pmu_alias_get(const char *name) | ||||||||||
{ | ||||||||||
return (name); | ||||||||||
} | ||||||||||
mhorne: It seems that this function could be eliminated altogether, since there is no distinction in… | ||||||||||
#elif defined(__aarch64__) | #elif defined(__aarch64__) | |||||||||
static struct pmu_alias pmu_armv8_alias_table[] = { | static struct pmu_alias pmu_armv8_alias_table[] = { | |||||||||
{NULL, NULL}, | {NULL, NULL}, | |||||||||
}; | }; | |||||||||
static const char * | static const char * | |||||||||
pmu_alias_get(const char *name) | pmu_alias_get(const char *name) | |||||||||
▲ Show 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | if (pe->event == NULL) | |||||||||
return (ENOENT); | return (ENOENT); | |||||||||
if (pmu_parse_event(&ped, pe->event)) | if (pmu_parse_event(&ped, pe->event)) | |||||||||
return (ENOENT); | return (ENOENT); | |||||||||
if (mfr == PMU_INTEL) | if (mfr == PMU_INTEL) | |||||||||
return (pmc_pmu_intel_pmcallocate(event_name, pm, &ped)); | return (pmc_pmu_intel_pmcallocate(event_name, pm, &ped)); | |||||||||
else | else | |||||||||
return (pmc_pmu_amd_pmcallocate(event_name, pm, &ped)); | return (pmc_pmu_amd_pmcallocate(event_name, pm, &ped)); | |||||||||
} | ||||||||||
#elif defined(__powerpc64__) | ||||||||||
int | ||||||||||
pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) | ||||||||||
{ | ||||||||||
const struct pmu_event *pe; | ||||||||||
struct pmu_event_desc ped; | ||||||||||
int idx = -1; | ||||||||||
bzero(&pm->pm_md, sizeof(pm->pm_md)); | ||||||||||
pm->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); | ||||||||||
event_name = pmu_alias_get(event_name); | ||||||||||
if ((pe = pmu_event_get(NULL, event_name, &idx)) == NULL) | ||||||||||
return (ENOENT); | ||||||||||
if (pe->event == NULL) | ||||||||||
return (ENOENT); | ||||||||||
if (pmu_parse_event(&ped, pe->event)) | ||||||||||
return (ENOENT); | ||||||||||
assert(ped.ped_event >= 0); | ||||||||||
pm->pm_ev = idx; | ||||||||||
Done Inline Actions
It seems pm_ev needs to point to idx for libpmc to map correctly between names and events. This field should be added to sys/powerpc/include/pmc_mdep.h, like: union pmc_md_op_pmcallocate { - uint64_t __pad[4]; + uint32_t pm_event; + uint32_t __pad1; + uint64_t __pad2[3]; }; luporl: It seems pm_ev needs to point to idx for libpmc to map correctly between names and events.
The… | ||||||||||
Done Inline ActionsThanks for narrowing this down, the use of idx vs ped.ped_event is not obvious at all in the amd64 code, and if you look you'll see that my arm64 version is accidentally incomplete :) I agree with the analysis. mhorne: Thanks for narrowing this down, the use of `idx` vs `ped.ped_event` is not obvious at all in… | ||||||||||
Done Inline ActionsOne mistake I've just noted in D31221: pmc_md_op_pmcallocate is a union, not a struct. Therefore the padding shouldn't be touched. mhorne: One mistake I've just noted in D31221: `pmc_md_op_pmcallocate` is a `union`, not a `struct`. | ||||||||||
Done Inline ActionsOh, that's true, I didn't realize it was a union, thanks for pointing it out. luporl: Oh, that's true, I didn't realize it was a union, thanks for pointing it out. | ||||||||||
pm->pm_md.pm_event = ped.ped_event; | ||||||||||
pm->pm_class = PMC_CLASS_POWER8; | ||||||||||
return (0); | ||||||||||
} | } | |||||||||
#elif defined(__aarch64__) | #elif defined(__aarch64__) | |||||||||
int | int | |||||||||
pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) | pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) | |||||||||
{ | { | |||||||||
const struct pmu_event *pe; | const struct pmu_event *pe; | |||||||||
Show All 29 Lines |
It seems that this function could be eliminated altogether, since there is no distinction in behaviour between power8 and power9.
To elaborate, the presence of a pmc_cpuid value matching the regex in pmu-events/arch/powerpc/mapfile.csv is enough to detect whether a CPU is supported or not. This is checked in pmu_events_map_get().