[AIX 성능 도구 4] 하드웨어 성능 모니터와 pmapi 라이브러리

핵심 정리

  • bos.pmapi 파일 세트는 POWER 프로세서의 하드웨어 성능 모니터(PM) 카운터를 읽는 도구입니다. 저수준 API인 pmapi 라이브러리, 고수준 API인 hpm 라이브러리, 명령 pmcycles(클록 속도), pmlist(지원 이벤트·그룹), hpmstat(시스템 전체), hpmcount(프로그램 하나)가 들어 있습니다.
  • 이벤트에는 검증 상태(verified, caveat, unverified 등)가 있고, unverified 이벤트는 정확도가 보장되지 않습니다. pm_initialize에 필터를 주어야 이벤트 목록이 돌아옵니다.
  • 집계 단위: 시스템 전체(root만, 프로세스 트리 옵션 가능), 스레드 자신(1st party), 디버거가 대상 스레드(3rd party), 공통 조상에서 만든 스레드 집계 그룹. 시스템 수준과 스레드 수준 API는 동시에 쓸 수 없습니다.
  • 기본 호출 흐름: pm_initialize → pm_set_program → pm_start → 작업 → pm_stop → pm_get_data → pm_delete_program. 성공하면 0, 실패하면 양수 오류 코드(pm_error로 해석).
  • 카운터보다 많은 이벤트는 다중화 모드(_mx, 집합마다 10ms~30s, 기본 100ms)로 돌아가며 셉니다. (6.1) 집합마다 모드를 다르게 주는 다중 모드(_mm), 전역 WPAR에서 WPAR 하나를 세는 _wp 호출이 더해졌습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1에서 성능 모니터링 에이전트, POWERCOMPAT 이벤트, 카운터 다중 모드, WPAR 집계와 예제가 더해짐)
원문 Performance Tools Guide and Reference — 5.3판 5장(123133쪽), 6.1판 5079쪽
파일 세트 bos.pmapi (pmapi 라이브러리, pmcycles, pmlist, hpm 라이브러리, hpmcount, hpmstat)
헤더·예제 /usr/include/pmapi.h, /usr/samples/pmapi
관련 명령어 pmcycles, pmlist, hpmcount, hpmstat, tprof

bos.pmapi 파일 세트에는 일부 IBM 마이크로프로세서에 들어 있는 성능 모니터(Performance Monitor) 기능의 집계(counting) 기능을 쓸 수 있게 하는 라이브러리와 도구가 들어 있습니다.

들어 있는 것은 다음과 같습니다.

  • pmapi 라이브러리: 저수준 응용 프로그래밍 인터페이스(API) 모음입니다.
    • 시스템 전체나 공통 조상을 가진 프로세스 집합의 활동을 세는 시스템 수준 API
    • 스레드가 자기 활동을 세는 1st party 커널 스레드 수준 API
    • 디버그 프로그램이 대상 스레드의 활동을 세는 3rd party 커널 스레드 수준 API
  • pmcycles 명령: 프로세서 클록 속도와 감소기(decrementer) 속도를 돌려줍니다.
  • pmlist 명령: 지원하는 프로세서, 이벤트, 이벤트 그룹과 집합, 파생 지표(derived metrics) 정보를 보여 줍니다.
  • hpm과 hpm_r 라이브러리: 다음을 할 수 있는 고수준 API 모음입니다.
    • 코드 구간의 중첩 계측
    • 하드웨어 카운터 원래 값에 더해 파생 지표의 자동 계산과 운영 체제 자원 사용 지표 수집
  • hpmstat 명령: 시스템 전체 활동에 관한 하드웨어 성능 모니터의 원래 지표와 파생 지표를 수집합니다.
  • hpmcount 명령: 응용 프로그램을 실행하고, 실행에 걸린 실제(wall clock) 시간, 하드웨어 성능 모니터의 원래·파생 지표, 운영 체제 자원 사용 통계를 보여 줍니다.

참고: API와 각 프로세서에서 쓸 수 있는 이벤트는 설계상 완전히 분리되어 있습니다. 쓸 수 있는 이벤트, 그 설명, 현재 시험 상태(프로세서마다 다름)는 따로 설치하는 표에 있으며, 어떤 API 호출도 이벤트의 유무나 상태에 의존하지 않으므로 여기서는 설명하지 않습니다.

pm_initialize API 초기화 루틴이 돌려주는 이벤트 상태는 verified, unverified, caveat, broken, group-only, thresholdable, shared 가운데 하나입니다(시험 상태와 이벤트 정확도는 "성능 모니터의 정확도"를 봅니다).

pm_initialize 루틴에는 이벤트 필터(상태 비트의 아무 조합)를 넘겨야 그 필터와 상태가 맞는 이벤트가 돌아옵니다. 필터를 넘기지 않으면 이벤트가 하나도 돌아오지 않습니다.

영어 원문

Hardware performance monitor APIs and tools

The bos.pmapi fileset contains libraries and tools that are designed to provide access to some of the counting facilities of the Performance Monitor feature included in select IBM® microprocessors.

They include the following:

  • The pmapi library, which contains a set of low-level application programming interfaces, APIs, includes the following: – A set of system-level APIs to permit counting of the activity of a whole machine or of a set of processes with a common ancestor. – A set of first party kernel-thread-level APIs to permit threads to count their own activity. – A set of third party kernel-thread-level APIs to permit a debug program to count the activity of target threads.

  • The pmcycles command, which returns the processor clock and decrementer speeds.

  • The pmlist command, which displays information about processors, events, event groups and sets, and derived metrics supported.

  • The hpm and hpm_r libraries, which contain a set of high-level APIs that enable the following: – Nested instrumentation of sections of code – Automatic calculation of derived metrics, and gathering of operating system resource-consumption metrics in addition to the raw hardware counter values

  • The hpmstat command, which collects the hardware performance monitor raw and derived metrics concerning total system activity of a machine.

  • The hpmcount command, which executes applications and provides the applications' execution wall clock time, the raw and derived hardware performance monitor metrics and the operating system resource-utilization statistics.

Note: The APIs and the events available on each of the supported processors have been completely separated by design. The events available, their descriptions, and their current testing status (which are different on each processor) are in separately installable tables, and are not described here because none of the API calls depend on the availability or status of any of the events.

The status of an event, as returned by the pm_initialize API initialization routine, can be verified, unverified, caveat, broken, group-only, thresholdable, or shared (see “Performance monitor accuracy” about testing status and event accuracy).

An event filter (which is any combination of the status bits) must be passed to the pm_initialize routine to force the return of events with status matching the filter. If no filter is passed to the pm_initialize routine, no events will be returned.

성능 모니터의 정확도

verified로 표시된 이벤트만 완전한 검증을 거쳤습니다. caveat로 표시된 이벤트는 pm_initialize 루틴이 돌려주는 이벤트 설명에 적힌 제한 안에서 검증되었습니다.

unverified로 표시된 이벤트는 정확도가 정해져 있지 않으므로 조심해서 씁니다. 성능 모니터 API는 본질적으로 하드웨어 레지스터를 읽어 주는 서비스이며, 그 레지스터에 의미 있는 내용이 없을 수도 있습니다.

사용자는 unverified 이벤트 카운터로 실험해 보고 특정 튜닝 상황에 쓸 수 있는지 스스로 판단할 수 있습니다.

영어 원문

Performance monitor accuracy

Only events marked verified have gone through full verification. Events marked caveat have been verified within the limitations documented in the event description returned by the pm_initialize routine.

Events marked unverified have undefined accuracy. Use caution with unverified events. The Performance Monitor API is essentially providing a service to read hardware registers that might not have any meaningful content.

Users can experiment with unverified event counters and determine for themselves if they can be used for specific tuning situations.

성능 모니터의 문맥과 상태

여러 수준에서 성능 모니터 데이터에 접근할 수 있도록 AIX 운영 체제는 선택적인 성능 모니터링 문맥(context)을 지원합니다.

이 문맥은 일반 프로세서·스레드 문맥을 확장한 것으로, 하드웨어 카운터마다 64비트 카운터 하나와 제어 워드 묶음을 가집니다. 제어 워드는 어떤 이벤트를 셀지, 언제 세기를 켜고 끌지를 정합니다.

영어 원문

Performance monitor context and state

To provide Performance Monitor data access at various levels, the AIX operating system supports optional performance monitoring contexts.

These contexts are an extension to the regular processor and thread contexts and include one 64-bit counter per hardware counter and a set of control words. The control words define which events are counted and when counting is on or off.

시스템 수준 문맥과 누적

시스템 수준 API에서는 프로세서마다 선택적인 성능 모니터 문맥을 연결할 수 있습니다.

영어 원문

System-level context and accumulation

For the system-level APIs, optional Performance Monitor contexts can be associated with each of the processors.

스레드 문맥

스레드마다 선택적인 성능 모니터 문맥을 연결할 수도 있습니다. AIX 운영 체제와 성능 모니터 커널 확장이 각 문맥의 64비트 카운터 묶음을 자동으로 관리합니다.

영어 원문

Thread context

Optional Performance Monitor contexts can also be associated with each thread. The AIX operating system and the Performance Monitor kernel extension automatically maintain sets of 64-bit counters for each of these contexts.

스레드 집계 그룹과 프로세스 문맥

스레드 수준 API는 선택적으로 스레드 집계 그룹(counting-group)이라는 개념을 지원합니다. 그룹 안의 모든 스레드는 자기 성능 모니터 문맥에 더해 그룹 누적 문맥을 공유합니다.

스레드 그룹은 공통 조상 스레드가 만든 모든 스레드로 정의합니다. 정의상 스레드 그룹의 모든 스레드는 같은 이벤트 집합을 세며, 아래에 설명하는 예외 하나를 빼면 그룹은 자손 스레드를 만들기 전에 만들어야 합니다. 자손 스레드가 만들어진 뒤에는 공통 조상을 가진 스레드 목록을 알아낼 수 없기 때문입니다.

특별한 경우가 한 프로세스에 속한 모든 스레드의 모음입니다. 프로세스에 속한 스레드 목록은 만들 수 있으므로, 이런 그룹은 자손 스레드를 언제 만들었든 아무 때나 만들 수 있습니다. 한 프로세스 안에 그룹이 여러 개 있을 수 있지만, 스레드 하나는 성능 모니터 집계 그룹 하나에만 속할 수 있습니다. 그룹 안의 모든 스레드는 같은 이벤트를 세야 하므로, 프로세스 안의 어떤 스레드가 이미 문맥을 가지고 있으면 프로세스 그룹 만들기는 실패합니다.

영어 원문

Thread counting-group and process context

The concept of thread counting-group is optionally supported by the thread-level APIs. All the threads within a group, in addition to their own performance monitor context, share a group accumulation context.

A thread group is defined as all the threads created by a common ancestor thread. By definition, all the threads in a thread group count the same set of events, and, with one exception described below, the group must be created before any of the descendant threads are created. This restriction is due to the fact that, after descendant threads are created, it is impossible to determine a list of threads with a common ancestor.

