libcpumf: Detect PMU named pai_ext

Add a check to detect Processor Activity Instrumentation (PAI)
Extension 1 facility unit.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2022-06-21 13:02:46 +02:00
committed by Jan Höppner
parent dc73c77d73
commit 15158ee0ca
3 changed files with 18 additions and 1 deletions

View File

@@ -17,7 +17,8 @@
#define S390_CPUS_ONLINE "/sys/devices/system/cpu/online"
#define S390_CPUMSF_BUFFERSZ "/sys/module/kernel/parameters/cpum_sfb_size"
#define S390_SYSFS_PAI_CRYPTO "/sys/devices/pai_crypto/"
#define S390_SYSFS_PAI_NNPA "/sys/devices/pai_nnpa/"
#define S390_SYSFS_PAI_EXT "/sys/devices/pai_ext/"
#define S390_SYSFS_PAI_NNPA S390_SYSFS_PAI_EXT "events/NNPA_ALL"
/**
* Read out the PMU type from a given file.
@@ -146,6 +147,14 @@ bool libcpumf_sfb_info(unsigned long *min, unsigned long *max);
*/
bool libcpumf_have_pai_crypto(void);
/**
* Return true if PAI_EXTENSION Facility is supported.
*
* @retval true PAI_EXTENSION counter Facility is available
* @retval false PAI_EXTENSION counter Facility is not available
*/
bool libcpumf_have_pai_ext(void);
/**
* Return true if PAI_NNPA counter Facility is supported. This PMU facility
* supports the Neural Network Processing Assist (NNPA) counter set.

View File

@@ -85,5 +85,6 @@ int main(void)
}
printf("PAI NNPA support %d\n", libcpumf_have_pai_nnpa());
printf("PAI EXTENSION support %d\n", libcpumf_have_pai_ext());
return EXIT_SUCCESS;
}

View File

@@ -147,6 +147,13 @@ bool libcpumf_have_pai_crypto(void)
return (stat(S390_SYSFS_PAI_CRYPTO, &statbuf) == -1) ? false : true;
}
bool libcpumf_have_pai_ext(void)
{
struct stat statbuf;
return (stat(S390_SYSFS_PAI_EXT, &statbuf) == -1) ? false : true;
}
bool libcpumf_have_pai_nnpa(void)
{
struct stat statbuf;