Page MenuHomeFreeBSD

D30603.id91219.diff
No OneTemporary

D30603.id91219.diff

Index: lib/libpmc/libpmc_pmu_util.c
===================================================================
--- lib/libpmc/libpmc_pmu_util.c
+++ lib/libpmc/libpmc_pmu_util.c
@@ -2,6 +2,10 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2018, Matthew Macy
+ * Copyright (c) 2021, The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Mitchell Horne
+ * under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -139,6 +143,30 @@
return (name);
}
+#elif defined(__aarch64__)
+
+static struct pmu_alias pmu_armv8_alias_table[] = {
+ {"BRANCH_INSTRUCTION_RETIRED", "BR_PRED"},
+ {"BRANCH-INSTRUCTION-RETIRED", "BR_PRED"},
+ {"BRANCH_MISSES_RETIRED", "BR_MIS_PRED"},
+ {"BRANCH-MISSES-RETIRED", "BR_MIS_PRED"},
+ {"branch-mispredicts", "BR_MIS_PRED"},
+ {"branches", "BR_PRED"},
+ {"instructions", "INST_SPEC"},
+};
+
+static const char *
+pmu_alias_get(const char *name)
+{
+ struct pmu_alias *pa;
+
+ for (pa = pmu_armv8_alias_table; pa->pa_alias != NULL; pa++)
+ if (strcasecmp(name, pa->pa_alias) == 0)
+ return (pa->pa_name);
+
+ return (name);
+}
+
#else
static const char *
@@ -549,6 +577,28 @@
return (pmc_pmu_amd_pmcallocate(event_name, pm, &ped));
}
+#elif defined(__aarch64__)
+
+int
+pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
+{
+ const struct pmu_event *pe;
+ int idx = -1;
+
+ 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);
+
+ assert(idx >= 0);
+ pm->pm_md.pm_has_raw_event = true;
+ pm->pm_class = PMC_CLASS_ARMV8;
+ pm->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE);
+
+ return (0);
+}
+
#else
int

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 7, 6:25 AM (3 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31015316
Default Alt Text
D30603.id91219.diff (1 KB)

Event Timeline