summaryrefslogtreecommitdiffstats
path: root/lib/libpmc
diff options
context:
space:
mode:
authorbr <br@FreeBSD.org>2015-05-19 15:25:47 +0000
committerbr <br@FreeBSD.org>2015-05-19 15:25:47 +0000
commitb1f1f07fae514c44e3bd47cd9a5abd733ff79621 (patch)
tree0f12b79cbc42f18c0970ad0c563a41924debb8d1 /lib/libpmc
parent64bb7409cdffef4895f0510fcf2a456eb342e1d3 (diff)
downloadFreeBSD-src-b1f1f07fae514c44e3bd47cd9a5abd733ff79621.zip
FreeBSD-src-b1f1f07fae514c44e3bd47cd9a5abd733ff79621.tar.gz
Add Performance Monitoring Counters support for AArch64.
Family-common and CPU-specific counters implemented. Supported CPUs: ARM Cortex A53/57/72. Reviewed by: andrew, bz, emaste, gnn, jhb Sponsored by: ARM Limited Differential Revision: https://reviews.freebsd.org/D2555
Diffstat (limited to 'lib/libpmc')
-rw-r--r--lib/libpmc/libpmc.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 2ad2268..c4482c8 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -82,6 +82,10 @@ static int xscale_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
static int armv7_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
struct pmc_op_pmcallocate *_pmc_config);
#endif
+#if defined(__aarch64__)
+static int arm64_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
+ struct pmc_op_pmcallocate *_pmc_config);
+#endif
#if defined(__mips__)
static int mips_allocate_pmc(enum pmc_event _pe, char* ctrspec,
struct pmc_op_pmcallocate *_pmc_config);
@@ -158,6 +162,7 @@ PMC_CLASSDEP_TABLE(p5, P5);
PMC_CLASSDEP_TABLE(p6, P6);
PMC_CLASSDEP_TABLE(xscale, XSCALE);
PMC_CLASSDEP_TABLE(armv7, ARMV7);
+PMC_CLASSDEP_TABLE(armv8, ARMV8);
PMC_CLASSDEP_TABLE(mips24k, MIPS24K);
PMC_CLASSDEP_TABLE(mips74k, MIPS74K);
PMC_CLASSDEP_TABLE(octeon, OCTEON);
@@ -263,6 +268,16 @@ static const struct pmc_event_descr westmereuc_event_table[] =
__PMC_EV_ALIAS_WESTMEREUC()
};
+static const struct pmc_event_descr cortex_a53_event_table[] =
+{
+ __PMC_EV_ALIAS_ARMV8_CORTEX_A53()
+};
+
+static const struct pmc_event_descr cortex_a57_event_table[] =
+{
+ __PMC_EV_ALIAS_ARMV8_CORTEX_A57()
+};
+
/*
* PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...)
*
@@ -294,6 +309,8 @@ PMC_MDEP_TABLE(p5, P5, PMC_CLASS_SOFT, PMC_CLASS_TSC);
PMC_MDEP_TABLE(p6, P6, PMC_CLASS_SOFT, PMC_CLASS_TSC);
PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_SOFT, PMC_CLASS_XSCALE);
PMC_MDEP_TABLE(armv7, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7);
+PMC_MDEP_TABLE(cortex_a53, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8);
+PMC_MDEP_TABLE(cortex_a57, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8);
PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_SOFT, PMC_CLASS_MIPS24K);
PMC_MDEP_TABLE(mips74k, MIPS74K, PMC_CLASS_SOFT, PMC_CLASS_MIPS74K);
PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_SOFT, PMC_CLASS_OCTEON);
@@ -362,6 +379,10 @@ PMC_CLASS_TABLE_DESC(xscale, XSCALE, xscale, xscale);
#endif
PMC_CLASS_TABLE_DESC(armv7, ARMV7, armv7, armv7);
#endif
+#if defined(__aarch64__)
+PMC_CLASS_TABLE_DESC(cortex_a53, ARMV8, cortex_a53, arm64);
+PMC_CLASS_TABLE_DESC(cortex_a57, ARMV8, cortex_a57, arm64);
+#endif
#if defined(__mips__)
PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips);
PMC_CLASS_TABLE_DESC(mips74k, MIPS74K, mips74k, mips);
@@ -2429,6 +2450,26 @@ armv7_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
}
#endif
+#if defined(__aarch64__)
+static struct pmc_event_alias cortex_a53_aliases[] = {
+ EV_ALIAS(NULL, NULL)
+};
+static struct pmc_event_alias cortex_a57_aliases[] = {
+ EV_ALIAS(NULL, NULL)
+};
+static int
+arm64_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
+ struct pmc_op_pmcallocate *pmc_config __unused)
+{
+ switch (pe) {
+ default:
+ break;
+ }
+
+ return (0);
+}
+#endif
+
#if defined(__mips__)
static struct pmc_event_alias mips24k_aliases[] = {
@@ -2938,6 +2979,19 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
ev = armv7_event_table;
count = PMC_EVENT_TABLE_SIZE(armv7);
break;
+ case PMC_CLASS_ARMV8:
+ switch (cpu_info.pm_cputype) {
+ default:
+ case PMC_CPU_ARMV8_CORTEX_A53:
+ ev = cortex_a53_event_table;
+ count = PMC_EVENT_TABLE_SIZE(cortex_a53);
+ break;
+ case PMC_CPU_ARMV8_CORTEX_A57:
+ ev = cortex_a57_event_table;
+ count = PMC_EVENT_TABLE_SIZE(cortex_a57);
+ break;
+ }
+ break;
case PMC_CLASS_MIPS24K:
ev = mips24k_event_table;
count = PMC_EVENT_TABLE_SIZE(mips24k);
@@ -3235,6 +3289,16 @@ pmc_init(void)
pmc_class_table[n] = &armv7_class_table_descr;
break;
#endif
+#if defined(__aarch64__)
+ case PMC_CPU_ARMV8_CORTEX_A53:
+ PMC_MDEP_INIT(cortex_a53);
+ pmc_class_table[n] = &cortex_a53_class_table_descr;
+ break;
+ case PMC_CPU_ARMV8_CORTEX_A57:
+ PMC_MDEP_INIT(cortex_a57);
+ pmc_class_table[n] = &cortex_a57_class_table_descr;
+ break;
+#endif
#if defined(__mips__)
case PMC_CPU_MIPS_24K:
PMC_MDEP_INIT(mips24k);
@@ -3446,6 +3510,19 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu)
} else if (pe >= PMC_EV_ARMV7_FIRST && pe <= PMC_EV_ARMV7_LAST) {
ev = armv7_event_table;
evfence = armv7_event_table + PMC_EVENT_TABLE_SIZE(armv7);
+ } else if (pe >= PMC_EV_ARMV8_FIRST && pe <= PMC_EV_ARMV8_LAST) {
+ switch (cpu) {
+ case PMC_CPU_ARMV8_CORTEX_A53:
+ ev = cortex_a53_event_table;
+ evfence = cortex_a53_event_table + PMC_EVENT_TABLE_SIZE(cortex_a53);
+ break;
+ case PMC_CPU_ARMV8_CORTEX_A57:
+ ev = cortex_a57_event_table;
+ evfence = cortex_a57_event_table + PMC_EVENT_TABLE_SIZE(cortex_a57);
+ break;
+ default: /* Unknown CPU type. */
+ break;
+ }
} else if (pe >= PMC_EV_MIPS24K_FIRST && pe <= PMC_EV_MIPS24K_LAST) {
ev = mips24k_event_table;
evfence = mips24k_event_table + PMC_EVENT_TABLE_SIZE(mips24k);
OpenPOWER on IntegriCloud