pmc_release(3) [freebsd man page]
PMC_ALLOCATE(3) BSD Library Functions Manual PMC_ALLOCATE(3) NAME
pmc_allocate, pmc_release -- allocate and free performance monitoring counters LIBRARY
Performance Counters Library (libpmc, -lpmc) SYNOPSIS
#include <pmc.h> int pmc_allocate(const char *eventspecifier, enum pmc_mode mode, uint32_t flags, int cpu, pmc_id_t *pmcid); int pmc_release(pmc_id_t pmc); DESCRIPTION
Function pmc_allocate() allocates a performance monitoring counter that measures the events named by argument eventspecifier, and writes the allocated handle to the location pointed to by argument pmcid. Argument eventspecifier comprises an PMC event name followed by an optional comma separated list of keywords and qualifiers. The allowed syntax for argument eventspecifier is processor specific and is listed in section EVENT SPECIFIERS in the pmc(3) manual page. The desired PMC mode is specified by argument mode. Legal values for the mode argument are: PMC_MODE_SC Allocate a system-scope counting PMC. PMC_MODE_SS Allocate a system-scope sampling PMC. PMC_MODE_TC Allocate a process-scope counting PMC. PMC_MODE_TS Allocate a process-scope sampling PMC. Mode specific modifiers may be specified using argument flags. The flags supported at PMC allocation time are: PMC_F_DESCENDANTS For process-scope PMCs, automatically track descendants of attached processes. PMC_F_LOG_PROCCSW For process-scope counting PMCs, generate a log event at every context switch containing the incremental number of hard- ware events seen by the process during the time it was executing on the CPU. PMC_F_LOG_PROCEXIT For process-scope counting PMCs, accumulate hardware events seen when the process was executing on a CPU and generate a log event when an attached process exits. PMCs allocated with flags PMC_F_LOG_PROCCSW and PMC_F_LOG_PROCEXIT need a log file to be configured before they are started. For system scope PMCs, the argument cpu is a non-negative value that specifies the CPU number that the PMC is to be allocated on. Process scope PMC allocations should specify the constant PMC_CPU_ANY for this argument. Function pmc_release() releases the PMC denoted by argument pmcid. RETURN VALUES
If successful, function pmc_allocate() sets the location specified by argument pmcid to the handle of the allocated PMC and returns 0. In case of an error, the function returns -1 and sets the global variable errno to indicate the error. The pmc_release() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
[EINVAL] The argument mode to function pmc_allocate() had an invalid value. [EINVAL] Argument cpu to function pmc_allocate() had an invalid CPU number. [EINVAL] Argument flags contained flags that were unsupported or otherwise incompatible with the requested PMC mode. [EINVAL] Argument eventspecifier to function pmc_allocate() specified an event not supported by hardware or contained a syntax error. [ENXIO] Function pmc_allocate() requested the use of a hardware resource that was absent or administratively disabled. [EOPNOTSUPP] The underlying hardware does not support the capabilities needed for a PMC being allocated by a call to pmc_allocate(). [EPERM] A system scope PMC allocation was attempted without adequate process privilege. [ESRCH] Function pmc_release() was called without first having allocated a PMC. [EINVAL] Argument pmcid to function pmc_release() did not specify a PMC previously allocated by this process. SEE ALSO
pmc(3), pmc_attach(3), pmc_configure_logfile(3), pmc_start(3), hwpmc(4) BSD
September 22, 2008 BSD
Check Out this Related Man Page
PMC_CAPABILITIES(3) BSD Library Functions Manual PMC_CAPABILITIES(3) 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. Function pmc_capabilities() retrieves the hardware capabilities of a PMC. Argument pmc is a PMC handle obtained by a prior call to pmc_allocate(). The function sets argument caps to a bit mask of capabilities supported by the PMC denoted by argument pmc. PMC capabili- ties are described in pmc(3). Function 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. The caller should not free this pointer value. 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 of struct pmc_classinfo descriptors describing the properties of each class of PMCs in the system. Function pmc_ncpu() is a convenience function that returns the maximum CPU number in the system. On systems that support sparsely numbered CPUs, not all CPUs may be physically present. Applications need to be prepared to deal with nonexistent CPUs. Function pmc_npmc() is a convenience function that returns the number of PMCs available in the CPU specified by argument cpu. Function 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 structure 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 in hwpmc(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 in pmc(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. Function 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 coun- ters associated with PMC pmc. 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. 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 to pmc_init() to initialize the PMC library had failed. A call to function pmc_pmcinfo() may fail with the following errors: [EINVAL] The argument cpu was invalid. [ENXIO] The argument cpu specified 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) BSD
September 22, 2008 BSD