One special case of a group is the collection of all the threads belonging to a process. Such a group can be created at any time regardless of when the descendant threads are created, because a list of threads belonging to a process can be generated. Multiple groups can coexist within a process, but each thread can be a member of only one Performance Monitor counting-group. Because all the threads within a group must be counting the same events, a process group creation will fail if any thread within the process already has a context.

성능 모니터 상태의 상속

성능 모니터 상태는 성능 모니터 프로그래밍(세는 이벤트), 집계 상태(켜짐·꺼짐), 선택적인 스레드 그룹 소속을 합친 것으로 정의합니다.

그룹마다 집계 상태가 있습니다. 그룹을 만들 때 집계 상태는 그룹의 첫 스레드에서 물려받습니다. 그룹에 속한 스레드의 실제 집계 상태는 자기 집계 상태와 그룹 집계 상태를 AND한 결과입니다. 그래서 그룹 집계 상태만 바꾸면 그룹 안 모든 스레드의 실제 집계 상태를 한꺼번에 제어할 수 있습니다. 스레드는 만들어질 때 부모로부터 성능 모니터 상태 전체를 물려받습니다. 그러나 스레드의 성능 모니터 문맥 데이터(64비트 카운터 값)는 물려받지 않으므로 새로 만든 스레드는 카운터가 0에서 시작합니다.

영어 원문

Performance monitor state inheritance

The performance monitor is defined as the combination of the Performance Monitor programmation (the events being counted), the counting state (on or off), and the optional thread group membership.

A counting state is associated with each group. When the group is created, its counting state is inherited from the initial thread in the group. For thread members of a group, the effective counting state is the result of AND-ing their own counting state with the group counting state. This provides a way to effectively control the counting state for all threads in a group. Simply manipulating the group-counting state will affect the effective counting state of all the threads in the group. Threads inherit their complete Performance Monitor state from their parents when the thread is created. A thread Performance Monitor context data (the value of the 64-bit counters) is not inherited, that is, newly created threads start with counters set to zero.

(6.1) 성능 모니터링 에이전트

성능 모니터링 에이전트(perfagent.server 파일 세트)는 호스트가 네트워크를 거쳐 또는 로컬에서 성능 통계를 제공할 수 있게 하는 프로그램 모음입니다. 핵심 프로그램은 데몬 xmtopas입니다.

주요 구성 요소는 다음과 같습니다.

구성 요소 설명
xmtopas 데이터 공급자(data-supplier) 데몬. 이 데몬이 도는 시스템이 로컬이나 원격 호스트의 데이터 소비자(data-consumer) 프로그램에 성능 통계를 제공하게 합니다. SNMP 인터페이스도 제공합니다(SNMP 인터페이스는 System p 에이전트에서만 쓸 수 있음).
xmtrend 장기 기록 데몬. jazizo와 jtopas로 나중에 처리할 수 있도록 큰 지표 집합의 추세를 기록합니다.
xmscheck xmservd 기록 구성 파일을 미리 검사하는 프로그램. 정해진 시각에 xmservd 기록을 시작하고 멈추려 할 때 유용합니다.
filtd 기존 통계를 줄이고(data reduction) 경보 조건과 경보 발생을 정의하는 데몬
xmpeek 로컬이나 원격 호스트의 xmservd 상태를 보여 주고 데몬에서 얻을 수 있는 통계를 모두 나열하는 프로그램
iphosts 감시할 호스트를 지정해 IP 성능 감시를 시작하는 프로그램. 호스트 목록을 명령줄이나 파일에서 받습니다.
armtoleg 기존 ARM(Application Response Management) 라이브러리를 PTX와 함께 제공되는 ARM 라이브러리와 동시에 쓸 수 있는 ARM 라이브러리로 바꾸는 프로그램. 필요한 운영 체제에서만 제공됩니다.
SpmiArmd ARM 데이터를 모아 Spmi 라이브러리 코드와 연결하는 데몬. 어떤 PTX 관리자 프로그램에서든 ARM 지표를 감시할 수 있게 합니다.
SpmiResp 선택한 호스트의 IP 응답 시간을 폴링해 Spmi 라이브러리 코드와 연결하는 데몬. 어떤 PTX 관리자 프로그램에서든 IP 응답 시간 지표를 감시할 수 있게 합니다.
ARM API와 라이브러리 PTX의 ARM 구현을 지원하는 헤더 파일 하나와 라이브러리 둘. PTX ARM 라이브러리와 먼저 설치된 ARM 라이브러리 하나를 함께, 동시에 쓸 수 있습니다.
SPMI(System Performance Measurement Interface) API와 라이브러리 직접 데이터 공급자 프로그램과 로컬 데이터 소비자 프로그램을 만들 수 있게 하는 헤더 파일과 라이브러리
예제 프로그램 API 사용법을 보여 주는 동적 데이터 공급자·소비자 예제 프로그램
원격 SPMI(RSI) API 하나 이상의 xmtopas 데몬이 제공하는 통계에 접근하는 프로그램을 만들려는 사람을 위한 API
영어 원문

Performance monitoring agent

The performance monitoring agent (perfagent.server fileset) is a collection of programs that make it possible for a host to act as a provider of performance statistics across a network or locally. The key program is the daemon xmtopas.

The following are the main components of the performance monitoring agent:

xmtopas

The data-supplier daemon, which permits a system where this daemon runs to supply performance statistics to data-consumer programs on the local or remote hosts. This daemon also provides the interface to SNMP.

Note: The interface to SNMP is available only on System p Agents.

xmtrend

A long-term recording daemon. This daemon also provides large metric set trend recordings for post-processing by jazizo and jtopas.

xmscheck

A program that lets you pre-check the xmservd recording configuration file. This program is useful when you want to start and stop xmservd recording at predetermined times.

filtd A daemon that can be used to do data reduction of existing statistics and to define alarm conditions and triggering of alarms.

xmpeek

A program that allows you to display the status of xmservd on the local or a remote host and to list all available statistics from the daemon.

iphosts

A program to initiate monitoring of Internet Protocol performance by specifying which hosts to monitor. The program accepts a list of hosts from the command line or from a file.

armtoleg

A program that can convert a pre-existing Application Response Management (ARM) library into an ARM library that can be accessed concurrently with the ARM library shipped with PTX. This program is only required and available on operating systems.

SpmiArmd

A daemon that collects Application Response Management (ARM) data and interfaces to the Spmi library code to allow monitoring of ARM metrics from any PTX manager program.

SpmiResp

A daemon that polls for IP response times for selected hosts and interfaces to the Spmi library code to allow monitoring of IP response time metrics from any PTX manager program.

Application Response Management API and Libraries

A header file and two libraries support the PTX implementation of ARM. The implementation allows for coexistence and simultaneous use of the PTX ARM library and one previously installed ARM library.

System Performance Measurement Interface API and Library

Header files and a library to allow you to develop your own data-supplier and local data-consumer programs.

Sample Programs

Sample dynamic data-supplier and data-consumer programs that illustrate the use of the API.

Remote System Performance Measurement Interface API

This API is available for those who want to develop programs that access the statistics available from one or more xmtopas daemons.

(6.1) POWERCOMPAT 이벤트

POWERCOMPAT 이벤트는 프로세서 호환 모드에서 쓸 수 있는 하드웨어 이벤트 목록이며, 실제 프로세서 이벤트의 부분 집합으로 쓰입니다.

프로세서 호환 모드를 쓰면 논리 파티션(LPAR)의 운영 체제 환경을 업그레이드하지 않고 프로세서 종류가 다른 시스템 사이에서 논리 파티션을 옮길 수 있습니다. 프로세서 호환 모드에서는 대상 시스템이 논리 파티션에, 그 안의 운영 체제 환경이 지원하는 프로세서 기능의 부분 집합을 제공합니다.

AIX 버전별로 POWERCOMPAT 호환 모드에서 지원하는 하드웨어 이벤트는 다음과 같습니다.

카운터 이벤트 이름 지원하는 AIX 버전
1 PM_1PLUS_PPC_CMPL AIX 6.1(6100-04 이상), AIX 7.1 이상
1 PM_CYC AIX 6.1(6100-04 이상), AIX 7.1 이상
1 PM_DATA_FROM_L1.5 AIX 6(6100-07 이하), AIX 7(7100-01 이하)
1 PM_FLOP AIX 6.1(6100-04 이상), AIX 7.1 이상
1 PM_GCT_NOSLOT_CYC AIX 6.1(6100-04 이상), AIX 7.1 이상
1 PM_IERAT_MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
1 PM_INST_CMPL AIX 6(6100-07 이하), AIX 7(7100-01 이하)
1 PM_INST_IMC_MATCH_CMPL AIX 6(6100-07 이하), AIX 7(7100-01 이하)
1 PM_LSU_DERAT_MISS_CYC AIX 6(6100-07 이하), AIX 7(7100-01 이하)
1 PM_PMC4_OVERFLOW AIX 6(6100-07 이하), AIX 7(7100-01 이하)
1 PM_SUSPENDED AIX 6(6100-07 이하), AIX 7(7100-01 이하)
1 PM_ANY_THRD_RUN_CYC AIX 6.1(6100-04 이상), AIX 7.1 이상
1 PM_MRK_INST_DISP AIX 6(6100-08 이상), AIX 7(7100-02 이상)
1 PM_MRK_BR_TAKEN_CMPL AIX 6(6100-08 이상), AIX 7(7100-02 이상)
1 PM_MRK_L1_ICACHE_MISS AIX 6(6100-08 이상), AIX 7(7100-02 이상)
1 PM_THRESH_EXC_4096 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
1 PM_THRESH_EXC_256 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
1 PM_MRK_L1_RELOAD_VALID AIX 6(6100-08 이상), AIX 7(7100-02 이상)
1 PM_THRESH_MET AIX 6(6100-08 이상), AIX 7(7100-02 이상)
2 PM_CYC AIX 6(6100-07 이하), AIX 7(7100-01 이하)
2 PM_DATA_FROM_L2MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_EXT_INT AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_INST_CMPL AIX 6(6100-07 이하), AIX 7(7100-01 이하)
2 PM_INST_DISP AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_L1_ICACHE_MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_LSU_DERAT_MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_PMC1_OVERFLOW AIX 6(6100-07 이하), AIX 7(7100-01 이하)
2 PM_RUN_CYC AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_ST_FIN AIX 6.1(6100-04 이상), AIX 7.1 이상
2 PM_SUSPENDED AIX 6(6100-07 이하), AIX 7(7100-01 이하)
2 PM_MRK_DATA_FROM_MEM AIX 6(6100-08 이상), AIX 7(7100-02 이상)
2 PM_MRK_LD_MISS_L1 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
2 PM_MRK_DATA_FROM_L3MISS AIX 6(6100-08 이상), AIX 7(7100-02 이상)
2 PM_THRESH_EXC_32 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
2 PM_THRESH_EXC_512 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
3 PM_CYC AIX 6(6100-07 이하), AIX 7(7100-01 이하)
3 PM_DATA_FROM_L3MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_DTLB_MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_INST_CMPL AIX 6(6100-07 이하), AIX 7(7100-01 이하)
3 PM_INST_DISP AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_L1_DCACHE_RELOAD_VALID AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_PMC2_OVERFLOW AIX 6(6100-07 이하), AIX 7(7100-01 이하)
3 PM_ST_MISS_L1 AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_SUSPENDED AIX 6(6100-07 이하), AIX 7(7100-01 이하)
3 PM_TB_BIT_TRANS AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_THRD_CONC_RUN_INST AIX 6.1(6100-04 이상), AIX 7.1 이상
3 PM_BR_TAKEN_CMPL AIX 6(6100-08 이상), AIX 7(7100-02 이상)
3 PM_MRK_ST_CMPL AIX 6(6100-08 이상), AIX 7(7100-02 이상)
3 PM_MRK_BR_MPRED_CMPL AIX 6(6100-08 이상), AIX 7(7100-02 이상)
3 PM_MRK_DERAT_MISS AIX 6(6100-08 이상), AIX 7(7100-02 이상)
3 PM_THRESH_EXC_64 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
3 PM_THRESH_EXC_1024 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_1PLUS_PPC_DISP AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_BR_MPRED_CMPL AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_CYC AIX 6(6100-07 이하), AIX 7(7100-01 이하)
4 PM_FLUSH AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_INST_CMPL AIX 6(6100-07 이하), AIX 7(7100-01 이하)
4 PM_ITLB_MISS AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_LD_MISS_L1 AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_PMC3_OVERFLOW AIX 6(6100-07 이하), AIX 7(7100-01 이하)
4 PM_RUN_INST_CMPL AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_RUN_PURR AIX 6.1(6100-04 이상), AIX 7.1 이상
4 PM_SUSPENDED AIX 6(6100-07 이하), AIX 7(7100-01 이하)
4 PM_MRK_INST_CMPL AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_MRK_DTLB_MISS AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_MRK_INST_FROM_L3MISS AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_MRK_DATA_FROM_L2MISS AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_THRESH_EXC_128 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_THRESH_EXC_2048 AIX 6(6100-08 이상), AIX 7(7100-02 이상)
4 PM_DATA_FROM_MEM AIX 6(6100-08 이상), AIX 7(7100-02 이상)
5 PM_RUN_INST_CMPL AIX 6.1 이상, AIX 7.1 이상
6 PM_RUN_CYC AIX 6.1 이상, AIX 7.1 이상
영어 원문

