1ebccf1e3SJoseph Koshy.\" Copyright (c) 2003-2005 Joseph Koshy 2ebccf1e3SJoseph Koshy.\" All rights reserved. 3ebccf1e3SJoseph Koshy.\" 4ebccf1e3SJoseph Koshy.\" Redistribution and use in source and binary forms, with or without 5ebccf1e3SJoseph Koshy.\" modification, are permitted provided that the following conditions 6ebccf1e3SJoseph Koshy.\" are met: 7ebccf1e3SJoseph Koshy.\" 1. Redistributions of source code must retain the above copyright 8ebccf1e3SJoseph Koshy.\" notice, this list of conditions and the following disclaimer. 9ebccf1e3SJoseph Koshy.\" 2. Redistributions in binary form must reproduce the above copyright 10ebccf1e3SJoseph Koshy.\" notice, this list of conditions and the following disclaimer in the 11ebccf1e3SJoseph Koshy.\" documentation and/or other materials provided with the distribution. 12ebccf1e3SJoseph Koshy.\" 13ebccf1e3SJoseph Koshy.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14ebccf1e3SJoseph Koshy.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15ebccf1e3SJoseph Koshy.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16ebccf1e3SJoseph Koshy.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17ebccf1e3SJoseph Koshy.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18ebccf1e3SJoseph Koshy.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19ebccf1e3SJoseph Koshy.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20ebccf1e3SJoseph Koshy.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21ebccf1e3SJoseph Koshy.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22ebccf1e3SJoseph Koshy.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23ebccf1e3SJoseph Koshy.\" SUCH DAMAGE. 24ebccf1e3SJoseph Koshy.\" 25ebccf1e3SJoseph Koshy.\" $FreeBSD$ 26ebccf1e3SJoseph Koshy.\" 27d9a5f346SJoseph Koshy.Dd April 15, 2005 28ebccf1e3SJoseph Koshy.Dt HWPMC 4 29ebccf1e3SJoseph Koshy.Os 30ebccf1e3SJoseph Koshy.Sh NAME 31ebccf1e3SJoseph Koshy.Nm hwpmc 32d9a5f346SJoseph Koshy.Nd "Hardware Performance Monitoring Counter support" 33ebccf1e3SJoseph Koshy.Sh SYNOPSIS 34d9a5f346SJoseph Koshy.Cd "options HWPMC_HOOKS" 35d9a5f346SJoseph Koshy.Cd "device hwpmc" 36ebccf1e3SJoseph Koshy.Sh DESCRIPTION 37ebccf1e3SJoseph KoshyThe 38ebccf1e3SJoseph Koshy.Nm 39ebccf1e3SJoseph Koshydriver virtualizes the hardware performance monitoring facilities in 40ebccf1e3SJoseph Koshymodern CPUs and provides support for using these facilities from 41ebccf1e3SJoseph Koshyuser level processes. 42ebccf1e3SJoseph Koshy.Pp 43ebccf1e3SJoseph KoshyThe driver supports multi-processor systems. 44ebccf1e3SJoseph Koshy.Pp 45ebccf1e3SJoseph KoshyPMCs are allocated using the 46d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 47ebccf1e3SJoseph Koshyrequest. 48ebccf1e3SJoseph KoshyA successful 49d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 50ebccf1e3SJoseph Koshyrequest will return an integer handle (typically a small integer) to 51ebccf1e3SJoseph Koshythe requesting process. 52ebccf1e3SJoseph KoshySubsequent operations on the allocated PMC use this handle to denote 53ebccf1e3SJoseph Koshythe specific PMC. 54ebccf1e3SJoseph KoshyA process that has successfully allocated a PMC is termed an 55ebccf1e3SJoseph Koshy.Dq "owner process" . 56ebccf1e3SJoseph Koshy.Pp 57ebccf1e3SJoseph KoshyPMCs may be allocated to operate in process-private or in system-wide 58ebccf1e3SJoseph Koshymodes. 59d9a5f346SJoseph Koshy.Bl -tag -width ".Em Process-private" 60ebccf1e3SJoseph Koshy.It Em Process-private 61ebccf1e3SJoseph KoshyIn process-private mode, a PMC is active only when a thread belonging 62ebccf1e3SJoseph Koshyto a process it is attached to is scheduled on a CPU. 63ebccf1e3SJoseph Koshy.It Em System-wide 64d9a5f346SJoseph KoshyIn system-wide mode, a PMC operates independently of processes and 65ebccf1e3SJoseph Koshymeasures hardware events for the system as a whole. 66ebccf1e3SJoseph Koshy.El 67ebccf1e3SJoseph Koshy.Pp 68ebccf1e3SJoseph KoshyThe 69ebccf1e3SJoseph Koshy.Nm 70ebccf1e3SJoseph Koshydriver supports the use of hardware PMCs for counting or for 71ebccf1e3SJoseph Koshysampling: 72d9a5f346SJoseph Koshy.Bl -tag -width ".Em Counting" 73ebccf1e3SJoseph KoshyIn counting modes, the PMCs count hardware events. 74ebccf1e3SJoseph KoshyThese counts are retrievable using the 75d9a5f346SJoseph Koshy.Dv PMC_OP_PMCREAD 76ebccf1e3SJoseph Koshysystem call on all architectures, though some architectures like the 77ebccf1e3SJoseph Koshyx86 and amd64 offer faster methods of reading these counts. 78ebccf1e3SJoseph Koshy.It Em Sampling 79ebccf1e3SJoseph KoshyIn sampling modes, where PMCs are configured to sample the CPU 80ebccf1e3SJoseph Koshyinstruction pointer after a configurable number of hardware events 81ebccf1e3SJoseph Koshyhave been observed. 82ebccf1e3SJoseph KoshyThese instruction pointer samples are directed to a log file for 83ebccf1e3SJoseph Koshysubsequent analysis. 84ebccf1e3SJoseph Koshy.El 85ebccf1e3SJoseph Koshy.Pp 86ebccf1e3SJoseph KoshyThese modes of operation are orthogonal; a PMC may be configured to 87ebccf1e3SJoseph Koshyoperate in one of four modes: 88ebccf1e3SJoseph Koshy.Bl -tag -width indent 89ebccf1e3SJoseph Koshy.It Process-private, counting 90ebccf1e3SJoseph KoshyThese PMCs count hardware events whenever a thread in their attached process is 91ebccf1e3SJoseph Koshyscheduled on a CPU. 92ebccf1e3SJoseph KoshyThese PMCs normally count from zero, but the initial count may be 93ebccf1e3SJoseph Koshyset using the 94d9a5f346SJoseph Koshy.Dv PMC_OP_SETCOUNT 95ebccf1e3SJoseph Koshyoperation. 96ebccf1e3SJoseph KoshyApplications can read the value of the PMC anytime using the 97d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 98ebccf1e3SJoseph Koshyoperation. 99ebccf1e3SJoseph Koshy.It Process-private, sampling 100ebccf1e3SJoseph KoshyThese PMCs sample the target processes instruction pointer after they 101ebccf1e3SJoseph Koshyhave seen the configured number of hardware events. 102ebccf1e3SJoseph KoshyThe PMCs only count events when a thread belonging to their attached 103ebccf1e3SJoseph Koshyprocess is active. 104ebccf1e3SJoseph KoshyThe desired frequency of sampling is set using the 105d9a5f346SJoseph Koshy.Dv PMC_OP_SETCOUNT 106ebccf1e3SJoseph Koshyoperation prior to starting the PMC. 107ebccf1e3SJoseph KoshyLog files are configured using the 108d9a5f346SJoseph Koshy.Dv PMC_OP_CONFIGURELOG 109ebccf1e3SJoseph Koshyoperation. 110ebccf1e3SJoseph Koshy.It System-wide, counting 111ebccf1e3SJoseph KoshyThese PMCs count hardware events seen by them independent of the 112ebccf1e3SJoseph Koshyprocesses that are executing. 113ebccf1e3SJoseph KoshyThe current count on these PMCs can be read using the 114d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 115ebccf1e3SJoseph Koshyrequest. 116ebccf1e3SJoseph KoshyThese PMCs normally count from zero, but the initial count may be 117ebccf1e3SJoseph Koshyset using the 118d9a5f346SJoseph Koshy.Dv PMC_OP_SETCOUNT 119ebccf1e3SJoseph Koshyoperation. 120ebccf1e3SJoseph Koshy.It System-wide, sampling 121ebccf1e3SJoseph KoshyThese PMCs will periodically sample the instruction pointer of the CPU 122ebccf1e3SJoseph Koshythey are allocated on, and will write the sample to a log for further 123ebccf1e3SJoseph Koshyprocessing. 124ebccf1e3SJoseph KoshyThe desired frequency of sampling is set using the 125d9a5f346SJoseph Koshy.Dv PMC_OP_SETCOUNT 126ebccf1e3SJoseph Koshyoperation prior to starting the PMC. 127ebccf1e3SJoseph KoshyLog files are configured using the 128d9a5f346SJoseph Koshy.Dv PMC_OP_CONFIGURELOG 129ebccf1e3SJoseph Koshyoperation. 130ebccf1e3SJoseph Koshy.Pp 131ebccf1e3SJoseph KoshySystem-wide statistical sampling can only be enabled by a process with 132ebccf1e3SJoseph Koshysuper-user privileges. 133ebccf1e3SJoseph Koshy.El 134ebccf1e3SJoseph Koshy.Pp 135ebccf1e3SJoseph KoshyProcesses are allowed to allocate as many PMCs are the hardware and 136ebccf1e3SJoseph Koshycurrent operating conditions permit. 137ebccf1e3SJoseph KoshyProcesses may mix allocations of system-wide and process-private 138ebccf1e3SJoseph KoshyPMCs. 139ebccf1e3SJoseph KoshyMultiple processes are allowed to be concurrently using the facilities 140ebccf1e3SJoseph Koshyof the 141ebccf1e3SJoseph Koshy.Nm 142ebccf1e3SJoseph Koshydriver. 143ebccf1e3SJoseph Koshy.Pp 144ebccf1e3SJoseph KoshyAllocated PMCs are started using the 145d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSTART 146ebccf1e3SJoseph Koshyoperation, and stopped using the 147d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSTOP 148ebccf1e3SJoseph Koshyoperation. 149ebccf1e3SJoseph KoshyStopping and starting a PMC is permitted at any time the owner process 150ebccf1e3SJoseph Koshyhas a valid handle to the PMC. 151ebccf1e3SJoseph Koshy.Pp 152ebccf1e3SJoseph KoshyProcess-private PMCs need to be attached to a target process before 153ebccf1e3SJoseph Koshythey can be used. 154ebccf1e3SJoseph KoshyAttaching a process to a PMC is done using the 155d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 156ebccf1e3SJoseph Koshyoperation. 157ebccf1e3SJoseph KoshyAn already attached PMC may be detached from its target process 158ebccf1e3SJoseph Koshyusing the converse 159d9a5f346SJoseph Koshy.Dv PMC_OP_PMCDETACH 160ebccf1e3SJoseph Koshyoperation. 161d9a5f346SJoseph KoshyIssuing a 162d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSTART 163ebccf1e3SJoseph Koshyoperation on an as yet unattached PMC will cause it to be attached 164ebccf1e3SJoseph Koshyto its owner process. 165ebccf1e3SJoseph KoshyThe following rules determine whether a given process may attach 166ebccf1e3SJoseph Koshya PMC to another target process: 167ebccf1e3SJoseph Koshy.Bl -bullet -compact 168ebccf1e3SJoseph Koshy.It 169ebccf1e3SJoseph KoshyA non-jailed process with super-user privileges is allowed to attach 170ebccf1e3SJoseph Koshyto any other process in the system. 171ebccf1e3SJoseph Koshy.It 172ebccf1e3SJoseph KoshyOther processes are only allowed to attach to targets that they would 173ebccf1e3SJoseph Koshybe able to attach to for debugging (as determined by 174ebccf1e3SJoseph Koshy.Xr p_candebug 9 ) . 175ebccf1e3SJoseph Koshy.El 176ebccf1e3SJoseph Koshy.Pp 177ebccf1e3SJoseph KoshyPMCs are released using 178d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRELEASE . 179ebccf1e3SJoseph KoshyAfter a successful 180d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRELEASE 181ebccf1e3SJoseph Koshyoperation the handle to the PMC will become invalid. 182d9a5f346SJoseph Koshy.Ss Modifier Flags 183ebccf1e3SJoseph KoshyThe 184d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 185ebccf1e3SJoseph Koshyoperation supports the following flags that modify the behavior 186ebccf1e3SJoseph Koshyof an allocated PMC: 187d9a5f346SJoseph Koshy.Bl -tag -width indent 188ebccf1e3SJoseph Koshy.It Dv PMC_F_DESCENDANTS 189f263522aSJoseph KoshyThis modifier is valid only for a PMC being allocated in process-private 190ebccf1e3SJoseph Koshymode. 191ebccf1e3SJoseph KoshyIt signifies that the PMC will track hardware events for its 192ebccf1e3SJoseph Koshytarget process and the target's current and future descendants. 193f263522aSJoseph Koshy.It Dv PMC_F_KGMON 194f263522aSJoseph KoshyThis modifier is valid only for a PMC being allocated in system-wide 195f263522aSJoseph Koshysampling mode. 196f263522aSJoseph KoshyIt signifies that the PMC's sampling interrupt is to be used to drive 197f263522aSJoseph Koshykernel profiling via 198f263522aSJoseph Koshy.Xr kgmon 8 . 199f263522aSJoseph Koshy.It Dv PMC_F_LOG_PROCCSW 200f263522aSJoseph KoshyThis modifier is valid only for a PMC being allocated in process-private 201f263522aSJoseph Koshymode. 2023bc6c674SJoseph KoshyWhen this modifier is present, at every context switch, 203f263522aSJoseph Koshy.Nm 2043bc6c674SJoseph Koshywill log a record containing the number of hardware events 2053bc6c674SJoseph Koshyseen by the target process when it was scheduled on the CPU. 206f263522aSJoseph Koshy.It Dv PMC_F_LOG_PROCEXIT 207f263522aSJoseph KoshyThis modifier is valid only for a PMC being allocated in process-private 208f263522aSJoseph Koshymode. 209f263522aSJoseph KoshyWith this modifier present, 210f263522aSJoseph Koshy.Nm 211f263522aSJoseph Koshywill maintain per-process counts for each target process attached to 212f263522aSJoseph Koshya PMC. 213d9a5f346SJoseph KoshyAt process exit time, a record containing the target process' PID and 214f263522aSJoseph Koshythe accumulated per-process count for that process will be written to the 215f263522aSJoseph Koshyconfigured log file. 216ebccf1e3SJoseph Koshy.El 217d9a5f346SJoseph Koshy.Pp 218f263522aSJoseph KoshyModifiers 219f263522aSJoseph Koshy.Dv PMC_F_LOG_PROCEXIT 220f263522aSJoseph Koshyand 221f263522aSJoseph Koshy.Dv PMC_F_LOG_PROCCSW 222f263522aSJoseph Koshymay be used in combination with modifier 223f263522aSJoseph Koshy.Dv PMC_F_DESCENDANTS 224f263522aSJoseph Koshyto track the behaviour of complex pipelines of processes. 2253bc6c674SJoseph KoshyPMCs with modifiers 2263bc6c674SJoseph Koshy.Dv PMC_F_LOG_PROCEXIT 2273bc6c674SJoseph Koshyand 2283bc6c674SJoseph Koshy.Dv PMC_F_LOG_PROCCSW 2293bc6c674SJoseph Koshycannot be started until their owner process has configured a log file. 230d9a5f346SJoseph Koshy.Ss Signals 231ebccf1e3SJoseph KoshyThe 232ebccf1e3SJoseph Koshy.Nm 233ebccf1e3SJoseph Koshydriver may deliver signals to processes that have allocated PMCs: 234d9a5f346SJoseph Koshy.Bl -tag -width ".Dv SIGBUS" 235d9a5f346SJoseph Koshy.It Dv SIGIO 236ebccf1e3SJoseph KoshyA 237d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 238ebccf1e3SJoseph Koshyoperation was attempted on a process-private PMC that does not have 239ebccf1e3SJoseph Koshyattached target processes. 240d9a5f346SJoseph Koshy.It Dv SIGBUS 241ebccf1e3SJoseph KoshyThe 242ebccf1e3SJoseph Koshy.Nm 243ebccf1e3SJoseph Koshydriver is being unloaded from the kernel. 244ebccf1e3SJoseph Koshy.El 245ebccf1e3SJoseph Koshy.Sh PROGRAMMING API 246ebccf1e3SJoseph KoshyThe recommended way for application programs to use the facilities of 247ebccf1e3SJoseph Koshythe 248ebccf1e3SJoseph Koshy.Nm 249d9a5f346SJoseph Koshydriver is using the API provided by the 250d9a5f346SJoseph Koshy.Xr pmc 3 251d9a5f346SJoseph Koshylibrary. 252ebccf1e3SJoseph Koshy.Pp 253ebccf1e3SJoseph KoshyThe 254ebccf1e3SJoseph Koshy.Nm 255ebccf1e3SJoseph Koshydriver operates using a system call number that is dynamically 256ebccf1e3SJoseph Koshyallotted to it when it is loaded into the kernel. 257ebccf1e3SJoseph Koshy.Pp 258ebccf1e3SJoseph KoshyThe 259ebccf1e3SJoseph Koshy.Nm 260ebccf1e3SJoseph Koshydriver supports the following operations: 261ebccf1e3SJoseph Koshy.Bl -tag -width indent 262d9a5f346SJoseph Koshy.It Dv PMC_OP_CONFIGURELOG 263ebccf1e3SJoseph KoshyConfigure a log file for sampling mode PMCs. 264d9a5f346SJoseph Koshy.It Dv PMC_OP_FLUSHLOG 265f263522aSJoseph KoshyTransfer buffered log data inside 266f263522aSJoseph Koshy.Nm 267f263522aSJoseph Koshyto a configured output file. 268f263522aSJoseph KoshyThis operation returns to the caller after the write operation 269f263522aSJoseph Koshyhas returned. 270d9a5f346SJoseph Koshy.It Dv PMC_OP_GETCPUINFO 271ebccf1e3SJoseph KoshyRetrieve information about the number of CPUs on the system and 272ebccf1e3SJoseph Koshythe number of hardware performance monitoring counters available per-CPU. 273d9a5f346SJoseph Koshy.It Dv PMC_OP_GETDRIVERSTATS 274ebccf1e3SJoseph KoshyRetrieve module statistics (for analyzing the behavior of 275ebccf1e3SJoseph Koshy.Nm 276ebccf1e3SJoseph Koshyitself). 277d9a5f346SJoseph Koshy.It Dv PMC_OP_GETMODULEVERSION 278ebccf1e3SJoseph KoshyRetrieve the version number of API. 279d9a5f346SJoseph Koshy.It Dv PMC_OP_GETPMCINFO 280ebccf1e3SJoseph KoshyRetrieve information about the current state of the PMCs on a 281ebccf1e3SJoseph Koshygiven CPU. 282d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCADMIN 283ebccf1e3SJoseph KoshySet the administrative state (i.e., whether enabled or disabled) for 284ebccf1e3SJoseph Koshythe hardware PMCs managed by the 285ebccf1e3SJoseph Koshy.Nm 286ebccf1e3SJoseph Koshydriver. 287d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCALLOCATE 288ebccf1e3SJoseph KoshyAllocate and configure a PMC. 289ebccf1e3SJoseph KoshyOn successful allocation, a handle to the PMC (a small integer) 290ebccf1e3SJoseph Koshyis returned. 291d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCATTACH 292ebccf1e3SJoseph KoshyAttach a process mode PMC to a target process. 293ebccf1e3SJoseph KoshyThe PMC will be active whenever a thread in the target process is 294ebccf1e3SJoseph Koshyscheduled on a CPU. 295ebccf1e3SJoseph Koshy.Pp 296ebccf1e3SJoseph KoshyIf the 297ebccf1e3SJoseph Koshy.Dv PMC_F_DESCENDANTS 298ebccf1e3SJoseph Koshyflag had been specified at PMC allocation time, then the PMC is 299ebccf1e3SJoseph Koshyattached to all current and future descendants of the target process. 300d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCDETACH 301ebccf1e3SJoseph KoshyDetach a PMC from its target process. 302d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCRELEASE 303ebccf1e3SJoseph KoshyRelease a PMC. 304d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCRW 305ebccf1e3SJoseph KoshyRead and write a PMC. 306ebccf1e3SJoseph KoshyThis operation is valid only for PMCs configured in counting modes. 307d9a5f346SJoseph Koshy.It Dv PMC_OP_SETCOUNT 308ebccf1e3SJoseph KoshySet the initial count (for counting mode PMCs) or the desired sampling 309ebccf1e3SJoseph Koshyrate (for sampling mode PMCs). 310d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCSTART 311ebccf1e3SJoseph KoshyStart a PMC. 312d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCSTOP 313ebccf1e3SJoseph KoshyStop a PMC. 314d9a5f346SJoseph Koshy.It Dv PMC_OP_WRITELOG 315ebccf1e3SJoseph KoshyInsert a timestamped user record into the log file. 316ebccf1e3SJoseph Koshy.El 317d9a5f346SJoseph Koshy.Ss i386 Specific API 318ebccf1e3SJoseph KoshySome i386 family CPUs support the RDPMC instruction which allows a 319ebccf1e3SJoseph Koshyuser process to read a PMC value without needing to invoke a 320d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 321ebccf1e3SJoseph Koshyoperation. 322ebccf1e3SJoseph KoshyOn such CPUs, the machine address associated with an allocated PMC is 323ebccf1e3SJoseph Koshyretrievable using the 324d9a5f346SJoseph Koshy.Dv PMC_OP_PMCX86GETMSR 325ebccf1e3SJoseph Koshysystem call. 326ebccf1e3SJoseph Koshy.Bl -tag -width indent 327d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCX86GETMSR 328ebccf1e3SJoseph KoshyRetrieve the MSR (machine specific register) number associated with 329ebccf1e3SJoseph Koshythe given PMC handle. 330ebccf1e3SJoseph Koshy.Pp 331c5153e19SJoseph KoshyThe PMC needs to be in process-private mode and allocated without the 332d9a5f346SJoseph Koshy.Dv PMC_F_DESCENDANTS 333c5153e19SJoseph Koshymodifier flag, and should be attached only to its owner process at the 334c5153e19SJoseph Koshytime of the call. 335ebccf1e3SJoseph Koshy.El 336d9a5f346SJoseph Koshy.Ss amd64 Specific API 337d9a5f346SJoseph KoshyAMD64 CPUs support the RDPMC instruction which allows a 338ebccf1e3SJoseph Koshyuser process to read a PMC value without needing to invoke a 339d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 340ebccf1e3SJoseph Koshyoperation. 341ebccf1e3SJoseph KoshyThe machine address associated with an allocated PMC is 342ebccf1e3SJoseph Koshyretrievable using the 343d9a5f346SJoseph Koshy.Dv PMC_OP_PMCX86GETMSR 344ebccf1e3SJoseph Koshysystem call. 345ebccf1e3SJoseph Koshy.Bl -tag -width indent 346d9a5f346SJoseph Koshy.It Dv PMC_OP_PMCX86GETMSR 347ebccf1e3SJoseph KoshyRetrieve the MSR (machine specific register) number associated with 348ebccf1e3SJoseph Koshythe given PMC handle. 349ebccf1e3SJoseph Koshy.Pp 350c5153e19SJoseph KoshyThe PMC needs to be in process-private mode and allocated without the 351d9a5f346SJoseph Koshy.Dv PMC_F_DESCENDANTS 352c5153e19SJoseph Koshymodifier flag, and should be attached only to its owner process at the 353c5153e19SJoseph Koshytime of the call. 354ebccf1e3SJoseph Koshy.El 355ebccf1e3SJoseph Koshy.Sh SYSCTL TUNABLES 356ebccf1e3SJoseph KoshyThe behavior of 357ebccf1e3SJoseph Koshy.Nm 358ebccf1e3SJoseph Koshyis influenced by the following 359ebccf1e3SJoseph Koshy.Xr sysctl 8 360f263522aSJoseph Koshyand 361f263522aSJoseph Koshy.Xr loader 8 362ebccf1e3SJoseph Koshytunables: 363ebccf1e3SJoseph Koshy.Bl -tag -width indent 364f263522aSJoseph Koshy.It Va kern.hwpmc.debugflags Pq string, read-write 365ebccf1e3SJoseph Koshy(Only available if the 366ebccf1e3SJoseph Koshy.Nm 367ebccf1e3SJoseph Koshydriver was compiled with 368d9a5f346SJoseph Koshy.Fl DDEBUG . ) 369ebccf1e3SJoseph KoshyControl the verbosity of debug messages from the 370ebccf1e3SJoseph Koshy.Nm 371ebccf1e3SJoseph Koshydriver. 372f263522aSJoseph Koshy.It Va kern.hwpmc.hashsize Pq integer, read-only 373d9a5f346SJoseph KoshyThe number of rows in the hash tables used to keep track of owner and 374ebccf1e3SJoseph Koshytarget processes. 375f263522aSJoseph KoshyThe default is 16. 376f263522aSJoseph Koshy.It Va kern.hwpmc.logbuffersize Pq integer, read-only 377f263522aSJoseph KoshyThe size in kilobytes of each log buffer used by 378d9a5f346SJoseph Koshy.Nm Ns 's 379f263522aSJoseph Koshylogging function. 380f263522aSJoseph KoshyThe default buffers size is 4KB. 381f263522aSJoseph Koshy.It Va kern.hwpmc.mtxpoolsize Pq integer, read-only 382ebccf1e3SJoseph KoshyThe size of the spin mutex pool used by the PMC driver. 383f263522aSJoseph KoshyThe default is 32. 384f263522aSJoseph Koshy.It Va kern.hwpmc.nbuffers Pq integer, read-only 385f263522aSJoseph KoshyThe number of log buffers used by 386f263522aSJoseph Koshy.Nm 387f263522aSJoseph Koshyfor logging. 388f263522aSJoseph KoshyThe default is 16. 389f263522aSJoseph Koshy.It Va kern.hwpmc.nsamples Pq integer, read-only 390d9a5f346SJoseph KoshyThe number of entries in the per-CPU ring buffer used during sampling. 391f263522aSJoseph KoshyThe default is 16. 392f263522aSJoseph Koshy.It Va security.bsd.unprivileged_syspmcs Pq boolean, read-write 393ebccf1e3SJoseph KoshyIf set to non-zero, allow unprivileged processes to allocate system-wide 394ebccf1e3SJoseph KoshyPMCs. 395ebccf1e3SJoseph KoshyThe default value is 0. 396f263522aSJoseph Koshy.It Va security.bsd.unprivileged_proc_debug Pq boolean, read-write 397ebccf1e3SJoseph KoshyIf set to 0, the 398ebccf1e3SJoseph Koshy.Nm 399f263522aSJoseph Koshydriver will only allow privileged processes to attach PMCs to other 400ebccf1e3SJoseph Koshyprocesses. 401ebccf1e3SJoseph Koshy.El 402ebccf1e3SJoseph Koshy.Pp 403ebccf1e3SJoseph KoshyThese variables may be set in the kernel environment using 404ebccf1e3SJoseph Koshy.Xr kenv 1 405ebccf1e3SJoseph Koshybefore 406ebccf1e3SJoseph Koshy.Nm 407ebccf1e3SJoseph Koshyis loaded. 408ebccf1e3SJoseph Koshy.Sh SECURITY CONSIDERATIONS 409ebccf1e3SJoseph KoshyPMCs may be used to monitor the actual behaviour of the system on hardware. 410ebccf1e3SJoseph KoshyIn situations where this constitutes an undesirable information leak, 411ebccf1e3SJoseph Koshythe following options are available: 412ebccf1e3SJoseph Koshy.Bl -enum 413ebccf1e3SJoseph Koshy.It 414ebccf1e3SJoseph KoshySet the 415ebccf1e3SJoseph Koshy.Xr sysctl 8 416ebccf1e3SJoseph Koshytunable 417d9a5f346SJoseph Koshy.Va security.bsd.unprivileged_syspmcs 418ebccf1e3SJoseph Koshyto 0. 419ebccf1e3SJoseph KoshyThis ensures that unprivileged processes cannot allocate system-wide 420ebccf1e3SJoseph KoshyPMCs and thus cannot observe the hardware behavior of the system 421ebccf1e3SJoseph Koshyas a whole. 422ebccf1e3SJoseph KoshyThis tunable may also be set at boot time using 423ebccf1e3SJoseph Koshy.Xr loader 8 , 424ebccf1e3SJoseph Koshyor with 425ebccf1e3SJoseph Koshy.Xr kenv 1 426ebccf1e3SJoseph Koshyprior to loading the 427ebccf1e3SJoseph Koshy.Nm 428ebccf1e3SJoseph Koshydriver into the kernel. 429ebccf1e3SJoseph Koshy.It 430ebccf1e3SJoseph KoshySet the 431ebccf1e3SJoseph Koshy.Xr sysctl 8 432ebccf1e3SJoseph Koshytunable 433d9a5f346SJoseph Koshy.Va security.bsd.unprivileged_proc_debug 434ebccf1e3SJoseph Koshyto 0. 435ebccf1e3SJoseph KoshyThis will ensure that an unprivileged process cannot attach a PMC 436ebccf1e3SJoseph Koshyto any process other than itself and thus cannot observe the hardware 437ebccf1e3SJoseph Koshybehavior of other processes with the same credentials. 438ebccf1e3SJoseph Koshy.El 439ebccf1e3SJoseph Koshy.Pp 440ebccf1e3SJoseph KoshySystem administrators should note that on IA-32 platforms 441ebccf1e3SJoseph Koshy.Fx 442ebccf1e3SJoseph Koshymakes the content of the IA-32 TSC counter available to all processes 443ebccf1e3SJoseph Koshyvia the RDTSC instruction. 444ebccf1e3SJoseph Koshy.Sh IMPLEMENTATION NOTES 445f263522aSJoseph Koshy.Ss SMP Symmetry 446f263522aSJoseph KoshyThe kernel driver requires all physical CPUs in an SMP system to have 447f263522aSJoseph Koshyidentical performance monitoring counter hardware. 448ebccf1e3SJoseph Koshy.Ss i386 TSC Handling 449ebccf1e3SJoseph KoshyHistorically, on the x86 architecture, 450ebccf1e3SJoseph Koshy.Fx 451ebccf1e3SJoseph Koshyhas permitted user processes running at a processor CPL of 3 to 452ebccf1e3SJoseph Koshyread the TSC using the RDTSC instruction. 453ebccf1e3SJoseph KoshyThe 454ebccf1e3SJoseph Koshy.Nm 455d9a5f346SJoseph Koshydriver preserves this semantics. 456ebccf1e3SJoseph Koshy.Ss Intel P4/HTT Handling 457ebccf1e3SJoseph KoshyOn CPUs with HTT support, Intel P4 PMCs are capable of qualifying 458ebccf1e3SJoseph Koshyonly a subset of hardware events on a per-logical CPU basis. 459ebccf1e3SJoseph KoshyConsequently, if HTT is enabled on a system with Intel Pentium P4 460ebccf1e3SJoseph KoshyPMCs, then the 461ebccf1e3SJoseph Koshy.Nm 462ebccf1e3SJoseph Koshydriver will reject allocation requests for process-private PMCs that 463ebccf1e3SJoseph Koshyrequest counting of hardware events that cannot be counted separately 464ebccf1e3SJoseph Koshyfor each logical CPU. 465f263522aSJoseph Koshy.Ss Intel Pentium-Pro Handling 466f263522aSJoseph KoshyWriting a value to the PMC MSRs found ing Intel Pentium-Pro style PMCs 467f263522aSJoseph Koshy(found in 468f263522aSJoseph Koshy.Tn "Intel Pentium Pro" , 469f263522aSJoseph Koshy.Tn "Pentium II" , 470f263522aSJoseph Koshy.Tn "Pentium III" , 471f263522aSJoseph Koshy.Tn "Pentium M" 472f263522aSJoseph Koshyand 473f263522aSJoseph Koshy.Tn "Celeron" 474f263522aSJoseph Koshyprocessors) will replicate bit 31 of the 475f263522aSJoseph Koshyvalue being written into the upper 8 bits of the MSR, 476f263522aSJoseph Koshybringing down the usable width of these PMCs to 31 bits. 477f263522aSJoseph KoshyFor process-virtual PMCs, the 478f263522aSJoseph Koshy.Nm 479f263522aSJoseph Koshydriver implements a workaround in software and makes the corrected 64 480f263522aSJoseph Koshybit count available via the 481d9a5f346SJoseph Koshy.Dv PMC_OP_RW 482f263522aSJoseph Koshyoperation. 483f263522aSJoseph KoshyProcesses that intend to use RDPMC instructions directly or 484f263522aSJoseph Koshythat intend to write values larger than 2^31 into these PMCs with 485d9a5f346SJoseph Koshy.Dv PMC_OP_RW 486f263522aSJoseph Koshyneed to be aware of this hardware limitation. 487f263522aSJoseph Koshy.Sh DIAGNOSTICS 488f263522aSJoseph Koshy.Bl -diag 489d9a5f346SJoseph Koshy.It "hwpmc: tunable hashsize=%d must be greater than zero." 490f263522aSJoseph KoshyA negative value was supplied for tunable 491f263522aSJoseph Koshy.Va kern.hwpmc.hashsize . 492d9a5f346SJoseph Koshy.It "hwpmc: tunable logbuffersize=%d must be greater than zero." 493f263522aSJoseph KoshyA negative value was supplied for tunable 494f263522aSJoseph Koshy.Va kern.hwpmc.logbuffersize . 495d9a5f346SJoseph Koshy.It "hwpmc: tunable nlogbuffers=%d must be greater than zero." 496f263522aSJoseph KoshyA negative value was supplied for tunable 497f263522aSJoseph Koshy.Va kern.hwpmc.nlogbuffers . 498d9a5f346SJoseph Koshy.It "hwpmc: tunable nsamples=%d out of range." 499f263522aSJoseph KoshyThe value for tunable 500f263522aSJoseph Koshy.Va kern.hwpmc.nsamples 501f263522aSJoseph Koshywas negative or greater than 65535. 502f263522aSJoseph Koshy.El 503ebccf1e3SJoseph Koshy.Sh ERRORS 504d9a5f346SJoseph KoshyA command issued to the 505ebccf1e3SJoseph Koshy.Nm 506ebccf1e3SJoseph Koshydriver may fail with the following errors: 507ebccf1e3SJoseph Koshy.Bl -tag -width Er 508ebccf1e3SJoseph Koshy.It Bq Er EBUSY 509d9a5f346SJoseph KoshyA 510d9a5f346SJoseph Koshy.Dv PMC_OP_CONFIGURELOG 511ebccf1e3SJoseph Koshyoperation was requested while an existing log was active. 512ebccf1e3SJoseph Koshy.It Bq Er EBUSY 513d9a5f346SJoseph KoshyA DISABLE operation was requested using the 514d9a5f346SJoseph Koshy.Dv PMC_OP_PMCADMIN 515ebccf1e3SJoseph Koshyrequest for a set of hardware resources currently in use for 516ebccf1e3SJoseph Koshyprocess-private PMCs. 517ebccf1e3SJoseph Koshy.It Bq Er EBUSY 518ebccf1e3SJoseph KoshyA 519d9a5f346SJoseph Koshy.Dv PMC_OP_PMCADMIN 520ebccf1e3SJoseph Koshyoperation was requested on an active system mode PMC. 521ebccf1e3SJoseph Koshy.It Bq Er EBUSY 522ebccf1e3SJoseph KoshyA 523d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 524ebccf1e3SJoseph Koshyoperation was requested for a target process that already had another 525ebccf1e3SJoseph KoshyPMC using the same hardware resources attached to it. 526ebccf1e3SJoseph Koshy.It Bq Er EBUSY 527d9a5f346SJoseph KoshyA 528d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 529ebccf1e3SJoseph Koshyrequest writing a new value was issued on a PMC that was active. 5303bc6c674SJoseph Koshy.It Bq Er EDOOFUS 5313bc6c674SJoseph KoshyA 532d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSTART 5333bc6c674SJoseph Koshyoperation was requested without a log file being configured for a 5343bc6c674SJoseph KoshyPMC allocated with 5353bc6c674SJoseph Koshy.Dv PMC_F_LOG_PROCCSW 5363bc6c674SJoseph Koshyand 5373bc6c674SJoseph Koshy.Dv PMC_F_LOG_PROCEXIT 5383bc6c674SJoseph Koshymodifiers. 539ebccf1e3SJoseph Koshy.It Bq Er EBUSY 540d9a5f346SJoseph KoshyA 541d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSETCOUNT 542ebccf1e3SJoseph Koshyrequest was issued on a PMC that was active. 543ebccf1e3SJoseph Koshy.It Bq Er EEXIST 544ebccf1e3SJoseph KoshyA 545d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 546ebccf1e3SJoseph Koshyrequest was reissued for a target process that already is the target 547ebccf1e3SJoseph Koshyof this PMC. 548ebccf1e3SJoseph Koshy.It Bq Er EFAULT 549ebccf1e3SJoseph KoshyA bad address was passed in to the driver. 550ebccf1e3SJoseph Koshy.It Bq Er EINVAL 551ebccf1e3SJoseph KoshyA process specified an invalid PMC handle. 552ebccf1e3SJoseph Koshy.It Bq Er EINVAL 553d9a5f346SJoseph KoshyAn invalid CPU number was passed in for a 554d9a5f346SJoseph Koshy.Dv PMC_OP_GETPMCINFO 555ebccf1e3SJoseph Koshyoperation. 556ebccf1e3SJoseph Koshy.It Bq Er EINVAL 557d9a5f346SJoseph KoshyAn invalid CPU number was passed in for a 558d9a5f346SJoseph Koshy.Dv PMC_OP_PMCADMIN 559ebccf1e3SJoseph Koshyoperation. 560ebccf1e3SJoseph Koshy.It Bq Er EINVAL 561d9a5f346SJoseph KoshyAn invalid operation request was passed in for a 562d9a5f346SJoseph Koshy.Dv PMC_OP_PMCADMIN 563ebccf1e3SJoseph Koshyoperation. 564ebccf1e3SJoseph Koshy.It Bq Er EINVAL 565d9a5f346SJoseph KoshyAn invalid PMC ID was passed in for a 566d9a5f346SJoseph Koshy.Dv PMC_OP_PMCADMIN 567ebccf1e3SJoseph Koshyoperation. 568ebccf1e3SJoseph Koshy.It Bq Er EINVAL 569ebccf1e3SJoseph KoshyA suitable PMC matching the parameters passed in to a 570d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 571ebccf1e3SJoseph Koshyrequest could not be allocated. 572ebccf1e3SJoseph Koshy.It Bq Er EINVAL 573ebccf1e3SJoseph KoshyAn invalid PMC mode was requested during a 574d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 575ebccf1e3SJoseph Koshyrequest. 576ebccf1e3SJoseph Koshy.It Bq Er EINVAL 577ebccf1e3SJoseph KoshyAn invalid CPU number was specified during a 578d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 579ebccf1e3SJoseph Koshyrequest. 580ebccf1e3SJoseph Koshy.It Bq Er EINVAL 581d9a5f346SJoseph KoshyA CPU other than 582d9a5f346SJoseph Koshy.Dv PMC_CPU_ANY 583ebccf1e3SJoseph Koshywas specified in a 584d9a5f346SJoseph Koshy.Dv PMC_OP_ALLOCATE 585ebccf1e3SJoseph Koshyrequest for a process-private PMC. 586ebccf1e3SJoseph Koshy.It Bq Er EINVAL 587d9a5f346SJoseph KoshyA CPU number of 588d9a5f346SJoseph Koshy.Dv PMC_CPU_ANY 589ebccf1e3SJoseph Koshywas specified in a 590d9a5f346SJoseph Koshy.Dv PMC_OP_ALLOCATE 591ebccf1e3SJoseph Koshyrequest for a system-wide PMC. 592ebccf1e3SJoseph Koshy.It Bq Er EINVAL 593ebccf1e3SJoseph KoshyThe 594ebccf1e3SJoseph Koshy.Ar pm_flags 595ebccf1e3SJoseph Koshyargument to an 596d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE 597ebccf1e3SJoseph Koshyrequest contained unknown flags. 598ebccf1e3SJoseph Koshy.It Bq Er EINVAL 599ebccf1e3SJoseph KoshyA PMC allocated for system-wide operation was specified with a 600d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 601ebccf1e3SJoseph Koshyrequest. 602ebccf1e3SJoseph Koshy.It Bq Er EINVAL 603ebccf1e3SJoseph KoshyThe 604ebccf1e3SJoseph Koshy.Ar pm_pid 605ebccf1e3SJoseph Koshyargument to a 606d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 607d9a5f346SJoseph Koshyrequest specified an illegal process ID. 608ebccf1e3SJoseph Koshy.It Bq Er EINVAL 609ebccf1e3SJoseph KoshyA 610d9a5f346SJoseph Koshy.Dv PMC_OP_PMCDETACH 611ebccf1e3SJoseph Koshyrequest was issued for a PMC not attached to the target process. 612ebccf1e3SJoseph Koshy.It Bq Er EINVAL 613ebccf1e3SJoseph KoshyArgument 614ebccf1e3SJoseph Koshy.Ar pm_flags 615ebccf1e3SJoseph Koshyto a 616d9a5f346SJoseph Koshy.Dv PMC_OP_PMCRW 617ebccf1e3SJoseph Koshyrequest contained illegal flags. 618ebccf1e3SJoseph Koshy.It Bq Er EINVAL 619ebccf1e3SJoseph KoshyA 620d9a5f346SJoseph Koshy.Dv PMC_OP_PMCX86GETMSR 621c5153e19SJoseph Koshyoperation was requested for a PMC not in process-virtual mode, or 622c5153e19SJoseph Koshyfor a PMC that is not solely attached to its owner process, or for 623c5153e19SJoseph Koshya PMC that was allocated with flag 624d9a5f346SJoseph Koshy.Dv PMC_F_DESCENDANTS . 625ebccf1e3SJoseph Koshy.It Bq Er EINVAL 626d9a5f346SJoseph Koshy(On Intel Pentium 4 CPUs with HTT support) 627d9a5f346SJoseph KoshyAn allocation request for 628ebccf1e3SJoseph Koshya process-private PMC was issued for an event that does not support 629ebccf1e3SJoseph Koshycounting on a per-logical CPU basis. 630ebccf1e3SJoseph Koshy.It Bq Er ENOMEM 631ebccf1e3SJoseph KoshyThe system was not able to allocate kernel memory. 632ebccf1e3SJoseph Koshy.It Bq Er ENOSYS 633d9a5f346SJoseph Koshy(i386 architectures) 634d9a5f346SJoseph KoshyA 635d9a5f346SJoseph Koshy.Dv PMC_OP_PMCX86GETMSR 636ebccf1e3SJoseph Koshyoperation was requested for hardware that does not support reading 637ebccf1e3SJoseph KoshyPMCs directly with the RDPMC instruction. 638ebccf1e3SJoseph Koshy.It Bq Er ENXIO 639d9a5f346SJoseph KoshyA 640d9a5f346SJoseph Koshy.Dv PMC_OP_GETPMCINFO 641ebccf1e3SJoseph Koshyoperation was requested for a disabled CPU. 642ebccf1e3SJoseph Koshy.It Bq Er ENXIO 643ebccf1e3SJoseph KoshyA system-wide PMC on a disabled CPU was requested to be allocated with 644d9a5f346SJoseph Koshy.Dv PMC_OP_PMCALLOCATE . 645ebccf1e3SJoseph Koshy.It Bq Er ENXIO 646ebccf1e3SJoseph KoshyA 647d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSTART 648ebccf1e3SJoseph Koshyor 649d9a5f346SJoseph Koshy.Dv PMC_OP_PMCSTOP 650ebccf1e3SJoseph Koshyrequest was issued for a system-wide PMC that was allocated on a 651ebccf1e3SJoseph Koshycurrently disabled CPU. 652ebccf1e3SJoseph Koshy.It Bq Er EPERM 653d9a5f346SJoseph KoshyA 654d9a5f346SJoseph Koshy.Dv PMC_OP_PMCADMIN 655ebccf1e3SJoseph Koshyrequest was issued by a process without super-user 656ebccf1e3SJoseph Koshyprivilege or by a jailed super-user process. 657ebccf1e3SJoseph Koshy.It Bq Er EPERM 658d9a5f346SJoseph KoshyA 659d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 660ebccf1e3SJoseph Koshyoperation was issued for a target process that the current process 661ebccf1e3SJoseph Koshydoes not have permission to attach to. 662c5153e19SJoseph Koshy.It Bq Er EPERM 663d9a5f346SJoseph Koshy(i386 and amd64 architectures) 664d9a5f346SJoseph KoshyA 665d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 666c5153e19SJoseph Koshyoperation was issued on a PMC whose MSR has been retrieved using 667d9a5f346SJoseph Koshy.Dv PMC_OP_PMCX86GETMSR . 668ebccf1e3SJoseph Koshy.It Bq Er ESRCH 669f263522aSJoseph KoshyA process issued a PMC operation request without having allocated any 670f263522aSJoseph KoshyPMCs. 671f263522aSJoseph Koshy.It Bq Er ESRCH 672f263522aSJoseph KoshyA process issued a PMC operation request after the PMC was detached 673f263522aSJoseph Koshyfrom all of its target processes. 674ebccf1e3SJoseph Koshy.It Bq Er ESRCH 675ebccf1e3SJoseph KoshyA 676d9a5f346SJoseph Koshy.Dv PMC_OP_PMCATTACH 677d9a5f346SJoseph Koshyrequest specified a non-existent process ID. 678ebccf1e3SJoseph Koshy.It Bq Er ESRCH 679ebccf1e3SJoseph KoshyThe target process for a 680d9a5f346SJoseph Koshy.Dv PMC_OP_PMCDETACH 681ebccf1e3SJoseph Koshyoperation is not being monitored by the 682ebccf1e3SJoseph Koshy.Nm 683ebccf1e3SJoseph Koshydriver. 684ebccf1e3SJoseph Koshy.El 685ebccf1e3SJoseph Koshy.Sh SEE ALSO 686ebccf1e3SJoseph Koshy.Xr kenv 1 , 687ebccf1e3SJoseph Koshy.Xr pmc 3 , 688f263522aSJoseph Koshy.Xr kgmon 8 , 689ebccf1e3SJoseph Koshy.Xr kldload 8 , 690ebccf1e3SJoseph Koshy.Xr pmccontrol 8 , 691ebccf1e3SJoseph Koshy.Xr pmcstat 8 , 692ebccf1e3SJoseph Koshy.Xr sysctl 8 , 693ebccf1e3SJoseph Koshy.Xr p_candebug 9 694d9a5f346SJoseph Koshy.Sh BUGS 695d9a5f346SJoseph KoshyThe driver samples the state of the kernel's logical processor support 696d9a5f346SJoseph Koshyat the time of initialization (i.e., at module load time). 697d9a5f346SJoseph KoshyOn CPUs supporting logical processors, the driver could misbehave if 698d9a5f346SJoseph Koshylogical processors are subsequently enabled or disabled while the 699d9a5f346SJoseph Koshydriver is active. 700