These modes of operation are orthogonal; a PMC may be configured to operate in one of four modes:
Process-private, counting |
| These PMCs count hardware events whenever a thread in their attached process is scheduled on a CPU. These PMCs normally count from zero, but the initial count may be set using the PMC_OP_SETCOUNT operation. Applications can read the value of the PMC anytime using the PMC_OP_PMCRW operation. |
Process-private, sampling |
| These PMCs sample the target processes instruction pointer after they have seen the configured number of hardware events. The PMCs only count events when a thread belonging to their attached process is active. The desired frequency of sampling is set using the PMC_OP_SETCOUNT operation prior to starting the PMC. Log files are configured using the PMC_OP_CONFIGURELOG operation. |
System-wide, counting |
| These PMCs count hardware events seen by them independent of the processes that are executing. The current count on these PMCs can be read using the PMC_OP_PMCRW request. These PMCs normally count from zero, but the initial count may be set using the PMC_OP_SETCOUNT operation. |
System-wide, sampling |
| These PMCs will periodically sample the instruction pointer of the CPU they are allocated on, and will write the sample to a log for further processing. The desired frequency of sampling is set using the PMC_OP_SETCOUNT operation prior to starting the PMC. Log files are configured using the PMC_OP_CONFIGURELOG operation. System-wide statistical sampling can only be enabled by a process with super-user privileges. |
|
Processes are allowed to allocate as many PMCs are the hardware and current operating conditions permit. Processes may mix allocations of system-wide and process-private PMCs. Multiple processes are allowed to be concurrently using the facilities of the hwpmc driver.
Process-private PMCs need to be attached to a target process before they can be used. Attaching a process to a PMC is done using the PMC_OP_PMCATTACH operation. An already attached PMC may be detached from its target process using the converse PMC_OP_PMCDETACH operation. Issuing a PMC_OP_PMCSTART operation on an as yet unattached PMC will cause it to be attached to its owner process. The following rules determine whether a given process may attach a PMC to another target process:
PMC_OP_CONFIGURELOG |
| Configure a log file for sampling mode PMCs. |
PMC_OP_FLUSHLOG |
| Transfer buffered log data inside hwpmc to a configured output file. This operation returns to the caller after the write operation has returned. |
PMC_OP_GETCPUINFO |
| Retrieve information about the number of CPUs on the system and the number of hardware performance monitoring counters available per-CPU. |
PMC_OP_GETDRIVERSTATS |
| Retrieve module statistics (for analyzing the behavior of hwpmc itself). |
PMC_OP_GETMODULEVERSION |
| Retrieve the version number of API. |
PMC_OP_GETPMCINFO |
| Retrieve information about the current state of the PMCs on a given CPU. |
PMC_OP_PMCADMIN |
| Set the administrative state (i.e., whether enabled or disabled) for the hardware PMCs managed by the hwpmc driver. |
PMC_OP_PMCALLOCATE |
| Allocate and configure a PMC. On successful allocation, a handle to the PMC (a small integer) is returned. |
PMC_OP_PMCATTACH |
| Attach a process mode PMC to a target process. The PMC will be active whenever a thread in the target process is scheduled on a CPU. If the PMC_F_DESCENDANTS flag had been specified at PMC allocation time, then the PMC is attached to all current and future descendants of the target process. |
PMC_OP_PMCDETACH |
| Detach a PMC from its target process. |
PMC_OP_PMCRELEASE |
| Release a PMC. |
PMC_OP_PMCRW |
| Read and write a PMC. This operation is valid only for PMCs configured in counting modes. |
PMC_OP_SETCOUNT |
| Set the initial count (for counting mode PMCs) or the desired sampling rate (for sampling mode PMCs). |
PMC_OP_PMCSTART |
| Start a PMC. |
PMC_OP_PMCSTOP |
| Stop a PMC. |
PMC_OP_WRITELOG |
| Insert a timestamped user record into the log file. |
|
kern.hwpmc.debugflags(string, read-write) |
| (Only available if the hwpmc driver was compiled with -DDEBUG -. ) Control the verbosity of debug messages from the hwpmc driver. |
kern.hwpmc.hashsize(integer, read-only) |
| The number of rows in the hash tables used to keep track of owner and target processes. The default is 16. |
kern.hwpmc.logbuffersize(integer, read-only) |
| The size in kilobytes of each log buffer used by s logging function. The default buffer size is 4KB. |
kern.hwpmc.mtxpoolsize(integer, read-only) |
| The size of the spin mutex pool used by the PMC driver. The default is 32. |
kern.hwpmc.nbuffers(integer, read-only) |
| The number of log buffers used by hwpmc for logging. The default is 16. |
kern.hwpmc.nsamples(integer, read-only) |
| The number of entries in the per-CPU ring buffer used during sampling. The default is 16. |
security.bsd.unprivileged_syspmcs(boolean, read-write) |
| If set to non-zero, allow unprivileged processes to allocate system-wide PMCs. The default value is 0. |
security.bsd.unprivileged_proc_debug(boolean, read-write) |
| If set to 0, the hwpmc driver will only allow privileged processes to attach PMCs to other processes. |
|
"hwpmc: [class/npmc/capabilities]..." | Announce the presence of npmc PMCs of class class, with capabilities described by bit string capabilities. |
"hwpmc: kernel version (0x%x) does not match module version (0x%x)." | The module loading process failed because a version mismatch was detected between the currently executing kernel and the module being loaded. |
"hwpmc: this kernel has not been compiled with options HWPMC_HOOKS." | The module loading process failed because the currently executing kernel was not configured with the required configuration option .Cd HWPMC_HOOKS . |
"hwpmc: tunable hashsize=%d must be greater than zero." | A negative value was supplied for tunable kern.hwpmc.hashsize. |
"hwpmc: tunable logbuffersize=%d must be greater than zero." | A negative value was supplied for tunable kern.hwpmc.logbuffersize. |
"hwpmc: tunable nlogbuffers=%d must be greater than zero." | A negative value was supplied for tunable kern.hwpmc.nlogbuffers. |
"hwpmc: tunable nsamples=%d out of range." | The value for tunable kern.hwpmc.nsamples was negative or greater than 65535. |
|
[EBUSY] |
| A PMC_OP_CONFIGURELOG operation was requested while an existing log was active. |
[EBUSY] |
| A DISABLE operation was requested using the PMC_OP_PMCADMIN request for a set of hardware resources currently in use for process-private PMCs. |
[EBUSY] |
| A PMC_OP_PMCADMIN operation was requested on an active system mode PMC. |
[EBUSY] |
| A PMC_OP_PMCATTACH operation was requested for a target process that already had another PMC using the same hardware resources attached to it. |
[EBUSY] |
| A PMC_OP_PMCRW request writing a new value was issued on a PMC that was active. |
[EBUSY] |
| A PMC_OP_PMCSETCOUNT request was issued on a PMC that was active. |
[EDOOFUS] |
| A PMC_OP_PMCSTART operation was requested without a log file being configured for a PMC allocated with PMC_F_LOG_PROCCSW and PMC_F_LOG_PROCEXIT modifiers. |
[EEXIST] |
| A PMC_OP_PMCATTACH request was reissued for a target process that already is the target of this PMC. |
[EFAULT] |
| A bad address was passed in to the driver. |
[EINVAL] |
| A process specified an invalid PMC handle. |
[EINVAL] |
| An invalid CPU number was passed in for a PMC_OP_GETPMCINFO operation. |
[EINVAL] |
| An invalid CPU number was passed in for a PMC_OP_PMCADMIN operation. |
[EINVAL] |
| An invalid operation request was passed in for a PMC_OP_PMCADMIN operation. |
[EINVAL] |
| An invalid PMC ID was passed in for a PMC_OP_PMCADMIN operation. |
[EINVAL] |
| A suitable PMC matching the parameters passed in to a PMC_OP_PMCALLOCATE request could not be allocated. |
[EINVAL] |
| An invalid PMC mode was requested during a PMC_OP_PMCALLOCATE request. |
[EINVAL] |
| An invalid CPU number was specified during a PMC_OP_PMCALLOCATE request. |
[EINVAL] |
| A CPU other than PMC_CPU_ANY was specified in a PMC_OP_ALLOCATE request for a process-private PMC. |
[EINVAL] |
| A CPU number of PMC_CPU_ANY was specified in a PMC_OP_ALLOCATE request for a system-wide PMC. |
[EINVAL] |
| The pm_flags argument to an PMC_OP_PMCALLOCATE request contained unknown flags. |
[EINVAL] |
| A PMC allocated for system-wide operation was specified with a PMC_OP_PMCATTACH request. |
[EINVAL] |
| The pm_pid argument to a PMC_OP_PMCATTACH request specified an illegal process ID. |
[EINVAL] |
| A PMC_OP_PMCDETACH request was issued for a PMC not attached to the target process. |
[EINVAL] |
| Argument pm_flags to a PMC_OP_PMCRW request contained illegal flags. |
[EINVAL] |
| A PMC_OP_PMCX86GETMSR operation was requested for a PMC not in process-virtual mode, or for a PMC that is not solely attached to its owner process, or for a PMC that was allocated with flag PMC_F_DESCENDANTS. |
[EINVAL] |
| (On Intel Pentium 4 CPUs with HTT support) An allocation request for a process-private PMC was issued for an event that does not support counting on a per-logical CPU basis. |
[ENOMEM] |
| The system was not able to allocate kernel memory. |
[ENOSYS] |
| (i386 architectures) A PMC_OP_PMCX86GETMSR operation was requested for hardware that does not support reading PMCs directly with the RDPMC instruction. |
[ENXIO] |
| A PMC_OP_GETPMCINFO operation was requested for a disabled CPU. |
[ENXIO] |
| A system-wide PMC on a disabled CPU was requested to be allocated with PMC_OP_PMCALLOCATE. |
[ENXIO] |
| A PMC_OP_PMCSTART or PMC_OP_PMCSTOP request was issued for a system-wide PMC that was allocated on a currently disabled CPU. |
[EOPNOTSUPP] |
| A PMC_OP_PMCALLOCATE request was issued for PMC capabilities not supported by the specified PMC class. |
[EPERM] |
| A PMC_OP_PMCADMIN request was issued by a process without super-user privilege or by a jailed super-user process. |
[EPERM] |
| A PMC_OP_PMCATTACH operation was issued for a target process that the current process does not have permission to attach to. |
[EPERM] |
| (i386 and amd64 architectures) A PMC_OP_PMCATTACH operation was issued on a PMC whose MSR has been retrieved using PMC_OP_PMCX86GETMSR. |
[ESRCH] |
| A process issued a PMC operation request without having allocated any PMCs. |
[ESRCH] |
| A process issued a PMC operation request after the PMC was detached from all of its target processes. |
[ESRCH] |
| A PMC_OP_PMCATTACH request specified a non-existent process ID. |
[ESRCH] |
| The target process for a PMC_OP_PMCDETACH operation is not being monitored by the hwpmc driver. |
|