POWERCOMPAT events

The POWERCOMPAT events provide a list of hardware events that are available for processor compatibility modes and are used as a subset of the actual processor events.

You can use the processor compatibility modes to move logical partitions between systems that have different processor types without upgrading the operating system environments in the logical partition. The processor compatibility mode allows the destination system to provide the logical partition with a subset of processor capabilities that are supported by the operating systems environment in the logical partition.

The following hardware events are supported in the POWERCOMPAT compatibility mode for different versions of the AIX operating system.

Table 1. POWERCOMPAT events

Counter Event name Supported AIX version
1 PM_1PLUS_PPC_CMPL • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
1 PM_CYC • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
1 PM_DATA_FROM_L1.5 • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
1 PM_FLOP • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
1 PM_GCT_NOSLOT_CYC • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
1 PM_IERAT_MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
1 PM_INST_CMPL • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier

Table 1. POWERCOMPAT events (continued)

Counter Event name Supported AIX version
1 PM_INST_IMC_MATCH_CMPL • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
1 PM_LSU_DERAT_MISS_CYC • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
1 PM_PMC4_OVERFLOW • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
1 PM_SUSPENDED • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
1 PM_ANY_THRD_RUN_CYC • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
1 PM_MRK_INST_DISP • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
1 PM_MRK_BR_TAKEN_CMPL • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
1 PM_MRK_L1_ICACHE_MISS • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
1 PM_THRESH_EXC_4096 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
1 PM_THRESH_EXC_256 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
1 PM_MRK_L1_RELOAD_VALID • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
1 PM_THRESH_MET • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
2 PM_CYC • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
2 PM_DATA_FROM_L2MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
2 PM_EXT_INT • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
2 PM_INST_CMPL • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
2 PM_INST_DISP • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
2 PM_L1_ICACHE_MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
2 PM_LSU_DERAT_MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
2 PM_PMC1_OVERFLOW • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
2 PM_RUN_CYC • AIX 6.1 with 6100-04, or later • AIX 7.1, or later

Table 1. POWERCOMPAT events (continued)

Counter Event name Supported AIX version
2 PM_ST_FIN • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
2 PM_SUSPENDED • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
2 PM_MRK_DATA_FROM_MEM • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
2 PM_MRK_LD_MISS_L1 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
2 PM_MRK_DATA_FROM_L3MISS • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
2 PM_THRESH_EXC_32 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
2 PM_THRESH_EXC_512 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
3 PM_CYC • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
3 PM_DATA_FROM_L3MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_DTLB_MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_INST_CMPL • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
3 PM_INST_DISP • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_L1_DCACHE_RELOAD_VALID • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_PMC2_OVERFLOW • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
3 PM_ST_MISS_L1 • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_SUSPENDED • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
3 PM_TB_BIT_TRANS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_THRD_CONC_RUN_INST • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
3 PM_BR_TAKEN_CMPL • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
3 PM_MRK_ST_CMPL • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
3 PM_MRK_BR_MPRED_CMPL • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later

Table 1. POWERCOMPAT events (continued)

Counter Event name Supported AIX version
3 PM_MRK_DERAT_MISS • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
3 PM_THRESH_EXC_64 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
3 PM_THRESH_EXC_1024 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_1PLUS_PPC_DISP • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_BR_MPRED_CMPL • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_CYC • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
4 PM_FLUSH • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_INST_CMPL • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
4 PM_ITLB_MISS • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_LD_MISS_L1 • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_PMC3_OVERFLOW • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
4 PM_RUN_INST_CMPL • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_RUN_PURR • AIX 6.1 with 6100-04, or later • AIX 7.1, or later
4 PM_SUSPENDED • AIX 6 with 6100-07, or earlier • AIX 7 with 7100-01, or earlier
4 PM_MRK_INST_CMPL • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_MRK_DTLB_MISS • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_MRK_INST_FROM_L3MISS • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_MRK_DATA_FROM_L2MISS • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_THRESH_EXC_128 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_THRESH_EXC_2048 • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later
4 PM_DATA_FROM_MEM • AIX 6 with 6100-08, or later • AIX 7 with 7100-02, or later

Table 1. POWERCOMPAT events (continued)

Counter Event name Supported AIX version
5 PM_RUN_INST_CMPL • AIX 6.1, or later • AIX 7.1, or later
6 PM_RUN_CYC • AIX 6.1, or later • AIX 7.1, or later

스레드 누적과 스레드 그룹 누적

스레드가 중단(또는 재디스패치)되면 그 스레드의 64비트 누적 카운터가 갱신됩니다. 스레드가 그룹에 속해 있으면 그룹 누적 카운터도 동시에 갱신됩니다.

마찬가지로 스레드가 집계를 멈추거나 성능 모니터 데이터를 읽으면, 성능 모니터 하드웨어 카운터의 현재 값을 더해 64비트 누적 카운터를 갱신합니다. 이때도 스레드가 그룹에 속해 있으면, 읽기나 멈추기가 스레드에 대한 것이든 스레드 그룹에 대한 것이든 그룹 누적 카운터가 함께 갱신됩니다.

그룹 수준 누적 데이터는 될 수 있는 대로 그룹에 속한 스레드들의 개별 성능 모니터 데이터와 일치하게 유지됩니다. 스레드가 스스로 그룹을 떠나면, 곧 자기 성능 모니터 문맥을 지우면, 그 스레드의 누적 데이터가 그룹 수준 누적 데이터에서 자동으로 빠집니다. 그룹에 속한 스레드가 자기 데이터를 초기화해도 그 데이터가 그룹 수준 누적 데이터에서 빠집니다. 스레드가 끝날 때는 그룹 누적 데이터에 아무것도 하지 않습니다.

그룹 수준 누적이 구성원 데이터의 합과 일치하지 않는 경우는, 그룹 수준 누적 데이터를 초기화했고 그룹에 구성원이 둘 이상일 때뿐입니다. 이 상황은 감지되어 그룹 데이터를 읽을 때 돌아오는 비트로 표시됩니다.

영어 원문

Thread accumulation and thread group accumulation

When a thread gets suspended (or redispatched), its 64-bit accumulation counters are updated. If the thread is member of a group, the group accumulation counters are updated at the same time.

Similarly, when a thread stops counting or reads its Performance Monitor data, its 64 bit accumulation counters are also updated by adding the current value of the Performance Monitor hardware counters to them. Again, if the thread is a member of a group, the group accumulation counters are also updated, regardless of whether the counter read or stop was for the thread or for the thread group.

The group-level accumulation data is kept consistent with the individual Performance Monitor data for the thread members of the group, whenever possible. When a thread voluntarily leaves a group, that is, deletes its Performance Monitor context, its accumulated data is automatically subtracted from the group-level accumulated data. Similarly, when a thread member in a group resets its own data, the data in question is subtracted from the group level accumulated data. When a thread dies, no action is taken on the group-accumulated data.

The only situation where the group-level accumulation is not consistent with the sum of the data for each of its members is when the group-level accumulated data has been reset, and the group has more than one member. This situation is detected and marked by a bit returned when the group data is read.

보안 고려 사항

시스템 수준 API 호출은 root 사용자만 쓸 수 있습니다. 다만 프로세스 트리 옵션을 쓰면 예외이며, 이때는 잠금 장치가 둘 이상의 프로세스에서 호출하는 것을 막습니다. 이 장치는 시스템 수준 문맥을 만든 때부터 지울 때까지 한 프로세스가 API를 소유하고 독점하도록 보장합니다.

프로세스 트리 옵션을 켜면 호출한 프로세스와 그 자손만 셉니다. 기본은 각 프로세서의 모든 활동을 세는 것입니다.

스레드 문맥을 쓰는 중이면 시스템 수준 API가 엉터리 데이터를 보고하므로, 시스템 수준 API 호출과 스레드 수준 API 호출은 동시에 쓸 수 없습니다. 첫 스레드 문맥을 할당하면 시스템 수준 API 잠금을 가져가고, 마지막 문맥이 해제될 때까지 놓지 않습니다.

1st party 호출에서 스레드는 자기 성능 모니터 문맥만 바꿀 수 있습니다. 유일한 예외는 그룹 수준 호출로, 당연히 그룹 문맥에 영향을 주고 다른 스레드의 문맥에도 영향을 줄 수 있습니다. 그룹을 지우면 그룹에 연결된 모든 문맥, 곧 호출자 문맥, 그룹 문맥, 그룹 안 모든 스레드의 문맥이 지워집니다.

