Reading CPU-measurement counters for an application

Red Hat Enterprise Linux 9.2 LPAR mode

Use the perf tool to read CPU-measurement counters with the scope of an application.

Before you begin

You must know the hexadecimal value of the counter number. You can find the decimal values in z/Architecture® The Load-Program-Parameter and the CPU-Measurement Facilities, SA23-2260 and in IBM® The CPU-Measurement Facility Extended Counters Definition for z10, z196/z114, zEC12/zBC12, z13®/z13s®, z14, z15® and z16, SA23-2261.

Procedure

Issue a command of this form to read a counter:
  • Using symbolic names:
    # perf stat -e cpum_cf/<symbolic_name>/ -- <path_to_app>
  • Using raw events:
    # perf stat -e <type>:<counter_number> -- <path_to_app>
  • Using raw events without specifying the type:
    # perf stat -e cpum_cf/event=<counter_number>/ -- <path_to_app>
Where:
-e cpum_cf/<symbolic_name>/
specifies a counter through a symbolic name. Symbolic names are lengthy but meaningful and the same for all mainframes models that support the counter.
-e <type>:<counter_number>
specifies a counter as a raw event. In the specification, <counter_number> is a decimal number.

<type> is a decimal number that the kernel assigns to the CPU-measurement facilities device driver. To find that value on a running Linux® instance, read the value of /sys/devices/cpum_cf/type.

Interface change: As of Red Hat® Enterprise Linux 8.3 the notation <type>:<counter_number> replaces the former r<hex_counter_number>, where <hex_counter_number> was the counter number in hexadecimal notation.

This specification is short but abstract, the numbers can differ between hardware models, and the value for <type> can change across boot cycles.

-e cpum_cf/event=<counter_number>/
specifies a counter as a raw event. In the specification, <counter_number> is a the same decimal number as in the previous format. This format avoids the type specification.
<path_to_app>
specifies the path to the application to be evaluated. The counters are incremented for all threads that belong to the specified application. If you specify -a instead of the double hyphen and path, system-wide counter data is read.
Tip: You can read multiple counters by specifying a comma-separated list of counters. For example, with 5 as the value for <type>: -e 5:32,5:33.

For more information about the perf command, see the perf or perf-stat man page.

Examples

Issue one of the following commands to read the problem-state cycle count counter (symbolic name PROBLEM_STATE_CPU_CYCLES; decimal value 32) and the problem-state instruction count counter (symbolic name PROBLEM_STATE_INSTRUCTIONS; decimal value 33) for an application /bin/df.
  • Using symbolic names:
    # perf stat -e cpum_cf/PROBLEM_STATE_CPU_CYCLES/,\
    cpum_cf/PROBLEM_STATE_INSTRUCTIONS/ -- /bin/df 
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/dasda1            6967656   3360888   3229780  51% /
    none                    942956        88    942868   1% /dev/shm
    /dev/dasdb1            6967656   4135792   2471260  63% /root
    
     Performance counter stats for '/bin/df':
    
             1,258,624      PROBLEM_STATE_CPU_CYCLES                                    
               341,792      PROBLEM_STATE_INSTRUCTIONS                                   
    
           0.002676094 seconds time elapsed
  • Using raw events:
    # cat /sys/devices/cpum_cf/type
    5
    # perf stat -e 5:32,5:33 -- /bin/df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/dasda1            6967656   3360884   3229784  51% /
    none                    942956        88    942868   1% /dev/shm
    /dev/dasdb1            6967656   4135792   2471260  63% /root
    
     Performance counter stats for '/bin/df':
    
             1,233,295      5:32                                                         
               341,792      5:33                                                         
    
           0.002526281 seconds time elapsed