libcpumf: Detect PMU pai_nnpa

Add a check to detect Processor Activity Instrumentation (PAI)
Extension 1 facility unit. This covers the counter set for
Neural Network Processing Assist (NNPA) counters.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2022-05-05 10:54:38 +02:00
committed by Jan Höppner
parent d7b1cbad8b
commit 130880159a
3 changed files with 19 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
#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/"
/**
* Read out the PMU type from a given file.
@@ -144,4 +145,13 @@ bool libcpumf_sfb_info(unsigned long *min, unsigned long *max);
* @retval false PAI_CRYPTO counter Facility is not available
*/
bool libcpumf_have_pai_crypto(void);
/**
* Return true if PAI_NNPA counter Facility is supported. This PMU facility
* supports the Neural Network Processing Assist (NNPA) counter set.
*
* @retval true PAI_NNPA counter Facility is available
* @retval false PAI_NNPA counter Facility is not available
*/
bool libcpumf_have_pai_nnpa(void);
#endif

View File

@@ -83,5 +83,7 @@ int main(void)
printf("PMU type 10 PMU name %s\n", pmuname);
free(pmuname);
}
printf("PAI NNPA support %d\n", libcpumf_have_pai_nnpa());
return EXIT_SUCCESS;
}

View File

@@ -146,3 +146,10 @@ bool libcpumf_have_pai_crypto(void)
return (stat(S390_SYSFS_PAI_CRYPTO, &statbuf) == -1) ? false : true;
}
bool libcpumf_have_pai_nnpa(void)
{
struct stat statbuf;
return (stat(S390_SYSFS_PAI_NNPA, &statbuf) == -1) ? false : true;
}