PMC_CAPABILITIES(3)
π PMC_CAPABILITIES(3) β your little info-gathering era
okay bestie so this is a libpmc page from the Library Functions Manual β that's the Performance Counters Library, aka libpmc (link it with -lpmc). these functions are all about asking the hardware questions. no cap, they're the "tell me everything" friend of the PMC world. π
β¨ NAME β¨
pmc_capabilities, pmc_cpuinfo, pmc_ncpu, pmc_npmc, pmc_pmcinfo, pmc_width β retrieve information about performance monitoring counters π
π LIBRARY π
Performance Counters Library (libpmc, -lpmc) π«Ά
π» SYNOPSIS π»
#include <pmc.h>
int
pmc_capabilities(pmc_id_t pmc, uint32_t *caps);
int
pmc_cpuinfo(const struct pmc_cpuinfo **cpu_info);
int
pmc_ncpu(void);
int
pmc_npmc(int cpu);
int
pmc_pmcinfo(int cpu, struct pmc_pmcinfo **pmc_info);
int
pmc_width(pmc_id_t pmc, uint32_t *width);
πΈ DESCRIPTION πΈ
these functions retrieve information about performance monitoring hardware. it's giving "let me introduce you to your own CPU" energy, honestly. π
π¦ the individual girlies π¦
pmc_capabilities() retrieves the hardware capabilities of a PMC. argument pmc is a PMC handle obtained by a prior call to pmc_allocate(). this function sets argument caps to a bit mask of capabilities supported by the PMC denoted by argument pmc. PMC capabilities are described in pmc(3). slay, capabilities. β¨
pmc_cpuinfo() retrieves information about the CPUs in the system. argument cpu_info will be set to point to an internal structure with information about the system's CPUs.
β οΈ bestie, listen β the caller should not free this pointer value. it's not yours. hands off. π
this structure has the following fields:
pm_cputypeβ specifies the CPU type.pm_ncpuβ specifies the number of CPUs in the system.pm_npmcβ specifies the number of PMC rows per CPU.pm_nclassβ specifies the number of distinct classes of PMCs in the system.pm_classesβ contains an array ofstruct pmc_classinfodescriptors describing the properties of each class of PMCs in the system.
pmc_ncpu() is a convenience function that returns the maximum CPU number in the system. here's the plot twist π β on systems that support sparsely numbered CPUs, not all CPUs may be physically present. so applications need to be prepared to deal with nonexistent CPUs. ghost CPUs, literally. π»
pmc_npmc() is a convenience function that returns the number of PMCs available in the CPU specified by argument cpu.
pmc_pmcinfo() returns information about the current state of the PMC hardware in the CPU specified by argument cpu. the location specified by argument pmc_info is set to point an array of struct pmc_info structures, each describing the state of one PMC in the CPU. these structures contain the following fields:
pm_nameβ a human readable name for the PMC.pm_classβ the PMC class for the PMC.pm_enabledβ non-zero if the PMC is enabled.pm_rowdispβ the disposition of the PMC row for this PMC. row dispositions are documented inhwpmc(4).pm_ownerpidβ if the hardware is in use, the process id of the owner of the PMC.pm_modeβ the PMC mode as described inpmc(3).pm_eventβ if the hardware is in use, the PMC event being measured.pm_flagsβ if the hardware is in use, the flags associated with the PMC.pm_reloadcountβ for sampling PMCs, the reload count associated with the PMC.
pmc_width() is used to retrieve the width in bits of the hardware counters associated with a PMC. argument pmc is a PMC handle obtained by a prior call to pmc_allocate(). the function sets the location pointed to by argument width to the width of the physical counters associated with PMC pmc. width = how thicc your counter is, basically. π
π₯ RETURN VALUES π₯
functions pmc_ncpu() and pmc_npmc() returns a positive integer if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. π
functions pmc_capabilities(), pmc_cpuinfo(), pmc_pmcinfo() and pmc_width() return 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
π«Ά friendly reminder:-1is the villain era signal. always checkerrnoafter.
π ERRORS π
a call to function pmc_capabilities() may fail with the following errors:
[EINVAL]β the argument to the function was invalid.
calls to functions pmc_cpuinfo(), pmc_ncpu() and pmc_npmc() may fail with the following errors:
[ENXIO]β a prior call topmc_init()to initialize the PMC library had failed.
a call to function pmc_pmcinfo() may fail with the following errors:
[EINVAL]β the argumentcpuwas invalid.[ENXIO]β the argumentcpuspecified a disabled or absent CPU.
a call to function pmc_width() may fail with the following errors:
[EINVAL]β the argument to the function was invalid.
π SEE ALSO π
pmc(3), pmc_allocate(3), pmc_get_driver_stats(3), pmc_name_of_capability(3), pmc_name_of_class(3), pmc_name_of_cputype(3), pmc_name_of_event(3), pmc_name_of_mode(3), hwpmc(4)
go read all of them, iykwim. it's giving study group. πβ¨
mwah π this one's from Debian, dated September 22, 2008 β yeah she's an older icon but she still ate, and the whole page is filed under PMC_CAPABILITIES(3). periodt. π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2007-2008 Joseph Koshy. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms