From 34cfca722c1a36ae04b9fb6e50930fef30f75518 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Tue, 21 Jul 2020 14:29:58 +0200 Subject: [PATCH] cpumf/lscpumf.c: Add support for counter number 265 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set the counter name for z15 counter numbered 265. It is either named DFLT_CCERROR or DFLT_CCFINISH, depending on the linux version. The counter was renamed from CCERROR to CCFINISH in linux version 5.8. Check for existence of file /sys/devices/cpum_cf/events/DLFT_CCERROR. f this file exists the counter is named DFLT_CCERROR else DFLT_CCFINISH (only for z15), other machines do not have this counter. Signed-off-by: Thomas Richter Signed-off-by: Jan Höppner --- cpumf/lscpumf.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cpumf/lscpumf.c b/cpumf/lscpumf.c index 21e9d466..88146c7f 100644 --- a/cpumf/lscpumf.c +++ b/cpumf/lscpumf.c @@ -2539,7 +2539,7 @@ static struct counters cpumcf_z15_counters[] = { { .ctrnum = 265, .ctrset = CPUMF_CTRSET_EXTENDED, - .name = "DFLT_CCERROR", + .name = NULL, .desc = "Increments by one for every DEFLATE CONVERSION CALL" "\n\t\tinstruction executed that ended in Condition Codes" "\n\t\t0, 1 or 2", @@ -2830,6 +2830,30 @@ static int read_sfb(struct cpumf_info *p) return rc; } +/* Set the counter name for z15 counter numbered 265. It is either named + * DFLT_CCERROR or DFLT_CCFINISH, depending on the linux version. The + * counter was renamed from CCERROR to CCFINISH in linux version 5.8. + * Check for existence of file /sys/devices/cpum_cf/events/DLFT_CCERROR. + */ +#define CCERROR "/sys/devices/cpum_cf/events/DFLT_CCERROR" +static void read_ccerror(struct counters *cp, size_t cp_cnt) +{ + struct stat sbuf; + char *ctrname; + size_t i = 0; + + if (stat(CCERROR, &sbuf) == 0) + ctrname = "DFLT_CCERROR"; + else + ctrname = "DFLT_CCFINISH"; + /* Find DFLT_CC{FINISH,ERROR} in table and set name */ + for (struct counters *p = cp; i < cp_cnt; ++i, ++p) + if (p->ctrnum == 265) { + p->name = ctrname; + break; + } +} + /* Read allnecessary information from /sysfs file /proc/service_levels */ static int read_info(void) { @@ -3017,6 +3041,7 @@ static struct counters *get_counter(int ctrset, size_t *len) case 8562: cp = cpumcf_z15_counters; *len = ARRAY_SIZE(cpumcf_z15_counters); + read_ccerror(cp, *len); break; } break;