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