호출한 스레드나 그 그룹에 속하지 않은 성능 모니터 문맥에는 대상 프로세스의 디버거 프로그램만 접근할 수 있습니다. 3rd party API 호출은 다음 경우에만 허용됩니다. 대상 프로세스를 API 호출자가 ptrace하고 있고(호출자가 이미 대상 프로세스에 붙어 있음) 대상 프로세스가 멈춰 있는 경우, 또는 대상 프로세스가 /proc 파일 시스템 이벤트에서 멈춰 있고 호출자가 그 제어 파일을 열 권한이 있는 경우입니다.

API에 3rd party 호출을 하려면 디버거 프로그램이 디버그 대상 스레드에 먼저 붙어 있어야 하므로, API의 보안 수준은 디버거 프로그램과 디버그 대상 프로세스 사이의 보안 수준과 같습니다.

영어 원문

Security considerations

The system-level APIs calls are only available from the root user except when the process tree option is used. In that case, a locking mechanism prevents calls being made from more than one process. This mechanism ensures ownership of the API and exclusive access by one process from the time that the system-level contexts are created until they are deleted.

Enabling the process tree option results in counting for only the calling process and its descendants; the default is to count all activities on each processor.

Because the system-level APIs would report bogus data if thread contexts where in use, system-level API calls are not enabled at the same time as thread-level API calls. The allocation of the first thread context will take the system-level API lock, which will not be released until the last context has been deallocated.

When using first party calls, a thread is only permitted to modify its own Performance Monitor context. The only exception to this rule is when making group level calls, which obviously affect the group context, but can also affect other threads' context. Deleting a group deletes all the contexts associated with the group, that is, the caller context, the group context, and all the contexts belonging to all the threads in the group.

Access to a Performance Monitor context not belonging to the calling thread or its group is available only from the target process's debugger program. The third party API calls are only permitted when the target process is either being ptraced by the API caller, that is, the caller is already attached to the target process, and the target process is stopped or the target process is stopped on a /proc file system event and the caller has the privilege required to open its control file.

The fact that the debugger program must already have been attached to the debugged thread before any third party call to the API can be made, ensures that the security level of the API will be the same as the one used between debugger programs and process being debugged.

pmapi 라이브러리

pmapi 라이브러리의 규칙입니다.

성능 모니터 API에 공통인 규칙은 다음과 같습니다.

  • 다른 API를 호출하기 전에 pm_initialize 루틴을 먼저 불러야 하며, 이후 pm_set_program 호출에는 해당 pm_initialize 호출이 그 필터 설정으로 돌려준 이벤트만 쓸 수 있습니다.
  • PM 문맥은 언제든 다시 프로그래밍하거나 재사용할 수 없습니다. 곧 어떤 API도 pm_delete_program 인터페이스 호출 없이 pm_set_program 인터페이스를 두 번 이상 부르는 것을 지원하지 않습니다. 또 프로세스 그룹을 만들 때 그 프로세스의 어떤 스레드도 이미 문맥을 가지고 있으면 안 됩니다.
  • 모든 API 호출은 성공하면 0을, 실패하면 양수 오류 코드(pm_error로 해석)를 돌려줍니다.
영어 원문

The pmapi library

Review the rules that are for the pmapi library.

The following rules are common to the Performance Monitor APIs:

  • The pm_initialize routine must be called before any other API call can be made, and only events returned by a given pm_initialize call with its associated filter setting can be used in subsequent pm_set_program calls.

  • PM contexts cannot be reprogrammed or reused at any time. This means that none of the APIs support more than one call to a pm_set_program interface without a call to a pm_delete_program interface. This also means that when creating a process group, none of the threads in the process is permitted to already have a context.

  • All the API calls return 0 when successful or a positive error code (which can be decoded using pm_error) otherwise.

pm_init API 초기화 루틴

pm_init 루틴은 두 번째 매개변수가 가리키는 pm_info_t 구조체에 프로세서 이름, 쓸 수 있는 카운터 수, 카운터마다 쓸 수 있는 이벤트 목록, 지원하는 임계값 승수(threshold multiplier)를 돌려줍니다.

임계값 승수를 두 개 지원하는 프로세서도 있고, 하나도 없어 임계값을 전혀 지원하지 않는 프로세서도 있습니다. POWER4보다 새로운 프로세서에는 pm_init 루틴을 쓸 수 없고 pm_initialize 루틴을 써야 합니다.

돌려주는 이벤트마다 시험 상태에 더해, 이후 API 호출에 쓸 식별자, 짧은 이름, 긴 이름을 돌려줍니다. 짧은 이름은 PM_MNEMONIC 형태의 기억하기 쉬운 이름이며, 프로세서가 달라도 같은 이벤트면 이름이 같습니다. 예를 들어 PM_CYC와 PM_INST_CMPL은 각각 프로세서 사이클 수와 완료된 명령어 수이며 모든 프로세서에 있어야 합니다. 이벤트마다 임계값 가능(thresholdable) 플래그도 돌려줍니다. 이벤트를 임계값과 함께 쓸 수 있는지를 나타내며, 쓸 수 있으면 임계값을 지정할 때 사이클 수가 임계값에 프로세서의 선택된 임계값 승수를 곱한 값을 넘을 때까지 세기를 미룹니다.

성능 모니터링 API는 개별 이벤트 대신 이벤트 그룹을 지정할 수 있습니다. 이벤트 그룹은 미리 정의된 이벤트 집합으로, 이벤트를 하나하나 지정하는 대신 그룹 ID 하나를 지정합니다. pm_init 루틴의 인터페이스는 새로운 선택적 세 번째 매개변수가 가리키는 pm_groups_info_t 구조체에 지원하는 이벤트 그룹 목록을 돌려주도록 확장되었습니다. 바이너리 호환성을 지키려면 필터에 PM_GET_GROUPS 비트 플래그를 OR해 세 번째 매개변수를 명시적으로 알려야 합니다. 플랫폼에 따라 그룹 안에서만 쓸 수 있는 이벤트가 있으며, 이벤트마다 돌려주는 임계값 플래그로 표시합니다. 표기는 다음과 같습니다.

표기 뜻
y 임계값을 쓸 수 있는 이벤트
g 그룹 안에서만 쓸 수 있는 이벤트
G 임계값을 쓸 수 있고 그룹 안에서만 쓸 수 있는 이벤트
n 임계값을 쓸 수 없고 따로 쓸 수 있는 이벤트

모든 이벤트가 g나 G로 표시되어 이벤트 그룹을 꼭 써야 하는 플랫폼도 있습니다. 돌려주는 이벤트 그룹마다 이벤트와 비슷한 짧은 이름, 긴 이름, 설명과, 이후 API 호출에 쓸 그룹 식별자, 그룹에 든 이벤트(이벤트 식별자 배열)가 들어 있습니다.

그룹의 시험 상태는 그룹에 든 이벤트들의 시험 상태 가운데 가장 낮은 것으로 정합니다. caveat인 이벤트가 하나라도 있으면 그룹 상태는 잘해야 caveat이고, unverified인 이벤트가 하나라도 있으면 그룹 상태는 unverified입니다. 이 상태는 그룹 특성으로 돌려주지는 않지만 필터에는 반영됩니다. 이벤트처럼 상태가 필터와 맞는 그룹만 돌아옵니다.

영어 원문

The pm_init API initialization routine

The pm_init routine returns (in a structure of type pm_info_t pointed to by its second parameter) the processor name, the number of counters available, the list of available events for each counter, and the threshold multipliers supported.

Some processor support two threshold multipliers, others none, meaning that thresholding is not supported at all. You can not use the pm_init routine with processors newer than POWER4. You must use the pm_initialize routine for newer processors.

For each event returned, in addition to the testing status, the pm_init routine also returns the identifier to be used in subsequent API calls, a short name, and a long name. The short name is a mnemonic name in the form PM_MNEMONIC. Events that are the same on different processors will have the same mnemonic name. For instance, PM_CYC and PM_INST_CMPL are respectively the number of processor cycles and instruction completed and should exist on all processors. For each event returned, a thresholdable flag is also returned. This flag indicates whether an event can be used with a threshold. If so, then specifying a threshold defers counting until a number of cycles equal to the threshold multiplied by the processor's selected threshold multiplier has been exceeded.

The Performance Monitoring API enables the specification of event groups instead of individual events. Event groups are predefined sets of events. Rather than each event being individually specified, a single group ID is specified. The interface to the pm_init routine has been enhanced to return the list of supported event groups in a structure of type pm_groups_info_t pointed to by a new optional third parameter. To preserve binary compatibility, the third parameter must be explicitly announced by OR-ing the PM_GET_GROUPS bitflag into the filter. Some events on some platforms can only be used from within a group. This is indicated in the threshold flag associated with each event returned. The following convention is used:

  • y — A thresholdable event
  • g — An event that can only be used in a group
  • G — A thresholdable event that can only be used in a group
  • n — A non-thresholdable event that is usable individually

On some platforms, use of event groups is required because all the events are marked g or G. Each of the event groups that are returned includes a short name, a long name, and a description similar to those associated with events, as well as a group identifier to be used in subsequent API calls and the events contained in the group (in the form of an array of event identifiers).

The testing status of a group is defined as the lowest common denominator among the testing status of the events that it includes. If at least one event has a testing status of caveat, the group testing status is at best caveat, and if at least one event has a status of unverified, then the group status is unverified. This is not returned as a group characteristic, but it is taken into account by the filter. Like events, only groups with status matching the filter are returned.

pm_initialize API 초기화 루틴

pm_initialize 루틴은 두 번째 매개변수로 지정한 pm_info2_t 구조체에 프로세서 이름, 그 특성, 쓸 수 있는 카운터 수, 카운터마다 쓸 수 있는 이벤트 목록을 돌려줍니다.

이벤트마다 상태를 돌려줍니다. 검증됨(validated), 검증 안 됨(unvalidated), 조건부 검증(validated with caveat) 가운데 하나이며, 그룹에서 쓸 수 있는지, 임계값을 쓸 수 있는지, 공유 이벤트인지도 나타냅니다.

플랫폼에 따라 그룹 안에서만 쓸 수 있는 이벤트가 있습니다. 개별 이벤트 대신 이벤트 그룹을 지정하는 경우, 그 이벤트는 그룹 전용(grouped only) 이벤트로 정의됩니다.

이벤트마다 임계값 가능 상태도 돌려줍니다. 이벤트를 임계값과 함께 쓸 수 있는지를 나타내며, 쓸 수 있으면 임계값을 지정할 때 사이클 수가 임계값에 선택된 프로세서 임계값 승수를 곱한 값을 넘을 때까지 세기를 미룹니다.

물리 처리 장치 하나에 하드웨어 스레드 두 개를 지원하는 프로세서가 있습니다. 스레드마다 카운터 집합이 있지만, 이런 프로세서의 일부 이벤트는 공유 이벤트입니다. 공유 이벤트는 특정 스레드의 활동이 아닌 신호로 제어되며, 그 신호가 스레드마다 하나씩인 두 하드웨어 카운터 집합에 동시에 보내집니다. 이런 이벤트는 shared 상태로 표시됩니다.

