mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Add a function to detect the existence of the CPU Measurement Sampling Facility on a system. Add a function which extracts the CPU Measurement Sampling Facility characteristics on a system, such as - minimum sample speed - maximum sample speed - current CPU speed - basic sample size in bytes - diagnostic sample size in bytes Add a function to detect the existence of the CPU Measurement Sampling Facility on a system and return the current sampling buffer management characteristics, such as: - minimum supported sampling buffer size - maximum supported sampling buffer size Add a function to detect the existence of the CPU Measurement Counting Facility on a system. Add a function which extracts the CPU Measurement Counting Facility characteristics on a system, such as - counter first version number - counter second version number - counter set authorization level Add a function the returm the PMU type number of a CPU Measurement Facility device driver. These numbers may vary between boots. Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
77 lines
2.1 KiB
C
77 lines
2.1 KiB
C
/* Copyright IBM Corp. 2022
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "lib/libcpumf.h"
|
|
|
|
int main(void)
|
|
{
|
|
unsigned long min, max, speed, sfb_min, sfb_max;
|
|
int rc, pmu, cfvn, csvn, auth;
|
|
cpu_set_t set;
|
|
|
|
pmu = libcpumf_pmutype(S390_CPUMF_CF);
|
|
if (pmu >= 0)
|
|
printf("PMU %stype %d\n", S390_CPUMF_CF, pmu);
|
|
else
|
|
printf("PMU %stype error %d\n", S390_CPUMF_CF, errno);
|
|
pmu = libcpumf_pmutype(S390_CPUMF_SF);
|
|
if (pmu >= 0)
|
|
printf("PMU %stype %d\n", S390_CPUMF_SF, pmu);
|
|
else
|
|
printf("PMU %stype error %d\n", S390_CPUMF_SF, errno);
|
|
pmu = libcpumf_pmutype(S390_CPUMF_CFDIAG);
|
|
if (pmu >= 0)
|
|
printf("PMU %stype %d\n", S390_CPUMF_CFDIAG, pmu);
|
|
else
|
|
printf("PMU %stype error %d\n", S390_CPUMF_CFDIAG, errno);
|
|
|
|
rc = libcpumf_cpuset_fn(S390_CPUS_ONLINE, &set);
|
|
if (rc == 0) {
|
|
puts("Online CPUs:");
|
|
for (int i = 0; i < CPU_SETSIZE; ++i)
|
|
if (CPU_ISSET(i, &set))
|
|
printf("%d ", i);
|
|
putchar('\n');
|
|
}
|
|
rc = libcpumf_cpuset("0-7,9,11-12 ,15", &set);
|
|
if (rc == 0) {
|
|
puts("String CPUs:");
|
|
for (int i = 0; i < CPU_SETSIZE; ++i)
|
|
if (CPU_ISSET(i, &set))
|
|
printf("%d ", i);
|
|
putchar('\n');
|
|
} else {
|
|
printf("libcpumf_cpuset input invalid %d\n", errno);
|
|
}
|
|
|
|
printf("CPUMCF support %d\n", libcpumf_have_cpumcf());
|
|
rc = libcpumf_cpumcf_info(&cfvn, &csvn, &auth);
|
|
printf("libcpumf_cpumcf_info %d", rc);
|
|
if (rc)
|
|
printf(" cfvn %d csvn %d authorization %#x", cfvn, csvn, auth);
|
|
putchar('\n');
|
|
|
|
printf("CPUMSF support %d\n", libcpumf_have_cpumsf());
|
|
rc = libcpumf_cpumsf_info(&min, &max, &speed, &cfvn, &csvn);
|
|
printf("libcpumf_cpumsf_info %d", rc);
|
|
if (rc)
|
|
printf(" min %ld max %ld speed %#lx basic %d diag %d", min,
|
|
max, speed, cfvn, csvn);
|
|
putchar('\n');
|
|
|
|
printf("CPUMSF have sfb %d\n", libcpumf_have_sfb());
|
|
rc = libcpumf_sfb_info(&sfb_min, &sfb_max);
|
|
printf("libcpumf_sfb_info %d", rc);
|
|
if (rc)
|
|
printf(" sfb_min %lu sfb_max %lu", sfb_min, sfb_max);
|
|
putchar('\n');
|
|
return EXIT_SUCCESS;
|
|
}
|