Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf list: Remove s390 specific strcmp_cpuid_cmp function

Make the type field in pmu-events/arch/s390/mapfile.cvs more generic to
match the created cpuid string for s390.

The pattern also checks for the counter first version number and counter
second version number ([13]\.[1-5]) and the authorization field which
follows.

These numbers do not exist in the cpuid identification string when perf
commands are executed on a z/VM environment (which does not support CPU
counter measurement facility).

CPUID string for LPAR:
cpuid : IBM,3906,704,M03,3.5,002f
CPUID string for z/VM:
cpuid : IBM,2964,702,N96

This allows the removal of s390 specific cpuid compare code and uses the
common compare function with its regular expression matching algorithm.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/20180423081745.3672-1-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Thomas Richter and committed by
Arnaldo Carvalho de Melo
ce04abfb ee05d217

+6 -24
-18
tools/perf/arch/s390/util/header.c
··· 146 146 zfree(&buf); 147 147 return buf; 148 148 } 149 - 150 - /* 151 - * Compare the cpuid string returned by get_cpuid() function 152 - * with the name generated by the jevents file read from 153 - * pmu-events/arch/s390/mapfile.csv. 154 - * 155 - * Parameter mapcpuid is the cpuid as stored in the 156 - * pmu-events/arch/s390/mapfile.csv. This is just the type number. 157 - * Parameter cpuid is the cpuid returned by function get_cpuid(). 158 - */ 159 - int strcmp_cpuid_str(const char *mapcpuid, const char *cpuid) 160 - { 161 - char *cp = strchr(cpuid, ','); 162 - 163 - if (cp == NULL) 164 - return -1; 165 - return strncmp(cp + 1, mapcpuid, strlen(mapcpuid)); 166 - }
+5 -5
tools/perf/pmu-events/arch/s390/mapfile.csv
··· 1 1 Family-model,Version,Filename,EventType 2 - 209[78],1,cf_z10,core 3 - 281[78],1,cf_z196,core 4 - 282[78],1,cf_zec12,core 5 - 296[45],1,cf_z13,core 6 - 3906,3,cf_z14,core 2 + ^IBM.209[78].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_z10,core 3 + ^IBM.281[78].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_z196,core 4 + ^IBM.282[78].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_zec12,core 5 + ^IBM.296[45].*[13]\.[1-5].[[:xdigit:]]+$,1,cf_z13,core 6 + ^IBM.390[67].*[13]\.[1-5].[[:xdigit:]]+$,3,cf_z14,core
+1 -1
tools/perf/util/pmu.c
··· 586 586 * cpuid string generated on this platform. 587 587 * Otherwise return non-zero. 588 588 */ 589 - int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid) 589 + int strcmp_cpuid_str(const char *mapcpuid, const char *cpuid) 590 590 { 591 591 regex_t re; 592 592 regmatch_t pmatch[1];