돌려주는 이벤트마다 시험 상태에 더해, 이후 API 호출에 쓸 식별자를 짧은 이름과 긴 이름으로 돌려줍니다. 짧은 이름은 PM_MNEMONIC 형태의 기억하기 쉬운 이름이며, 프로세서가 달라도 같은 이벤트면 이름이 같습니다. 예를 들어 PM_CYC와 PM_INST_CMPL은 각각 프로세서 사이클 수와 완료된 명령어 수이며 모든 프로세서에 있어야 합니다.

성능 모니터링 API는 개별 이벤트 대신 이벤트 그룹을 지정할 수 있습니다. 이벤트 그룹은 미리 정의된 이벤트 집합으로, 이벤트를 하나하나 지정하는 대신 그룹 ID 하나를 지정할 수 있습니다. pm_initialize 루틴의 인터페이스는 지원하는 이벤트 그룹 목록을 pm_groups_info_t 구조체에 담아 세 번째 매개변수로 그 주소를 돌려줍니다.

모든 이벤트가 그룹 전용으로 표시되어 이벤트 그룹을 꼭 써야 하는 플랫폼도 있습니다. 돌려주는 이벤트 그룹마다 이벤트와 비슷한 짧은 이름, 긴 이름, 설명과, 이후 API 호출에 쓸 그룹 식별자, 그룹에 든 이벤트(이벤트 식별자 배열)가 들어 있습니다.

그룹의 시험 상태는 그룹에 든 이벤트들의 시험 상태 가운데 가장 낮은 것으로 정합니다. caveat인 이벤트가 하나라도 있으면 그룹 상태는 잘해야 caveat이고, unverified인 이벤트가 하나라도 있으면 그룹 상태는 unverified입니다. 그룹 특성으로 돌려주지는 않지만 필터에는 반영되며, 상태가 필터와 맞는 그룹만 돌아옵니다.

proctype 매개변수가 PM_CURRENT가 아니면 성능 모니터 API 라이브러리는 초기화되지 않고, 필터를 반영해 지정한 프로세서의 정보만 매개변수 pm_info2_t와 pm_groups_info_t에 돌려줍니다. proctype이 PM_CURRENT이면 그 정보를 돌려주는 것에 더해 성능 모니터 API 라이브러리가 초기화되어 다른 호출을 받을 준비가 됩니다.

영어 원문

The pm_initialize API initialize routine

The pm_initialize routine returns the processor name in a structure of type pm_info2_t defined by its second parameter, its characteristics, the number of counters available, and the list of available events for each counter.

For each event a status is returned, indicating the event status: validated, unvalidated, or validated with caveat. The status also indicates if the event can be used in a group or not, if it is a thresholdable event and if it is a shared event.

Some events on some platforms can be used only within a group. In the case where an event group is specified instead of individual events, the events are defined as grouped only events.

For each returned event, a thresholdable state is also returned. It indicates whether an event can be used with a threshold. If so, specifying a threshold defers counting until it exceeds a number of cycles equal to the threshold multiplied by the selected processor threshold multiplier.

Some processors support two hardware threads per physical processing unit. Each thread implements a set of counters, but some events defined for those processors are shared events. A shared event, is controlled by a signal not specific to a particular thread's activity and sent simultaneously to both sets of hardware counters, one for each thread. Those events are marked by the shared status.

For each returned event, in addition to the testing status, the pm_initialize routine returns the identifier to be used in subsequent API calls, as a short name and a long name. The short name is a mnemonic name in the form PM_MNEMONIC. The same events on different processors will have the same mnemonic name. For instance, PM_CYC and PM_INST_CMPL are respectively the number of processor cycles and the number of completed instructions, and should exist on all processors.

The Performance Monitoring API enables the specification of event groups instead of individual events. Event groups are predefined sets of events. Rather than to specify individually each event, a single group ID can be specified. The interface to the pm_initialize routine returns the list of supported event groups in a structure of type pm_groups_info_t whose address is returned in the third parameter.

On some platforms, the use of event groups is required because all events are marked as group-only. Each event group that is returned includes a short name, a long name, and a description similar to those associated with events, as well as a group identifier to be used in subsequent API calls and the events contained in the group (in the form of an array of event identifiers).

The testing status of a group is defined as the lowest common denominator among the testing status of the events that it includes. If the testing status of at least one event is caveat, then the group testing status

is at best caveat, and if the status of at least one event is unverified, then the group status is unverified. This is not returned as a group characteristic, but it is taken into account by the filter. Like events, only groups whose status match the filter are returned.

If the proctype parameter is not set to PM_CURRENT, the Performance Monitor APIs library is not initialized and the subroutine only returns information about the specified processor in its parameters, pm_info2_t and pm_groups_info_t, taking into account the filter. If the proctype parameter is set to PM_CURRENT, in addition to returning the information described, the Performance Monitor APIs library is initialized and ready to accept other calls.

pmapi 라이브러리의 기본 호출

아래는 시스템 전체 API 호출이며, 각각 1st party·3rd party 커널 스레드 집계나 그룹 집계용 변형이 있습니다. 변형은 pm_set_program, pm_set_program_mythread, pm_set_program_group처럼 함수 이름 뒤에 붙는 접미사로 나타냅니다.

호출 설명
pm_set_program 집계 구성을 정합니다. 셀 이벤트(카운터마다 하나씩인 이벤트 식별자 목록이나 이벤트 그룹 식별자 하나)와 집계 모드를 지정합니다. 고를 수 있는 이벤트 목록은 pm_init 루틴이 돌려줍니다. 목록에 임계값 가능 이벤트가 있으면 임계값과 임계값 승수도 지정할 수 있습니다. 집계 모드에는 사용자 모드·커널 모드 집계, 바로 세기 시작할지가 들어갑니다. 시스템 전체 호출에서는 프로세스와 그 자손만 셀지 시스템 전체를 셀지도 들어가고, 집계 그룹 호출에서는 만들 그룹 종류(첫 스레드와 그 이후 자손으로 이루어진 그룹, 또는 프로세스의 모든 스레드를 담는 프로세스 수준 그룹)가 들어갑니다. 기본으로 인터럽트 처리에 쓴 시간도 세며, 집계 모드를 바꿔 이 동작을 바꿀 수 있습니다.
pm_get_program 현재 성능 모니터 설정을 가져옵니다. 모드 정보와 세고 있는 이벤트 목록(또는 이벤트 그룹)이 들어 있으며, 목록에 임계값 가능 이벤트가 있으면 임계값과 쓰인 승수도 돌려줍니다.
pm_delete_program 성능 모니터 구성을 지웁니다. pm_set_program을 되돌릴 때 씁니다.
pm_start, pm_tstart 성능 모니터 집계를 시작합니다. pm_tstart는 카운터가 세기 시작한 시각의 타임스탬프를 돌려줍니다. timebase 값이며 time_base_to_time으로 시각으로 바꿀 수 있습니다.
pm_stop, pm_tstop 성능 모니터 집계를 멈춥니다. pm_tstop은 카운터가 세기를 멈춘 시각의 타임스탬프를 돌려줍니다(timebase 값, time_base_to_time으로 변환).
pm_get_data, pm_get_tdata, pm_get_Tdata 성능 모니터 집계 데이터를 돌려줍니다. 하드웨어 카운터마다 하나씩인 64비트 값의 묶음입니다. 집계 그룹 호출이면 그룹 정보도 돌려줍니다("스레드 집계 그룹 정보" 참고). pm_get_tdata는 하드웨어 카운터를 마지막으로 읽은 시각의 타임스탬프가 더해집니다. pm_get_Tdata는 카운터가 켜져 있던 구간의 누적 시간이 더해지며, 실제 시간과 (지원하는 프로세서에서) PURR·SPURR 값으로 재고 timebase 단위로 돌려줍니다.
pm_get_data_cpu, pm_get_tdata_cpu, pm_get_Tdata_cpu 프로세서 하나의 집계 데이터를 돌려줍니다. 프로세서 번호는 0부터 _system_configuration.ncpus까지 연속된 번호이며, 동적 재구성이 있었으면 호출마다 다른 프로세서를 가리킬 수 있습니다.
pm_get_data_lcpu, pm_get_tdata_lcpu, pm_get_Tdata_lcpu 논리 프로세서 하나의 집계 데이터를 돌려줍니다. 논리 프로세서 번호는 연속되지 않으며, 지정한 논리 프로세서가 마지막 pm_set_program 호출 이후 온라인이었던 적이 없으면 오류를 돌려줍니다. 논리 프로세서 번호는 동적 재구성이 있어도 늘 같은 프로세서를 가리킵니다. 모든 프로세서의 데이터를 얻으려면 0부터 _system_configuration.max_ncpus까지 반복해 부릅니다.
pm_reset_data 성능 모니터 집계 데이터를 초기화합니다. 모든 값이 0이 됩니다.
영어 원문

Basic pmapi library calls

Each of the following sections describes a system-wide API call that has variations for first- and third-party kernel thread or group counting. Variations are indicated by suffixes to the function call names, such as pm_set_program, pm_set_program_mythread, and pm_set_program_group.

pm_set_program

Sets the counting configuration. Use this call to specify the events (as a list of event identifiers, one per counter, or as a single event-group identifier) to be counted, and a mode in which to count. The list of events to choose from is returned by the pm_init routine. If the list includes a thresholdable event, you can also use this call to specify a threshold, and a threshold multiplier.

The mode in which to count can include user-mode and kernel-mode counting, and whether to start counting immediately. For the system-wide API call, the mode also includes whether to turn counting on only for a process and its descendants or for the whole system. For counting group API calls, the mode includes the type of counting group to create, that is, a group containing the initial thread and its future descendants, or a process-level group, which includes all the threads in a process.

By default, the time spent during interrupts handling is counted. It is possible to override this default behavior by modifying the counting mode.

pm_get_program

Retrieves the current Performance Monitor settings. This includes mode information and the list of events (or the event group) being counted. If the list includes a thresholdable event, this call also returns a threshold and the multiplier used.

pm_delete_program

Deletes the Performance Monitor configuration. Use this call to undo pm_set_program.

pm_start, pm_tstart

Starts Performance Monitor counting. pm_tstart returns a timestamp associated with the time the Performance Monitoring counters started counting. This is a timebase value that can be converted to time using time_base_to_time.

pm_stop, pm_tstop

Stops Performance Monitor counting. pm_tstop returns a timestamp associated with the time the Performance Monitoring counters stopped counting. This is a timebase value that can be converted to time using time_base_to_time.

pm_get_data, pm_get_tdata, pm_get_Tdata

Returns Performance Monitor counting data. The data is a set of 64-bit values, one per hardware counter. For the counting group API calls, the group information is also returned. (See Thread counting-group information.)

pm_get_tdata is similar to pm_get_data, but includes a timestamp that indicates the last time that the hardware Performance Monitoring counters were read. This is a timebase value that can be converted to time by using time_base_to_time.

pm_get_Tdata is also similar to pm_get_data but includes accumulated times corresponding to the interval during which the hardware Performance Monitoring counters were active. The

