hwpmc(4) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

hwpmc(4)

Additionally,  for i386 systems: The driver virtualizes the hard‐
ware performance monitoring facilities in modern  CPUs  and  pro‐
vides   support  for  using  these  facilities  from  user  level
processes.  The driver supports  multi-processor  systems.   PMCs
are  allocated  using the request.  A successful request will re‐
turn a handle to the requesting process.   Subsequent  operations
on  the allocated PMC use this handle to denote the specific PMC.
A process that has successfully allocated a PMC is termed an PMCs
may be allocated with process or system scope.  The PMC is active
only when a thread belonging to a process it is  attached  to  is
scheduled  on a CPU.  The PMC operates independently of processes
and measures hardware events for the system as a whole.  PMCs may
be allocated for counting or for sampling: In counting modes, the
PMCs count hardware events.  These counts are  retrievable  using
the  system  call on all architectures.  Some architectures offer
faster methods of reading these counts.  In sampling  modes,  the
PMCs  are  configured  to sample the CPU instruction pointer (and
optionally to capture the call chain leading up  to  the  sampled
instruction  pointer)  after  a  configurable  number of hardware
events have been observed.  Instruction pointer samples and  call
chain  records  are usually directed to a log file for subsequent
analysis.  Scope and operational mode are orthogonal; a  PMC  may
thus be configured to operate in one of the following four modes:
These  PMCs  count hardware events whenever a thread in their at‐
tached process is scheduled on a CPU.  These PMCs normally  count
from  zero, but the initial count may be set using the operation.
Applications can read the value of the PMC anytime using the  op‐
eration.   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  sam‐
pling  is set using the operation prior to starting the PMC.  Log
files are configured using the operation.  These PMCs count hard‐
ware events seen by them independent of the  processes  that  are
executing.  The current count on these PMCs can be read using the
request.   These  PMCs  normally count from zero, but the initial
count may be set using the operation.  These PMCs  will  periodi‐
cally  sample  the  instruction pointer of the CPU they are allo‐
cated on, and will write the sample to a log for further process‐
ing.  The desired frequency of sampling is set using  the  opera‐
tion  prior  to starting the PMC.  Log files are configured using
the operation.  System-wide statistical sampling can only be  en‐
abled by a process with super-user privileges.  Processes are al‐
lowed  to allocate as many PMCs as the hardware and current oper‐
ating conditions permit.  Processes may mix allocations  of  sys‐
tem-wide and process-private PMCs.  Multiple processes may be us‐
ing  PMCs  simultaneously.   Allocated PMCs are started using the
operation, and stopped using the operation.  Stopping and  start‐
ing  a PMC is permitted at any time the owner process has a valid
handle to the PMC.  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 operation.  An already attached PMC may  be
detached  from  its  target process using the converse operation.
Issuing a 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:  A  non-jailed process with super-user privileges is al‐
lowed to attach to  any  other  process  in  the  system.   Other
processes  are  only allowed to attach to targets that they would
be able to attach to for debugging (as determined by PMCs are re‐
leased using After a successful operation the handle to  the  PMC
will  become invalid.  The operation supports the following flags
that modify the behavior of an allocated PMC: This  modifier  in‐
forms  sampling  PMCs to record a callchain when capturing a sam‐
ple.  The maximum depth to which  call  chains  are  recorded  is
specified by the kernel tunable.  This modifier is valid only for
a PMC being allocated in process-private mode.  It signifies that
the PMC will track hardware events for its target process and the
target's  current and future descendants.  This modifier is valid
only for a PMC being allocated in system-wide sampling mode.   It
signifies  that  the  PMC's  sampling  interrupt is to be used to
drive kernel profiling via This functionality is currently  unim‐
plemented.  This modifier is valid only for a PMC being allocated
in process-private mode.  When this modifier is present, at every
context  switch, will log a record containing the number of hard‐
ware events seen by the target process when it was  scheduled  on
the  CPU.   This modifier is valid only for a PMC being allocated
in process-private mode.  With this modifier present, will  main‐
tain  per-process  counts  for  each target process attached to a
PMC.  At process  exit  time,  a  record  containing  the  target
process'  PID  and  the  accumulated  per-process  count for that
process will be written to the configured  log  file.   Modifiers
and  may be used in combination with modifier to track the behav‐
ior of complex pipelines of processes.  PMCs with  modifiers  and
cannot  be started until their owner process has configured a log
file.  The driver may deliver signals to processes that have  al‐
located  PMCs: A operation was attempted on a process-private PMC
that does not have attached target processes.  The driver is  be‐
ing unloaded from the kernel.  A PMC row is defined as the set of
PMC  resources at the same hardware address in the CPUs in a sys‐
tem.  Since process scope PMCs need to move between CPUs  follow‐
ing  their  target threads, allocation of a process scope PMC re‐
serves all PMCs in a PMC row for  use  only  with  process  scope
PMCs.  Accordingly a PMC row will be in one of the following dis‐
positions:  Hardware counters in this row are free and may be use
to satisfy either of system scope or process scope allocation re‐
quests.  Hardware counters in this row  are  in  use  by  process
scope  PMCs  and  are only available for process scope allocation
requests.  Some hardware counters in this row have been  adminis‐
tratively  disabled or are in use by system scope PMCs.  Non-dis‐
abled hardware counters in such a row may be used for  satisfying
system scope allocation requests.  No process scope PMCs will use
hardware  counters in this row.  The recommended way for applica‐
tion programs to use the facilities of the driver  is  using  the
API  provided by the library.  The driver operates using a system
call number that is dynamically allotted to it when it is  loaded
into  the  kernel.  The driver supports the following operations:
Configure a log file for PMCs that require a log file.  The  dri‐
ver  will  write log data to this file asynchronously.  If it en‐
counters an error, logging will be stopped and the error code en‐
countered will be saved for subsequent retrieval  by  a  request.
Transfer  buffered  log  data inside to a configured output file.
This operation returns to the caller after  the  write  operation
has returned.  The returned error code reflects any pending error
state  inside Retrieve information about the highest possible CPU
number for the system, and the  number  of  hardware  performance
monitoring  counters  available per CPU.  Retrieve module statis‐
tics (for analyzing the behavior of itself).  Retrieve  the  ver‐
sion number of API.  Retrieve information about the current state
of  the PMCs on a given CPU.  Set the administrative state (i.e.,
whether enabled or disabled) for the hardware PMCs managed by the
driver.  The invoking process needs  to  possess  the  privilege.
Allocate and configure a PMC.  On successful allocation, a handle
to  the  PMC (a 32 bit value) is returned.  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 flag
had been specified at PMC allocation time, then the  PMC  is  at‐
tached  to  all  current  and  future  descendants  of the target
process.  Detach a PMC from its target process.  Release  a  PMC.
Read and write a PMC.  This operation is valid only for PMCs con‐
figured  in  counting modes.  Set the initial count (for counting
mode PMCs) or the desired sampling rate (for sampling mode PMCs).
Start a PMC.  Stop a PMC.  Insert a timestamped user record  into
the  log  file.  Some i386 family CPUs support the RDPMC instruc‐
tion which allows a user process to  read  a  PMC  value  without
needing to invoke a operation.  On such CPUs, the machine address
associated  with an allocated PMC is retrievable using the system
call.  Retrieve the MSR (machine specific register) number  asso‐
ciated  with  the  given  PMC  handle.   The  PMC  needs to be in
process-private mode and allocated without the modifier flag, and
should be attached only to its owner process at the time  of  the
call.   AMD64  CPUs  support the RDPMC instruction which allows a
user process to read a PMC value without needing to invoke a  op‐
eration.  The machine address associated with an allocated PMC is
retrievable  using  the  system  call.  Retrieve the MSR (machine
specific register) number associated with the given  PMC  handle.
The PMC needs to be in process-private mode and allocated without
the  modifier  flag,  and  should  be  attached only to its owner
process at the time of the call.  The behavior of  is  influenced
by  the  following and tunables: The maximum number of call chain
records to capture per sample.  The default is 8.   (Only  avail‐
able if the driver was compiled with Control the verbosity of de‐
bug messages from the driver.  The number of rows in the hash ta‐
bles  used  to keep track of owner and target processes.  The de‐
fault is 16.  The size in kilobytes of each log  buffer  used  by
logging  function.   The default buffer size is 4KB.  The size of
the spin mutex pool used by the PMC driver.  The default  is  32.
The  number  of  log buffers used by for logging.  The default is
64.  The number of entries in the per-CPU ring buffer used during
sampling.  The default is 512.  If set to non-zero, allow unpriv‐
ileged processes to allocate system-wide PMCs.  The default value
is 0.  If set  to  0,  the  driver  will  only  allow  privileged
processes to attach PMCs to other processes.  These variables may
be  set  in  the  kernel environment using before is loaded.  The
kernel driver requires all physical CPUs in an SMP system to have
identical performance monitoring counter hardware.  On  platforms
that sparsely number CPUs and which support hot-plugging of CPUs,
requests  that  specify  non-existent  or disabled CPUs will fail
with an error.  Applications allocating system-scope PMCs need to
be aware of the possibility of such transient failures.  Histori‐
cally, on the x86 architecture, has permitted user processes run‐
ning at a processor CPL of 3 to read the TSC using the RDTSC  in‐
struction.  The driver preserves this behavior.  On CPUs with HTT
support, Intel P4 PMCs are capable of qualifying only a subset of
hardware events on a per-logical CPU basis.  Consequently, if HTT
is  enabled on a system with Intel Pentium P4 PMCs, then the dri‐
ver will reject allocation requests for process-private PMCs that
request counting of hardware events that cannot be counted  sepa‐
rately  for  each  logical  CPU.  Writing a value to the PMC MSRs
found in Intel Pentium-Pro style PMCs (found in  and  processors)
will replicate bit 31 of the value being written into the upper 8
bits  of the MSR, bringing down the usable width of these PMCs to
31 bits.  For  process-virtual  PMCs,  the  driver  implements  a
workaround  in  software  and  makes  the  corrected 64 bit count
available via the operation.  Processes that intend to use  RDPMC
instructions  directly or that intend to write values larger than
2^31 into these PMCs with need to be aware of this hardware limi‐
tation.  Announce the presence of PMCs of class with capabilities
described by bit string The module loading process failed because
a version mismatch was detected between the  currently  executing
kernel  and  the module being loaded.  The module loading process
failed because the currently executing kernel was not  configured
with  the required configuration option A negative value was sup‐
plied for tunable A negative value was  supplied  for  tunable  A
negative value was supplied for tunable The value for tunable was
negative  or  greater  than 65535.  The driver is The API and ABI
documented in this manual page may change  in  the  future.   The
recommended  method of accessing this driver is using the API.  A
command issued to the driver may fail with the following  errors:
Helper  process  creation failed for a request due to a temporary
resource shortage in the kernel.  A operation was requested while
an existing log was active.  A DISABLE  operation  was  requested
using  the  request  for a set of hardware resources currently in
use for process-private PMCs.  A operation was  requested  on  an
active  system  mode PMC.  A operation was requested for a target
process that already had another PMC using the same hardware  re‐
sources attached to it.  A request writing a new value was issued
on a PMC that was active.  A request was issued on a PMC that was
active.   A operation was requested without a log file being con‐
figured for a PMC allocated with and modifiers.  A operation  was
requested  on a system-wide sampling PMC without a log file being
configured.  A request was reissued for a target process that al‐
ready is the target of this PMC.  A bad address was passed in  to
the driver.  An invalid PMC handle was specified.  An invalid CPU
number  was passed in for a operation.  A request to de-configure
a log file was issued without a log file being configured.  A re‐
quest was issued without a log file being configured.  An invalid
CPU number was passed in for a operation.  An  invalid  operation
request  was  passed  in  for a operation.  An invalid PMC ID was
passed in for a operation.  A suitable PMC matching  the  parame‐
ters  passed  in to a request could not be allocated.  An invalid
PMC mode was requested during a request.  An invalid  CPU  number
was  specified  during a request.  A CPU other than was specified
in a request for a process-private PMC.   A  CPU  number  of  was
specified in a request for a system-wide PMC.  The argument to an
request  contained  unknown flags.  (On Intel Pentium 4 CPUs with
HTT support) A request for a process-private PMC was  issued  for
an  event that does not support counting on a per-logical CPU ba‐
sis.  A PMC allocated for  system-wide  operation  was  specified
with a or request.  The argument to a or request specified an il‐
legal process ID.  A request was issued for a PMC not attached to
the  target  process.   Argument  to  a request contained illegal
flags.  A operation was requested for a PMC not  in  process-vir‐
tual  mode, or for a PMC that is not solely attached to its owner
process, or for a PMC that was allocated with flag A request  was
issued  for  an owner process without a log file configured.  The
system was not able to allocate  kernel  memory.   (On  i386  and
amd64  architectures) A operation was requested for hardware that
does not support reading PMCs directly with  the  RDPMC  instruc‐
tion.   A  operation was requested for an absent or disabled CPU.
A operation specified allocation of a system-wide PMC on  an  ab‐
sent  or disabled CPU.  A or request was issued for a system-wide
PMC that was allocated on a CPU that is currently absent or  dis‐
abled.   A  request was issued for PMC capabilities not supported
by the specified PMC class.  (i386 architectures) A sampling mode
PMC was requested on a CPU lacking an APIC.  A request was issued
by a process without super-user privilege or by a  jailed  super-
user  process.   A operation was issued for a target process that
the current process does not have permission to attach to.  (i386
and amd64 architectures) A operation was issued on  a  PMC  whose
MSR has been retrieved using A process issued a PMC operation re‐
quest  without having allocated any PMCs.  A process issued a PMC
operation request after the PMC was detached from all of its tar‐
get processes.  A or request specified a non-existent process ID.
The target process for a operation is not being monitored by  The
driver  first  appeared  in  The driver was written by The driver
samples the state of the kernel's logical  processor  support  at
the  time of initialization (i.e., at module load time).  On CPUs
supporting logical processors, the driver could misbehave if log‐
ical processors are subsequently enabled or  disabled  while  the
driver  is active.  On the i386 architecture, the driver requires
that the local APIC on the CPU be enabled for sampling mode to be
supported.  Many single-processor motherboards keep the APIC dis‐
abled in BIOS; on such systems will not  support  sampling  PMCs.
PMCs  may be used to monitor the actual behavior of the system on
hardware.  In situations where this  constitutes  an  undesirable
information  leak,  the  following options are available: Set the
tunable to 0.  This ensures that  unprivileged  processes  cannot
allocate  system-wide  PMCs  and thus cannot observe the hardware
behavior of the system as a whole.  This tunable may also be  set
at  boot  time using or with prior to loading the driver into the
kernel.  Set the tunable to 0.  This will ensure that an unprivi‐
leged process cannot attach a PMC to any process other  than  it‐
self  and  thus  cannot  observe  the  hardware behavior of other
processes  with  the  same  credentials.   System  administrators
should  note  that  on  IA-32  platforms makes the content of the
IA-32 TSC counter available to all processes via  the  RDTSC  in‐
struction.




















































맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3