aboutsummaryrefslogtreecommitdiff
path: root/lib/libpmc/libpmc.c
diff options
context:
space:
mode:
authorJoseph Koshy <jkoshy@FreeBSD.org>2005-05-01 14:11:49 +0000
committerJoseph Koshy <jkoshy@FreeBSD.org>2005-05-01 14:11:49 +0000
commitc5153e190bd2410c60a50e108a7a60cde9a3c4bc (patch)
tree1e7573a97fa735d4770310305b9ec83d8767f4a7 /lib/libpmc/libpmc.c
parentb60d26c9b930c7b267cd7f7b4b73d4b44d744124 (diff)
downloadsrc-c5153e190bd2410c60a50e108a7a60cde9a3c4bc.tar.gz
src-c5153e190bd2410c60a50e108a7a60cde9a3c4bc.zip
Add convenience APIs pmc_width() and pmc_capabilities() to -lpmc.
Have pmcstat(8) and pmccontrol(8) use these APIs. Return PMC class-related constants (PMC widths and capabilities) with the OP GETCPUINFO call leaving OP PMCINFO to return only the dynamic information associated with a PMC (i.e., whether enabled, owner pid, reload count etc.). Allow pmc_read() (i.e., OPS PMCRW) on active self-attached PMCs to get upto-date values from hardware since we can guarantee that the hardware is running the correct PMC at the time of the call. Bug fixes: - (x86 class processors) Fix a bug that prevented an RDPMC instruction from being recognized as permitted till after the attached process had context switched out and back in again after a pmc_start() call. Tighten the rules for using RDPMC class instructions: a GETMSR OP is now allowed only after an OP ATTACH has been done by the PMC's owner to itself. OP GETMSR is not allowed for PMCs that track descendants, for PMCs attached to processes other than their owner processes. - (P4/HTT processors only) Fix a bug that caused the MI and MD layers to get out of sync. Add a new MD operation 'get_config()' as part of this fix. - Allow multiple system-mode PMCs at the same row-index but on different CPUs to be allocated. - Reject allocation of an administratively disabled PMC. Misc. code cleanups and refactoring. Improve a few comments.
Notes
Notes: svn path=/head/; revision=145774
Diffstat (limited to 'lib/libpmc/libpmc.c')
-rw-r--r--lib/libpmc/libpmc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 526f07144c1b..272d25a33c1e 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -1981,6 +1981,36 @@ pmc_cpuinfo(const struct pmc_op_getcpuinfo **pci)
return 0;
}
+int
+pmc_width(pmc_id_t pmcid, uint32_t *width)
+{
+ unsigned int i;
+ enum pmc_class cl;
+
+ cl = PMC_ID_TO_CLASS(pmcid);
+ for (i = 0; i < cpu_info.pm_nclass; i++)
+ if (cpu_info.pm_classes[i].pm_class == cl) {
+ *width = cpu_info.pm_classes[i].pm_width;
+ return 0;
+ }
+ return EINVAL;
+}
+
+int
+pmc_capabilities(pmc_id_t pmcid, uint32_t *caps)
+{
+ unsigned int i;
+ enum pmc_class cl;
+
+ cl = PMC_ID_TO_CLASS(pmcid);
+ for (i = 0; i < cpu_info.pm_nclass; i++)
+ if (cpu_info.pm_classes[i].pm_class == cl) {
+ *caps = cpu_info.pm_classes[i].pm_caps;
+ return 0;
+ }
+ return EINVAL;
+}
+
const char *
pmc_name_of_cputype(enum pmc_cputype cp)
{