interval is measured in real time, PURR and SPURR (on processors supporting those) values, and returned in timebase units convertable to time using time_base_to_time.

The pm_get_data_cpu, pm_get_tdata_cpu and pm_get_Tdata_cpu interfaces return the Performance Monitor counting data for a single processor. The specified processor number represents a contiguous number going from 0 to _system_configuration.ncpus. This number can represent a different processor from call to call if dynamic reconfiguration operations have occurred.

The pm_get_data_lcpu, pm_get_tdata_lcpu and pm_get_Tdata_lcpu interfaces return the Performance Monitor counting data for a single logical processor. The logical processor numbering is not contiguous, and the call to these interfaces returns an error if the specified logical processor has not been on line since the last call to pm_set_program. A logical processor number always designates the same processor even if dynamic reconfiguration operations have occurred. To get data for all processors, these interfaces must be called in a loop from 0 to _system_configuration.max_ncpus.

pm_reset_data

Resets Performance Monitor counting data. All values are set to 0.

스레드 집계 그룹 정보

pm_get_data_mygroup과 pm_get_data_pgroup 인터페이스는 pm_groupinfo_t 구조체에 다음 정보를 돌려줍니다.

스레드 집계 그룹마다 연결된 정보입니다.

항목 설명
member count 그룹에 속한 스레드 수. 실행 중에 그룹 구성원이었다가 끝난 스레드도 포함합니다. 일관성 플래그가 켜져 있으면 그룹 수준 데이터에 기여한 스레드 수입니다.
process flag 그룹이 프로세스의 모든 스레드를 담고 있음을 나타냅니다.
consistency flag 그룹의 PM 데이터가 구성원 스레드들의 개별 PM 데이터 합과 일치함을 나타냅니다.
영어 원문

Thread counting-group information

This the following information is returned by the pm_get_data_mygroup and pm_get_data_pgroup interfaces in a pm_groupinfo_t structure.

The following information is associated with each thread counting-group:

member count

The number of threads that are members of the group. This includes deceased threads that were members of the group when running.

If the consistency flag is on, the count will be the number of threads that have contributed to the group-level data.

process flag

Indicates that the group includes all the threads in the process.

consistency flag

Indicates that the group PM data is consistent with the sum of the individual PM data for the thread members.

카운터 다중화 모드

카운터 다중화(multiplexing)를 쓰면 하드웨어 카운터 수보다 많은 이벤트를 셀 수 있습니다. 성능 특성이 고른 작업 부하를 분석하려고 만든 모드로, 카운터보다 많은 이벤트를 모으려고 작업 부하를 여러 번 돌리지 않아도 됩니다.

이 모드에서 pmapi는 주기적으로 집계 설정을 바꾸며 여러 이벤트 집합의 값과 집계 시간을 누적합니다. 다음 집합으로 바꾸기 전에 각 이벤트 집합을 세는 시간은 10ms~30s이며 기본은 100ms입니다.

돌려주는 값에는 모든 이벤트 집합을 센 횟수와, 집합마다 누적 카운터 값과 그 집합을 센 누적 시간이 들어갑니다. 누적 시간은 최대 세 가지로 잽니다. Time Base로 재고, 쓸 수 있으면 PURR 시간과 SPURR 시간으로도 잽니다. 이 시간은 timebase 형식이며 time_base_to_time 함수로 시각으로 바꿀 수 있습니다. 전체 측정 구간에 걸쳐 결과를 정규화하는 데 씁니다.

몇몇 기본 pmapi 호출에는 _mx 접미사가 붙는 다중화 모드 변형이 있습니다.

호출 설명
pm_set_program_mx 집계 구성을 정합니다. pm_set_program과 달리 셀 그룹(또는 이벤트 목록)의 집합과, 다음 집합으로 바꾸기 전에 각 집합을 셀 시간을 받습니다.
pm_get_program_mx 현재 성능 모니터 설정을 가져옵니다. pm_get_program과 달리 그룹(또는 이벤트 목록)의 집합을 돌려줍니다.
pm_get_data_mx 집계 데이터를 돌려줍니다. 구성한 그룹(또는 이벤트 목록)마다 하나씩인 집계 데이터 집합이며, 누적 카운터 값에 더해 구성한 모든 집합을 센 횟수와 집합마다 센 누적 시간이 들어갑니다.
pm_get_tdata_mx pm_get_data_mx와 같고, 하드웨어 카운터를 마지막으로 읽은 시각의 타임스탬프가 더해집니다.
pm_get_data_cpu_mx, pm_get_tdata_cpu_mx pm_get_data_mx나 pm_get_tdata_mx와 같지만 프로세서 하나의 데이터를 돌려줍니다. 프로세서 번호는 0부터 _system_configuration.ncpus 사이여야 하며, 동적 재구성이 있었으면 호출마다 다른 프로세서를 가리킬 수 있습니다.
pm_get_data_lcpu_mx, pm_get_tdata_lcpu_mx pm_get_data_cpu_mx나 pm_get_tdata_cpu_mx와 같지만 논리 프로세서 하나의 데이터를 돌려줍니다. 논리 프로세서 번호는 연속되지 않고, 마지막 pm_set_program_mx 호출 이후 온라인이었던 적이 없으면 오류를 돌려줍니다. 번호는 동적 재구성이 있어도 늘 같은 프로세서를 가리키며, 모든 프로세서의 데이터는 0부터 _system_configuration.max_ncpus까지 반복해 얻습니다.
영어 원문

Counter multiplexing mode

You can set the counting for more events than available hardware counters using counter multiplexing. This mode is meant to be used to analyze workloads with homogenous performance characteristics. This avoids the requirement to run the workload multiple times to collect more events than available hardware counters.

In this mode, the pmapi periodically changes the setting of the counting and accumulates values and counting time for multiple sets of events. The time each event set is counted before switching to the next set can be in the range of 10 ms to 30 s. The default value is 100 ms.

The values returned include the number of times all sets of events have been counted, and for each set, the accumulated counter values and the accumulated time the set was counted. The accumulated time is measured up to three different ways: using Time Base, and when available, using the PURR time and one the SPURR time. These times are stored in a timebase format that can be converted to time by using the time_base_to_time function. These times are meant to be used to normalize the results across the complete measurement interval.

Several basic pmapi calls have the following multiplexing mode variations indicated by the _mx suffix:

pm_set_program_mx

Sets the counting configuration. It differs from the pm_set_program function in that it accepts a set of groups (or event lists) to be counted, and the time each set must be counted before switching to the next set.

pm_get_program_mx

Retrieves the current Performance Monitor settings. It differs from the pm_get_program function in that it returns a set of groups (or event lists).

pm_get_data_mx

Returns the Performance Monitor counting data. It returns a set of counting data, one per group (or event list) configured. The returned data includes in addition to the accumulated counter values, the number of times all the configured sets have been counted, and for each set, the accumulated time it was counted.

pm_get_tdata_mx

Same as pm_get_data_mx, but includes a timestamp indicating the last time that the hardware Performance Monitor counters were read.

pm_get_data_cpu_mx/pm_get_tdata_cpu_mx

Same as pm_get_data_mx or pm_get_tdata_mx, but returns the Performance Monitor counting data for a single processor. The specified processor number must be in the range 0 to _system_configuration.ncpus. This number might represent different processors from call to call if dynamic reconfiguration operations have occurred.

pm_get_data_lcpu_mx/pm_get_tdata_lcpu_mx

Same as pm_get_data_cpu_mx or pm_get_tdata_cpu_mx, but returns the Performance Monitor counting data for a single logical processor. The logical processor numbering is not contiguous, and the call to these interfaces return an error if the specified logical processor has not been online since the last call to pm_set_program_mx. A logical processor number always designates the same processor even if dynamic reconfiguration operations have occurred. To get data for all processors, these interfaces must be called in a loop from 0 to _system_configuration.max_ncpus.

(6.1) 카운터 다중 모드

카운터 다중 모드(multi-mode)는 다중화 모드와 비슷합니다. 다중화 모드에서는 집계 모드가 모든 이벤트 집합에 공통입니다.

다중 모드에서는 이벤트 집합마다 집계 모드를 따로 줄 수 있습니다. 대신 집합마다 집계 모드가 다르므로 전체 측정 구간에 걸쳐 결과를 정규화할 수 없습니다.

몇몇 기본 pmapi 호출에는 _mm 접미사가 붙는 다중 모드 변형이 있습니다.

호출 설명
pm_set_program_mm 집계 구성을 정합니다. pm_set_program_mx와 달리 셀 그룹 집합과 그룹마다의 집계 모드를 받습니다.
pm_get_program_mm 현재 성능 모니터 설정을 가져옵니다. pm_get_program_mx와 달리 그룹 집합과 그룹마다의 집계 모드를 다룹니다.
영어 원문

Counter multi-mode

Counter multi-mode is similar to multiplexing mode. The counting mode in multiplexing mode is common to all the event sets.

The multi-mode allows you to associate a counting mode with each event set, but as the counting mode differs for an event set to another one, the results of the counting cannot be normalized on the complete measurement interval.

Several basic pmapi calls have the following multi-mode variations indicated by the _mm suffix:

pm_set_program_mm

Sets the counting configuration. It differs from the pm_set_program_mx function in that it accepts a set of groups and associated counting mode to be counted.

pm_get_program_mm

Retrieves the current Performance Monitor settings. It differs from the pm_get_program_mx function in that it accepts a set of groups and associated counting mode.

(6.1) WPAR 집계

전역 WPAR에서 특정 WPAR의 시스템 전체 활동을 감시할 수 있습니다. 이때는 그 WPAR 안에서 실행되는 프로세스의 활동만 감시합니다.

몇몇 기본 pmapi 호출에는 _wp 접미사가 붙는 WPAR별 변형이 있습니다.

호출 설명
pm_set_program_wp, pm_set_program_wp_mm pm_set_program이나 pm_set_program_mm과 같지만, 지정한 WPAR(WPAR Configured ID로 식별)에만 프로그래밍을 설정합니다. pm_set_program_wp_mx는 없습니다.
pm_get_program, pm_get_program_wp pm_get_program과 같지만 지정한 WPAR(WPAR Configured ID로 식별)의 프로그래밍만 가져옵니다. pm_get_program_wp_mx는 없습니다.
pm_start_wp, pm_tstart_wp pm_start나 pm_tstart와 같지만 특정 WPAR(WPAR Configured ID로 식별)를 대상으로 합니다.
pm_stop_wp, pm_tstop_wp pm_stop이나 pm_tstop과 같지만 특정 WPAR(WPAR Configured ID로 식별)를 대상으로 합니다.
pm_get_data_wp, pm_get_tdata_wp, pm_get_Tdata_wp pm_get_data, pm_get_tdata, pm_get_Tdata와 같지만 지정한 WPAR(핸들로 식별, pm_get_wplist 참고)의 집계 데이터만 가져옵니다.
pm_reset_data_wp 원문은 pm_get_data_wp와 같은 설명을 되풀이하지만, 지정한 WPAR의 집계 데이터를 초기화하는 호출입니다.
pm_get_wplist 마지막 시스템 전체 집계 동안 활성이었던 WPAR 문맥 목록을 가져옵니다. WPAR 문맥에는 WPAR Configured ID, WPAR 이름, WPAR를 유일하게 식별하는 WPAR 핸들이 들어 있습니다. 이 핸들로 pm_get_data_wp 계열 서브루틴을 불러 특정 WPAR의 집계 데이터를 얻습니다.
영어 원문

