Changeset View
Changeset View
Standalone View
Standalone View
lib/libpmc/libpmc_pmu_util.c
Show All 37 Lines | |||||
#include <regex.h> | #include <regex.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <pmc.h> | #include <pmc.h> | ||||
#include <pmclog.h> | #include <pmclog.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <libpmcstat.h> | #include <libpmcstat.h> | ||||
#include "pmu-events/pmu-events.h" | #include "pmu-events/pmu-events.h" | ||||
#if defined(__amd64__) || defined(__i386__) | |||||
struct pmu_alias { | struct pmu_alias { | ||||
const char *pa_alias; | const char *pa_alias; | ||||
const char *pa_name; | const char *pa_name; | ||||
}; | }; | ||||
#if defined(__amd64__) || defined(__i386__) | |||||
typedef enum { | typedef enum { | ||||
PMU_INVALID, | PMU_INVALID, | ||||
PMU_INTEL, | PMU_INTEL, | ||||
PMU_AMD, | PMU_AMD, | ||||
} pmu_mfr_t; | } pmu_mfr_t; | ||||
static struct pmu_alias pmu_intel_alias_table[] = { | static struct pmu_alias pmu_intel_alias_table[] = { | ||||
{"UNHALTED_CORE_CYCLES", "CPU_CLK_UNHALTED.THREAD_P_ANY"}, | {"UNHALTED_CORE_CYCLES", "CPU_CLK_UNHALTED.THREAD_P_ANY"}, | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | pmu_alias_get(const char *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); | ||||
} | } | ||||
#else | |||||
static const char * | |||||
pmu_alias_get(const char *name) | |||||
{ | |||||
return (name); | |||||
} | |||||
#endif | |||||
struct pmu_event_desc { | struct pmu_event_desc { | ||||
uint64_t ped_period; | uint64_t ped_period; | ||||
uint64_t ped_offcore_rsp; | uint64_t ped_offcore_rsp; | ||||
uint64_t ped_l3_thread; | uint64_t ped_l3_thread; | ||||
uint64_t ped_l3_slice; | uint64_t ped_l3_slice; | ||||
uint32_t ped_event; | uint32_t ped_event; | ||||
uint32_t ped_frontend; | uint32_t ped_frontend; | ||||
uint32_t ped_ldlat; | uint32_t ped_ldlat; | ||||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | if (pe->metric_expr != NULL) | ||||
printf("metric_expr: %s\n", pe->metric_expr); | printf("metric_expr: %s\n", pe->metric_expr); | ||||
if (pe->metric_name != NULL) | if (pe->metric_name != NULL) | ||||
printf("metric_name: %s\n", pe->metric_name); | printf("metric_name: %s\n", pe->metric_name); | ||||
if (pe->metric_group != NULL) | if (pe->metric_group != NULL) | ||||
printf("metric_group: %s\n", pe->metric_group); | printf("metric_group: %s\n", pe->metric_group); | ||||
} | } | ||||
} | } | ||||
#if defined(__amd64__) || defined(__i386__) | |||||
static int | static int | ||||
pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm, | pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm, | ||||
struct pmu_event_desc *ped) | struct pmu_event_desc *ped) | ||||
{ | { | ||||
struct pmc_md_amd_op_pmcallocate *amd; | struct pmc_md_amd_op_pmcallocate *amd; | ||||
const struct pmu_event *pe; | const struct pmu_event *pe; | ||||
int idx = -1; | int idx = -1; | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) | ||||
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)); | ||||
} | } | ||||
#else | #else | ||||
uint64_t | |||||
pmc_pmu_sample_rate_get(const char *event_name __unused) | |||||
{ | |||||
return (DEFAULT_SAMPLE_COUNT); | |||||
} | |||||
void | |||||
pmc_pmu_print_counters(const char *event_name __unused) | |||||
{ | |||||
} | |||||
void | |||||
pmc_pmu_print_counter_desc(const char *e __unused) | |||||
{ | |||||
} | |||||
void | |||||
pmc_pmu_print_counter_desc_long(const char *e __unused) | |||||
{ | |||||
} | |||||
void | |||||
pmc_pmu_print_counter_full(const char *e __unused) | |||||
{ | |||||
} | |||||
int | int | ||||
pmc_pmu_enabled(void) | |||||
{ | |||||
return (0); | |||||
} | |||||
int | |||||
pmc_pmu_pmcallocate(const char *e __unused, struct pmc_op_pmcallocate *p __unused) | pmc_pmu_pmcallocate(const char *e __unused, struct pmc_op_pmcallocate *p __unused) | ||||
{ | { | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
const char * | |||||
pmc_pmu_event_get_by_idx(const char *c __unused, int idx __unused) | |||||
{ | |||||
return (NULL); | |||||
} | |||||
int | |||||
pmc_pmu_stat_mode(const char ***a __unused) | |||||
{ | |||||
return (EOPNOTSUPP); | |||||
} | |||||
int | |||||
pmc_pmu_idx_get_by_event(const char *c __unused, const char *e __unused) | |||||
{ | |||||
return (-1); | |||||
} | |||||
#endif | #endif |