Accessing PMU registers from user applications
You cannot access Performance Monitoring Unit (PMU) registers from user applications (user-mode) when a system starts, from another PMU-based profiler, or from Live Partition Mobility (LPM) with libpmapi pragmas.
A libpmapi pragma is a light-weight subroutine that is exported through the libpmapi library, which provides access to the PMU registers. A libpmapi pragma uses the mtspr and mfspr instructions instead of the pmsvcs kernel extension to avoid system calls.
The following libpmapi pragmas are included in the AIX®
operating system:
- mmcr_read Subroutine
- mmcr_write Subroutine
- pmc_read_1to4 Subroutine
- pmc_read_5to6 Subroutine
- pmc_write Subroutine
In the following scenarios, if you use the libpmapi pragmas for read and write access to the PMU
registers,
-1 is returned, which indicates that the option is not available.
Therefore, you cannot access the PMU registers from a user application in the following scenarios: - When a system
starts
MMCR0[PMCC] is set to 00 PMCs 1-6, MMCR0, MMCRA and MMCR2 registers are read only. Access using pmc_read_1to4 , pmc_read_5to6 and mmcr_read returns 0 Access using pmc_write and mmcr_write returns -1 - Another PMU-based profiler is
used
MMCR0[PMCC] is set to 00 PMCs 1-6, MMCR0, MMCRA and MMCR2 registers are read only. Access using pmc_read_1to4 , pmc_read_5to6 and mmcr_read returns 0 Access using pmc_write and mmcr_write returns -1 - During
LPM
Prior to the Mobility operation, any running PMU counting is stopped and MMCR0[PMCC] is set to 00. Post Mobility operation, PMCs 1-6, MMCR0, MMCRA and MMCR2 registers are read only. Access using pmc_read_1to4 , pmc_read_5to6 and mmcr_read returns 0 Access using pmc_write and mmcr_write returns -1
Instead of using the libpmapi pragmas, if you use the mtspr and the mfspr instructions to access the PMU registers, a SIGILL signal is generated for any write operations.
Sample programs are located in the /usr/samples/pmapi directory.