From 15158ee0cad3bf7e5a9ee614b9aa3901d2cbbf07 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Tue, 21 Jun 2022 13:02:46 +0200 Subject: [PATCH] libcpumf: Detect PMU named pai_ext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check to detect Processor Activity Instrumentation (PAI) Extension 1 facility unit. Signed-off-by: Thomas Richter Signed-off-by: Jan Höppner --- include/lib/libcpumf.h | 11 ++++++++++- libcpumf/libcpumf_example.c | 1 + libcpumf/libcpumf_support.c | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/lib/libcpumf.h b/include/lib/libcpumf.h index 832d9124..c577c895 100644 --- a/include/lib/libcpumf.h +++ b/include/lib/libcpumf.h @@ -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. diff --git a/libcpumf/libcpumf_example.c b/libcpumf/libcpumf_example.c index f962b5bc..1f2d4d81 100644 --- a/libcpumf/libcpumf_example.c +++ b/libcpumf/libcpumf_example.c @@ -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; } diff --git a/libcpumf/libcpumf_support.c b/libcpumf/libcpumf_support.c index bd6e4079..1a24d0f6 100644 --- a/libcpumf/libcpumf_support.c +++ b/libcpumf/libcpumf_support.c @@ -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;