aboutsummaryrefslogtreecommitdiff
path: root/lib/libpmc/libpmc_pmu_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpmc/libpmc_pmu_util.c')
-rw-r--r--lib/libpmc/libpmc_pmu_util.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c
index 7af6d813ada6..fa2e76e8d026 100644
--- a/lib/libpmc/libpmc_pmu_util.c
+++ b/lib/libpmc/libpmc_pmu_util.c
@@ -1,5 +1,5 @@
/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018, Matthew Macy
* Copyright (c) 2021, The FreeBSD Foundation
@@ -28,8 +28,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
- *
*/
#include <sys/types.h>
@@ -165,6 +163,21 @@ pmu_alias_get(const char *name)
#elif defined(__aarch64__)
static struct pmu_alias pmu_armv8_alias_table[] = {
+ {"UNHALTED_CORE_CYCLES", "CPU_CYCLES"},
+ {"UNHALTED-CORE-CYCLES", "CPU_CYCLES"},
+ {"LLC_MISSES", "LL_CACHE_MISS_RD"},
+ {"LLC-MISSES", "LL_CACHE_MISS_RD"},
+ {"LLC_REFERENCE", "LL_CACHE_RD"},
+ {"LLC-REFERENCE", "LL_CACHE_RD"},
+ {"BRANCH_INSTRUCTION_RETIRED", "BR_RETIRED"},
+ {"BRANCH-INSTRUCTION-RETIRED", "BR_RETIRED"},
+ {"BRANCH_MISSES_RETIRED", "BR_MIS_PRED_RETIRED"},
+ {"BRANCH-MISSES-RETIRED", "BR_MIS_PRED_RETIRED"},
+ {"unhalted-cycles", "CPU_CYCLES"},
+ {"instructions", "INST_RETIRED",},
+ {"branch-mispredicts", "BR_MIS_PRED_RETIRED"},
+ {"branches", "BR_RETIRED"},
+ {"interrupts", "EXC_IRQ"},
{NULL, NULL},
};
@@ -559,8 +572,8 @@ pmc_pmu_intel_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm,
return (0);
}
-int
-pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
+static int
+pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm)
{
const struct pmu_event *pe;
struct pmu_event_desc ped;
@@ -591,8 +604,8 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
#elif defined(__powerpc64__)
-int
-pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
+static int
+pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm)
{
const struct pmu_event *pe;
struct pmu_event_desc ped;
@@ -618,8 +631,8 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
#elif defined(__aarch64__)
-int
-pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
+static int
+pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm)
{
const struct pmu_event *pe;
struct pmu_event_desc ped;
@@ -636,7 +649,6 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
assert(idx >= 0);
pm->pm_ev = idx;
pm->pm_md.pm_md_config = ped.ped_event;
- pm->pm_md.pm_md_flags |= PM_MD_RAW_EVENT;
pm->pm_class = PMC_CLASS_ARMV8;
pm->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE);
@@ -645,9 +657,28 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
#else
-int
-pmc_pmu_pmcallocate(const char *e __unused, struct pmc_op_pmcallocate *p __unused)
+static int
+pmc_pmu_pmcallocate_md(const char *e __unused, struct pmc_op_pmcallocate *p __unused)
{
return (EOPNOTSUPP);
}
#endif
+
+int
+pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
+{
+ int error;
+
+ error = pmc_pmu_pmcallocate_md(event_name, pm);
+ if (error != 0) {
+ /* Reset any changes. */
+ pm->pm_ev = 0;
+ pm->pm_caps = 0;
+ pm->pm_class = 0;
+
+ return (error);
+ }
+
+ pm->pm_flags |= PMC_F_EV_PMU;
+ return (0);
+}