WPAR counting

It is possible to monitor the system-wide activity of a specific WPAR from the Global WPAR. In this case, only the activity of the processes running in this WPAR will be monitored.

Several basic pmapi calls have the following per-WPAR variations indicated by the _wp suffix:

pm_set_program_wp, pm_set_program_wp_mm

Same as the pm_set_program subroutine or the pm_set_program_mm subroutine, except that the

programming is set for the specified WPAR only (identified by its WPAR Configured ID). Notice that there is no pm_set_program_wp_mx subroutine.

pm_get_program, pm_get_program_wp

Same as the pm_get_program subroutine or the pm_get_program_wp subroutine, except that it retrieves the programming for the specified WPAR only (identified by its WPAR Configured ID). Notice that there is no pm_get_program_wp_mx subroutine.

pm_start_wp, pm_tstart, pm_start_wp, pm_tstart_wp

Same as the pm_start subroutine or the pm_tstartsubroutine, except that it targets a specific WPAR (identified by its WPAR Configured ID).

pm_stop_wp, pm_tstop, pm_stop_wp, pm_tstop_wp

Same as the pm_stop subroutine or the pm_tstop subroutine, except that it targets a specific WPAR (identified by its WPAR Configured ID).

pm_get_data_wp, pm_get_tdata_wp, pm_get_Tdata

Same as the pm_get_data subroutine or the pm_get_tdata subroutine or the pm_get_Tdata subroutine, except that it retrieves Performance Monitor counting data for the specified WPAR only (identified by its handle, see the pm_get_wplist subroutines).

pm_reset_data

Same as the pm_get_data routine or the pm_get_tdatasburoutine or the pm_get_Tdata subroutine, except that it retrieves Performance Monitor counting data for the specified WPAR only (identified by its handle, see the pm_get_wplist subroutines).

pm_get_wplist

Retrieves the list of WPARs contexts that were active during the last system-wide counting. A WPAR context includes the WPAR Configured ID, the WPAR name, and a WPAR handle that uniquely identifies the WPAR. The WPAR handle can then be used to retrieve the Performance Monitor counting data for a specified WPAR using one of the pm_get_data_wp subroutines.

pmapi 라이브러리 사용 예

다음 예는 성능 모니터 API의 사용법을 의사 코드로 보여 줍니다. 실제로 동작하는 예제 코드는 /usr/samples/pmapi 디렉터리에 있습니다.

단일 스레드 프로그램 예

text
# include <pmapi.h>
main()
{
       pm_info_t pminfo;
       pm_prog_t prog;
       pm_data_t data;
       int filter = PM_VERIFIED; /* use only verified events */
       pm_init(filter, &pminfo)
       prog.mode.w       = 0;  /* start with clean mode */
       prog.mode.b.user  = 1;  /* count only user mode */
       for (i = 0; i < pminfo.maxpmcs; i++)
                prog.events[i] = COUNT_NOTHING;
       prog.events[0]    = 1;  /* count event 1 in first counter */
       prog.events[1]    = 2;  /* count event 2 in second counter */
       pm_set_program_mythread(&prog);
       pm_start_mythread();
(1)    ... usefull work ....
       pm_stop_mythread();
       pm_get_data_mythread(&data);
       ... print results ...
}

이벤트 그룹으로 초기화하는 예

text
# include <pmapi.h>
main()
{
       pm_info2_t        pminfo;
       pm_prog_t        prog;
       pm_groups_info_t pmginfo;
       int filter = PM_VERIFIED;  /* get list of verified events */
       pm_initialize(filter, &pminfo, &pmginfo, PM_CURRENT )
       prog.mode.w           = 0;  /* start with clean mode */
       prog.mode.b.user      = 1;  /* count only user mode */
       prog.mode.b.is_group  = 1;  /* specify event group */
       for (i = 0; i < pminfo.maxpmcs; i++)
                prog.events[i] = COUNT_NOTHING;
       prog.events[0]    = 1;  /* count events in group 1 */
       .....
}

특정 프로세서가 지원하는 모든 이벤트 그룹 정보를 얻는 예

text
#include <stdio.h>
#include <stdlib.h>
#include <pmapi.h>
int main()
{
 int rc = 0;
 pm_info2_t events;
 pm_groups_info_t groups;
 pm_events2_t *ev_ptr = NULL;
 int filter = 0;
 /*
 * Get the events and groups supported for POWER4.
  * To get the events and groups supported for the current processor,
  * use PM_CURRENT.
 */
 int processor_type = PM_POWER4;
 int group_idx = 0;
 int counter_idx = 0;
 int ev_count = 0;
 int event_found = 0;
 /*
  * PM_VERIFIED    - To get list of verified events
  * PM_UNVERIFIED - To get list of unverified events
  * PM_CAVEAT    - To get list of events that are usable but with caveats
  */
 filter |= PM_VERIFIED | PM_UNVERIFIED | PM_CAVEAT;
 /* Get list of events-groups */
 filter |= PM_GET_GROUPS;
  if ((rc = pm_initialize(filter, &events, &groups, processor_type)) != 0)
 {
   pm_error("pm_initialize", rc);
   exit(-1);
  }
for(group_idx = 0; group_idx < groups.maxgroups; group_idx++)
 {
  printf("================================\n");
  printf("Group ID: %d.\n", groups.event_groups[group_idx].group_id);
  printf("Group Name: %s.\n", groups.event_groups[group_idx].short_name);
  printf("Group Long Name: %s.\n", groups.event_groups[group_idx].long_name);
  printf("Group Description: %s.\n", groups.event_groups[group_idx].description);
  printf("Events in this Group: \n");
  for(counter_idx = 0; counter_idx < events.maxpmcs; counter_idx++)
  {
   event_found = 0;
   for(ev_ptr = events.list_events[counter_idx], ev_count = 0;
    ev_count < events.maxevents[counter_idx];
    ev_ptr++, ev_count++)
   {
    /* If the event ID in "groups" matches with event ID supported
     * in the counter */
    if(groups.event_groups[group_idx].events[counter_idx] == ev_count)
    {
     printf("\tCounter ID: %d.\n", counter_idx+1);
     printf("\tEvent ID: %d.\n", ev_count);
     printf("\tEvent Name: %s.\n", ev_ptr->short_name);
     event_found = 1;
     break;
    }
        /* We have found the event for this counter. Move on to
     * next counter. */
    if(event_found) break;
   }
  }
  printf("\n");
 }
 return 0;
}

초기화 프로그램을 디버거에서 살펴보는 예

프로그램이 실행되는 동안 성능 모니터 데이터를 살펴보는 방법입니다.

text
from a debugger at breakpoint (1)
       pm_initialize(filter);
(2)    pm_get_program_pthread(pid, tid, ptid, &prog);
       ... display PM programmation ...
(3)    pm_get_data_pthread(pid, tid, ptid);
       ... display PM data ...
       pm_delete_program_pthread(pid, tid, ptid);
       prog.events[0] = 2; /* change counter 1 to count event number 2 */
       pm_set_program_pthread(pid, tid, ptid, &prog);
continue program

디버거에서 실행하는 프로그램에 성능 모니터 API 호출이 하나도 없어도 위 시나리오는 그대로 됩니다. 다른 점은 (2)와 (3)의 호출이 실패하고, 프로그램이 계속되면 카운터 1에서 이벤트 2번만 세고 다른 카운터는 아무것도 세지 않는다는 것뿐입니다.

(6.1) 전역 WPAR에서 WPAR 하나 세기

text
main ()
{
        pm_prog_t prog;
        pm_wpar_ctx_info_t wp_list;
        int nwpars = 1;
        cid_t cid;
        /* set programming for WPAR ``wpar1’’ */
        getcorralid("wpar1", &cid);
        pm_set_program_wp(cid, &prog);
        pm_start_wp(cid);
        ... workload ...
        pm_stop_wp(cid);
        /* retrieve data for WPAR ``wpar1’’ */
        pm_get_wplist("wpar1", &wp_list, &nwpars);
        pm_get_data_wp(wp_list.wp_handle, &data);
        pm_delete_program_wp(cid);
}

(6.1) 전역 WPAR에서 활성 WPAR 모두를 세고 WPAR별 데이터 얻기

text
main ()
{
        pm_prog_t prog;
        pm_wpar_ctx_info_t *wp_list;
        int nwpars;
        /* set programming */
        ...
        prog.mode.b.wpar_all = 1;  /* collect per-WPAR data */
        pm_set_program(&prog);
        pm_start();
        ... workload ...
        pm_stop();
        /* retrieve the number of WPARs that were active during the counting */
        nwpars = 0;
        pm_get_wplist(NULL, NULL, &nwpars);
        /* allocate an array large enough to retrieve WPARs contexts */
        wp_list = malloc(nwpars * sizeof (pm_wpar_ctx_info_t));
        /* retrieve WPARs contexts */
        pm_get_wplist(NULL, wp_list, &nwpars);
        /* retrieve and print data for each WPAR */
        for (i = 0; i < nwpars; i++) {
            printf("WPAR: %s (CID=%d)\n", wp_list[i].name, wp_list[i].cid);
            pm_get_data_wp(wp_list[i].hwpar, &data);
        }
        free(wp_list);
        pm_delete_program();
}

간단한 다중 스레드 예

독립된 스레드들이 같은 이벤트 집합을 세는 예입니다.

text
# include <pmapi.h>
pm_data_t data2;
void *
doit(void *)
{
(1)    pm_start_mythread();
       ... usefull work ....
       pm_stop_mythread();
       pm_get_data_mythread(&data2);
}
main()
{
       pthread_t threadid;
       pthread_attr_t attr;
       pthread_addr_t status;
       ... same initialization as in previous example ...
       pm_program_mythread(&prog);
       /* setup 1:1 mode */
       pthread_attr_init(&attr);
       pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
       pthread_create(&threadid, &attr, doit, NULL);
(2)    pm_start_mythread();
       ... usefull work ....
       pm_stop_mythread();
       pm_get_data_mythread(&data);
       ... print main thread results (data )...
       pthread_join(threadid, &status);
       ... print auxiliary thread results (data2) ...
}

위 예에서 처음 집계 상태가 꺼져 있었고 보조 스레드가 그 상태를 만든 스레드에서 물려받았으므로, 주 스레드와 보조 스레드는 각각 (1)과 (2)에서 세기 시작합니다.

간단한 스레드 집계 그룹 예

집계 그룹에 스레드 두 개가 있는 예입니다. 보조 스레드의 초기화 루틴 본문은 앞의 예와 같습니다.

