summaryrefslogtreecommitdiffstats
path: root/tools/perf/arch
diff options
context:
space:
mode:
authorThomas Richter <tmricht@linux.vnet.ibm.com>2018-02-13 16:14:18 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-02-16 15:16:57 -0300
commit4cb7d3ecfca90684ad00f893c34a2028fcc5f764 (patch)
tree40f23d7dd8ecb09616d148cce48c031ed4c2f4a8 /tools/perf/arch
parentc59124fa59757fadc80ad881056a21f98c71b146 (diff)
downloadlinux-4cb7d3ecfca90684ad00f893c34a2028fcc5f764.tar.bz2
perf cpuid: Introduce a platform specific cpuid compare function
The function get_cpuid_str() is called by perf_pmu__getcpuid() and on s390 returns a complete description of the CPU and its capabilities, which is a comma separated list. To map the CPU type with the value defined in the pmu-events/arch/s390/mapfile.csv, introduce an architecture specific cpuid compare function named strcmp_cpuid_str() The currently used regex algorithm is defined as the weak default and will be used if no platform specific one is defined. This matches the current behavior. Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com> Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Link: http://lkml.kernel.org/r/20180213151419.80737-3-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/arch')
-rw-r--r--tools/perf/arch/s390/util/header.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/perf/arch/s390/util/header.c b/tools/perf/arch/s390/util/header.c
index a78064c25ced..231294b80dc4 100644
--- a/tools/perf/arch/s390/util/header.c
+++ b/tools/perf/arch/s390/util/header.c
@@ -146,3 +146,21 @@ char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
zfree(&buf);
return buf;
}
+
+/*
+ * Compare the cpuid string returned by get_cpuid() function
+ * with the name generated by the jevents file read from
+ * pmu-events/arch/s390/mapfile.csv.
+ *
+ * Parameter mapcpuid is the cpuid as stored in the
+ * pmu-events/arch/s390/mapfile.csv. This is just the type number.
+ * Parameter cpuid is the cpuid returned by function get_cpuid().
+ */
+int strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
+{
+ char *cp = strchr(cpuid, ',');
+
+ if (cp == NULL)
+ return -1;
+ return strncmp(cp + 1, mapcpuid, strlen(mapcpuid));
+}