• Thomas Richter's avatar
    s390/cpumf: Add support for complete counter set extraction · cf6acb8b
    Thomas Richter authored
    Add support to the CPU Measurement counter facility device driver
    to extract complete counter sets per CPU and per counter set from user
    space. This includes a new device named /dev/hwctr and support
    for the device driver functions open, close and ioctl. Other
    functions are not supported.
    
    The ioctl command supports 3 subcommands:
    S390_HWCTR_START: enables counter sets on a list of CPUs.
    S390_HWCTR_STOP: disables counter sets on a list of CPUs.
    S390_HWCTR_READ: reads counter sets on a list of CPUs.
    
    The ioctl(..., S390_HWCTR_READ, ...) is the only subcommand which
    returns data.  It requires member data_bytes to be positive and
    indicates the maximum amount of data available to store counter set
    data. The other ioctl() subcommands do not use this member and it
    should be set to zero.
    The S390_HWCTR_READ subcommand returns the following data:
    
    The cpuset data is flattened using the following scheme, stored in member
    data:
    
     0x0       0x8   0xc       0x10  0x10      0x18  0x20  0x28         0xU-1
     +---------+-----+---------+-----+---------+-----+-----+------+------+
     | no_cpus | cpu | no_sets | set | no_cnts | cv1 | cv2 | .... | cv_n |
     +---------+-----+---------+-----+---------+-----+-----+------+------+
    
                               0xU   0xU+4     0xU+8 0xU+10             0xV-1
                               +-----+---------+-----+-----+------+------+
                               | set | no_cnts | cv1 | cv2 | .... | cv_n |
                               +-----+---------+-----+-----+------+------+
    
               0xV   0xV+4     0xV+8 0xV+c
               +-----+---------+-----+---------+-----+-----+------+------+
               | cpu | no_sets | set | no_cnts | cv1 | cv2 | .... | cv_n |
               +-----+---------+-----+---------+-----+-----+------+------+
    
    U and V denote arbitrary hexadezimal addresses.
    The first integer represents the number of CPUs data was extracted
    from. This is followed by CPU number and number of counter sets extracted.
    Both are two integer values. This is followed by the set identifer
    and number of counters extracted. Both are two integer values. This is
    followed by the counter values, each element is eight bytes in size.
    
    The S390_HWCTR_READ ioctl subcommand is also limited to one call per
    minute. This ensures that an application does not read out the
    counter sets too often and reduces the overall CPU performance.
    The complete counter set extraction is an expensive operation.
    Reviewed-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
    Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
    Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
    Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
    cf6acb8b
perf_cpum_cf_diag.h 1.65 KB