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