git: 49e1f23c7715 - releng/14.0 - libpmc: make pmc_pmu_pmcallocate() machine-independent
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 25 Sep 2023 17:20:39 UTC
The branch releng/14.0 has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=49e1f23c7715ec1ac665d7c8fea226f761454b3e
commit 49e1f23c7715ec1ac665d7c8fea226f761454b3e
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-06-19 22:32:22 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-09-25 17:18:44 +0000
libpmc: make pmc_pmu_pmcallocate() machine-independent
Have it call the platform-dependent version. For better layering, move
the reset logic inside the new function. This is mainly to facilitate an
upcoming change.
Reviewed by: jkoshy
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40752
(cherry picked from commit 45dcc17e2fb8f0f9838ba167b311f271a08fcea9)
(cherry picked from commit 196bb0e152cf2d3a0ba61bda8a2d09c8107a809a)
---
lib/libpmc/libpmc.c | 5 -----
lib/libpmc/libpmc_pmu_util.c | 34 ++++++++++++++++++++++++++--------
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 71fba89237ff..a7ed1c3d9ac8 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -1091,11 +1091,6 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode,
assert(pmc_config.pm_ev < PMC_EVENT_FIRST);
goto found;
}
-
- /* Otherwise, reset any changes */
- pmc_config.pm_ev = 0;
- pmc_config.pm_caps = 0;
- pmc_config.pm_class = 0;
}
free(spec_copy);
spec_copy = NULL;
diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c
index a61f81f7d2c7..772dec7a9d53 100644
--- a/lib/libpmc/libpmc_pmu_util.c
+++ b/lib/libpmc/libpmc_pmu_util.c
@@ -572,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;
@@ -604,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;
@@ -631,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;
@@ -658,9 +658,27 @@ 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);
+ }
+
+ return (0);
+}