aboutsummaryrefslogtreecommitdiff
path: root/lib/libpmc/libpmc.c
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2018-05-26 19:29:19 +0000
committerMatt Macy <mmacy@FreeBSD.org>2018-05-26 19:29:19 +0000
commit959826ca1bb0a42ddd624bf1803ae2957a3282f3 (patch)
treec994717317a845c2afb2fd2d79beb650af57fafd /lib/libpmc/libpmc.c
parent5506ceb87fa19140863b4e3ee978f631ccc4cf74 (diff)
downloadsrc-959826ca1bb0a42ddd624bf1803ae2957a3282f3.tar.gz
src-959826ca1bb0a42ddd624bf1803ae2957a3282f3.zip
pmc(3)/hwpmc(4): update supported Intel processors to rely fully on the
vendor provided pmu-events tables and sundry cleanups. The vendor pmu-events tables provide counter descriptions, default sample rates, event, umask, and flag values for all the counter configuration permutations. Using this gives us: - much simpler kernel code for the MD component - helpful long and short event descriptions - simpler user code - sample rates that won't overload the system Update man page with newer sample types and remove unused sample type.
Notes
Notes: svn path=/head/; revision=334244
Diffstat (limited to 'lib/libpmc/libpmc.c')
-rw-r--r--lib/libpmc/libpmc.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 8b25768d33d1..05fd84bc0b90 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -2781,8 +2781,27 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode,
if (mode != PMC_MODE_SS && mode != PMC_MODE_TS &&
mode != PMC_MODE_SC && mode != PMC_MODE_TC) {
- errno = EINVAL;
- goto out;
+ return (EINVAL);
+ }
+ bzero(&pmc_config, sizeof(pmc_config));
+ pmc_config.pm_cpu = cpu;
+ pmc_config.pm_mode = mode;
+ pmc_config.pm_flags = flags;
+ if (PMC_IS_SAMPLING_MODE(mode))
+ pmc_config.pm_caps |= PMC_CAP_INTERRUPT;
+ /*
+ * Can we pull this straight from the pmu table?
+ */
+ r = spec_copy = strdup(ctrspec);
+ ctrname = strsep(&r, ",");
+ if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) {
+ if (PMC_CALL(PMCALLOCATE, &pmc_config) < 0)
+ return (errno);
+ *pmcid = pmc_config.pm_pmcid;
+ return (0);
+ } else {
+ free(spec_copy);
+ spec_copy = NULL;
}
/* replace an event alias with the canonical event specifier */
@@ -2833,15 +2852,8 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode,
goto out;
}
- bzero(&pmc_config, sizeof(pmc_config));
pmc_config.pm_ev = ev->pm_ev_code;
pmc_config.pm_class = pcd->pm_evc_class;
- pmc_config.pm_cpu = cpu;
- pmc_config.pm_mode = mode;
- pmc_config.pm_flags = flags;
-
- if (PMC_IS_SAMPLING_MODE(mode))
- pmc_config.pm_caps |= PMC_CAP_INTERRUPT;
if (pcd->pm_evc_allocate_pmc(ev->pm_ev_code, r, &pmc_config) < 0) {
errno = EINVAL;