text
main()
{
        ... same initialization as in previous example ...
        pm_set_program_mygroup(&prog); /* create counting group */
(1)     pm_start_mygroup()
        pthread_create(&threadid, &attr, doit, NULL)
(2)     pm_start_mythread();
        ... usefull work ....
        pm_stop_mythread();
        pm_get_data_mythread(&data)
        ... print main thread results ...
        pthread_join(threadid, &status);
        ... print auxiliary thread results ...
        pm_get_data_mygroup(&data)
        ... print group results ...
}

위 예에서 (1)의 호출은 그룹의 집계만 켜고 그 안의 개별 스레드는 켜지 않으므로 (2)의 호출이 필요합니다. 끝에 그룹 결과는 두 스레드 결과의 합입니다.

카운터 다중화를 쓰는 스레드 집계 그룹 예

집계 그룹에 스레드 두 개가 있습니다. 보조 스레드의 초기화 루틴 본문은 앞의 예와 같습니다.

text
main()
{
        pm_info2_t         pminfo;
        pm_groups_info_t   pmginfo;
        pm_prog_mx_r       prog;
        pm_events_prog_t   event_set[2];
        pm_data_mx_t       data;
        int filter = PM_VERIFIED;  /* get list of verified events */
        pm_initialize(filter, &pminfo, &pmginfo, PM_CURRENT )
        prog.mode.w           = 0;  /* start with clean mode */
        prog.mode.b.user      = 1;  /* count only user mode */
        prog.mode.b.is_group  = 1;  /* specify event group */
        prog.events_set       = event_set;
        prog.nb_events_prog   = 2;   /* two event group counted */
        prog.slice_duration   = 200; /* slice duration for each event group is 200ms */
        for (i = 0; i < pminfo.maxpmcs; i++) {
                event_set[0][i] = COUNT_NOTHING;
                event_set[1][i] = COUNT_NOTHING;
        }
        event_set[0][0]     = 1;   /* count events in group 1 in the first set */
        event_set[1][0]     = 3;   /* count events in group 3 in the first set */
        pm_set_program_mygroup_mx(&prog); /* create counting group */
        pm_start_mygroup()
        pthread_create(&threadid, &attr, doit, NULL)
        pm_start_mythread();
        ... usefull work ....
        pm_stop_mythread();
        pm_get_data_mythread_mx(&data)
        printf ("Main thread results:\n");
        for (i = 0; i < 2 ; i++) {
                group_number = event_set[i][0];
                printf ("Group #%d: %s\n", group_number, pmginfo.event_groups[group_number].short_name);
                printf ("    counting time: %d ms\n", data.accu_set[i].accu_time);
                printf ("    counting values:\n");
                for (counter = 0; counter < pminfo.maxpmcs; counter++) {
                        printf ("event %d: %d\n", counter, data.accu_set[i].accu_data[counter]);
                }
        }
  (1)   free(data.accu_set);   /* free the memory alloacted for the main thread results */
        pthread_join(threadid, &status);
        ... print auxiliary thread results ...
        free(data.accu_set);   /* free the memory allocated for the thread results */
        pm_get_data_mygroup_mx(&data)
        ... print group results ...
        free(data.accu_set);   /* free the memoory allocated for the group results */
        pm_delete_program()
}
(1) Each time data are got in time slice mode, the buffer allocated to return the counters */
must be freed after used.

(6.1) 카운터 다중화와 다중 모드를 쓰는 스레드 집계 그룹 예

집계 그룹에 스레드 두 개가 있으며 보조 스레드의 초기화 루틴 본문은 앞의 예와 같습니다. 앞의 예와 비슷하지만 다중 모드를 써서 셀 그룹마다 모드를 연결합니다.

text
main()
{
        pm_info2_t         pminfo;
        pm_groups_info_t   pmginfo;
        pm_prog_mm_t       prog;
        pm_data_mx_t       data;
        pm_prog_t          prog_set[2];
        int filter = PM_VERIFIED;  /* get list of verified events */
        pm_initialize(filter, &pminfo, &pmginfo, PM_CURRENT );
        prog.prog_set = prog_set;
        prog.nb_set_prog   = 2;      /* two groups counted */
        prog.slice_duration   = 200; /* slice duration for each event group is 200ms */
        prog_set[0].mode.w           = 0;  /* start with clean mode */
        prog_set[0].mode.b.user      = 1;  /* grp 0: count only user mode */
        prog_set[0].mode.b.is_group  = 1;  /* specify event group */
        prog_set[0].mode.b.proctree  = 1;  /* turns process tree counting on:
                                              this option is common to all counted groups */
        prog_set[1].mode.w           = 0;  /* start with clean mode */
        prog_set[1].mode.b.kernel    = 1;  /* grp 1: count only kernel mode */
        prog_set[1].mode.b.is_group  = 1;  /* specify event group */
        for (i = 0; i < pminfo.maxpmcs; i++) {
                prog_set[0].events[i] = COUNT_NOTHING;
                prog_set[1].events[i] = COUNT_NOTHING;
        }
        prog_set[0].events[0]     = 1;   /* count events in group 1 in the first set */
        prog_set[1].events[0]     = 3;   /* count events in group 3 in the first set */
        pm_set_program_mygroup_mm(&prog); /* create counting group */
        pm_start_mygroup();
        pthread_create(&threadid, &attr, doit, NULL);
        pm_start_mythread();
        ... usefull work ....
        pm_stop_mythread();
        pm_get_data_mythread_mx(&data);
        printf ("Main thread results:\n");
        for (i = 0; i < 2 ; i++) {
                group_number = prog_set[i].events[0];
                printf ("Group #%d: %s\n", group_number, pmginfo.event_groups[group_number].short_name);
                printf ("    counting time: %d ms\n", data.accu_set[i].accu_time);
                printf ("    counting values:\n");
                for (counter = 0; counter < pminfo.maxpmcs; counter++) {
                        printf ("event %d: %d\n", counter, data.accu_set[i].accu_data[counter]);
                }
        }
  (1)   free(data.accu_set);   /* free the memory allocated for the main thread results */
        pthread_join(threadid, &status);
        ... print auxiliary thread results ...
        free(data.accu_set);   /* free the memory allocated for the thread results */
        pm_get_data_mygroup_mx(&data)
        ... print group results ...
        free(data.accu_set);   /* free the memory allocated for the group results */
        pm_delete_program();
}
(1) Each time data are got in time slice mode, the buffer allocated to return the
counters must be freed after used.
}

초기화(reset)가 있는 스레드 집계 예

초기화 호출이 그룹 데이터에 주는 영향을 보여 주는 예입니다. 보조 스레드 본문은 앞과 같지만 이 경우 pm_start_mythread 호출은 필요 없습니다.

text
main()
{
        ... same initialization as in previous example...
        prog.mode.b.count  = 1;  /* start counting immediately */
        pm_set_program_mygroup(&prog);
        pthread_create(&threadid, pthread_attr_default, doit, NULL)
        ... usefull work ....
        pm_stop_mythread()
        pm_reset_data_mythread()
        pthread_join(threadid, &status);
        ...print auxiliary thread results...
        pm_get_data_mygroup(&data)
        ...print group results...
}

위 예에서 보조 스레드를 만들기 전에 주 스레드와 그룹의 집계 상태가 모두 켜져 있으므로, 보조 스레드는 그 상태를 물려받아 바로 세기 시작합니다.

끝에 data1은 data와 같습니다. pm_reset_data_mythread가 그룹 데이터를 일관되게 유지하려고 주 스레드 데이터를 그룹 데이터에서 자동으로 뺐기 때문입니다. 실제로 그룹 데이터는 여전히 보조 스레드와 주 스레드 데이터의 합과 같지만, 이 경우 주 스레드 데이터가 0입니다.

영어 원문

Examples of pmapi library usage

The following examples demonstrate the use of Performance Monitor APIs in pseudo-code. Functional sample code is available in the /usr/samples/pmapi directory.

Simple single-threaded program example

The following example displays a single-threaded program.

(21줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Initialization example using an event group

The following example displays initialization using an event group.

(16줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Get the information about all the event-groups for a specific processor example:

The following example displays how to obtain all the event-groups that are supported for a specific processor.

(67줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Debugger program example for initialization program

The following example illustrates how to look at the performance monitor data while the program is executing.

text
from a debugger at breakpoint (1)
       pm_initialize(filter);
(2)    pm_get_program_pthread(pid, tid, ptid, &prog);
       ... display PM programmation ...
(3)    pm_get_data_pthread(pid, tid, ptid);
       ... display PM data ...
       pm_delete_program_pthread(pid, tid, ptid);
       prog.events[0] = 2; /* change counter 1 to count event number 2 */
       pm_set_program_pthread(pid, tid, ptid, &prog);
continue program

The preceding scenario would also work if the program being executed under the debugger did not have any embedded Performance Monitor API calls. The only difference would be that the calls at (2) and (3) would fail, and that when the program continues, it will be counting only event number 2 in counter 1, and nothing in other counters.

Count a single WPAR from the Global WPAR

The following program is an example of a count of a single WPAR from the global WPAR.

(17줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Count all active WPARs from the Global WPAR and retrieve per-WPAR data:

The following program is an example of a count of all active WPARS from the global WPAR and also retrieves per-WPAR data.

(27줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Simple multi-threaded example

The following is a simple multi-threaded example with independent threads counting the same set of events.

(29줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

In the preceding example, counting starts at (1) and (2) for the main and auxiliary threads respectively because the initial counting state was off and it was inherited by the auxiliary thread from its creator.

Simple thread counting-group example

The following example has two threads in a counting-group. The body of the auxiliary thread's initialization routine is the same as in the previous example.

(16줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

In the preceding example, the call in (2) is necessary because the call in (1) only turns on counting for the group, not the individual threads in it. At the end, the group results are the sum of both threads results.

Simple thread counting-group with counter-multiplexing example:

The following example has two threads in a counting-group. The body of the auxiliary thread's initialization routine is the same as in the previous example.

(49줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Simple thread counting-group with counter-multiplexing and multi-mode example:

The following example has two threads in a counting-group. The body of the auxiliary thread's initialization routine is the same as in the previous example.

This example is similar to the previous one except that it uses the multi-mode functionality, and associates a mode with each group counted.

(55줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

Thread counting example with reset

The following example with a reset call illustrates the impact on the group data. The body of the auxiliary thread is the same as before, except for the pm_start_mythread call, which is not necessary in this case.

(14줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

In the preceding example, the main thread and the group counting state are both on before the auxiliary thread is created, so the auxiliary thread will inherit that state and start counting immediately.

At the end, data1 is equal to data because the pm_reset_data_mythread automatically subtracted the main thread data from the group data to keep it consistent. In fact, the group data remains equal to the sum of the auxiliary and the main thread data, but in this case, the main thread data is null.

자주 쓰는 형태

bash
pmcycles -m                 # 프로세서 클록 속도
pmlist -l                   # 지원하는 이벤트 그룹 목록
pmlist -g -1                # 모든 그룹과 그룹에 든 이벤트
ls /usr/samples/pmapi       # 예제 소스