git: 937539e0a32c - main - libpmc: fix the 'cycles' event alias on x86

Mitchell Horne mhorne at FreeBSD.org
Thu Sep 30 14:17:21 UTC 2021


The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=937539e0a32ce1da46223664ca1cf3b252e02ece

commit 937539e0a32ce1da46223664ca1cf3b252e02ece
Author:     Mitchell Horne <mhorne at FreeBSD.org>
AuthorDate: 2021-09-30 14:11:36 +0000
Commit:     Mitchell Horne <mhorne at FreeBSD.org>
CommitDate: 2021-09-30 14:15:26 +0000

    libpmc: fix the 'cycles' event alias on x86
    
    Looking for "tsc-tsc" in the pmu tables will fail every time. Instead,
    make this an alias for the static TSC event defined in pmc_events.h.
    This fixes 'pmcstat -s cycles' on Intel and AMD.
    
    Reviewed by:    emaste
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32197
---
 lib/libpmc/libpmc.c          | 2 +-
 lib/libpmc/libpmc_pmu_util.c | 1 -
 sys/dev/hwpmc/pmc_events.h   | 3 +++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 4ff7eb893959..4df888f497c0 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -178,7 +178,7 @@ static const struct pmc_event_descr cortex_a76_event_table[] =
 
 static const struct pmc_event_descr tsc_event_table[] =
 {
-	__PMC_EV_TSC()
+	__PMC_EV_ALIAS_TSC()
 };
 
 #undef	PMC_CLASS_TABLE_DESC
diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c
index edd99357678e..2584f08b8dc3 100644
--- a/lib/libpmc/libpmc_pmu_util.c
+++ b/lib/libpmc/libpmc_pmu_util.c
@@ -74,7 +74,6 @@ static struct pmu_alias pmu_intel_alias_table[] = {
 	{"BRANCH-INSTRUCTION-RETIRED", "BR_INST_RETIRED.ALL_BRANCHES"},
 	{"BRANCH_MISSES_RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"},
 	{"BRANCH-MISSES-RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"},
-	{"cycles", "tsc-tsc"},
 	{"unhalted-cycles", "CPU_CLK_UNHALTED.THREAD_P_ANY"},
 	{"instructions", "inst_retired.any_p"},
 	{"branch-mispredicts", "br_misp_retired.all_branches"},
diff --git a/sys/dev/hwpmc/pmc_events.h b/sys/dev/hwpmc/pmc_events.h
index ae56685f5fc5..e319d72f3fa8 100644
--- a/sys/dev/hwpmc/pmc_events.h
+++ b/sys/dev/hwpmc/pmc_events.h
@@ -54,6 +54,9 @@
 #define        PMC_EV_TSC_FIRST        PMC_EV_TSC_TSC
 #define        PMC_EV_TSC_LAST         PMC_EV_TSC_TSC
 
+#define	__PMC_EV_ALIAS_TSC()			\
+__PMC_EV_ALIAS("cycles",	TSC_TSC)
+
 /*
  * Software events are dynamically defined.
  */


More information about the dev-commits-src-all mailing list