Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Sep 2023 20:27:46 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 45dcc17e2fb8 - main - libpmc: make pmc_pmu_pmcallocate() machine-independent
Message-ID:  <202309032027.383KRkcu089772@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=45dcc17e2fb8f0f9838ba167b311f271a08fcea9

commit 45dcc17e2fb8f0f9838ba167b311f271a08fcea9
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-06-19 22:32:22 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-09-03 20:27:05 +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
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D40752
---
 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);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309032027.383KRkcu089772>