aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/header.c39
-rw-r--r--tools/perf/util/pmu.c39
2 files changed, 39 insertions, 39 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4fd45be95a43..e31f52845e77 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -988,6 +988,45 @@ static int write_group_desc(struct feat_fd *ff,
988} 988}
989 989
990/* 990/*
991 * Return the CPU id as a raw string.
992 *
993 * Each architecture should provide a more precise id string that
994 * can be use to match the architecture's "mapfile".
995 */
996char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
997{
998 return NULL;
999}
1000
1001/* Return zero when the cpuid from the mapfile.csv matches the
1002 * cpuid string generated on this platform.
1003 * Otherwise return non-zero.
1004 */
1005int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
1006{
1007 regex_t re;
1008 regmatch_t pmatch[1];
1009 int match;
1010
1011 if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
1012 /* Warn unable to generate match particular string. */
1013 pr_info("Invalid regular expression %s\n", mapcpuid);
1014 return 1;
1015 }
1016
1017 match = !regexec(&re, cpuid, 1, pmatch, 0);
1018 regfree(&re);
1019 if (match) {
1020 size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
1021
1022 /* Verify the entire string matched. */
1023 if (match_len == strlen(cpuid))
1024 return 0;
1025 }
1026 return 1;
1027}
1028
1029/*
991 * default get_cpuid(): nothing gets recorded 1030 * default get_cpuid(): nothing gets recorded
992 * actual implementation must be in arch/$(SRCARCH)/util/header.c 1031 * actual implementation must be in arch/$(SRCARCH)/util/header.c
993 */ 1032 */
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index c660625d7d4b..11a234740632 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -655,45 +655,6 @@ static int is_arm_pmu_core(const char *name)
655 return 0; 655 return 0;
656} 656}
657 657
658/*
659 * Return the CPU id as a raw string.
660 *
661 * Each architecture should provide a more precise id string that
662 * can be use to match the architecture's "mapfile".
663 */
664char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
665{
666 return NULL;
667}
668
669/* Return zero when the cpuid from the mapfile.csv matches the
670 * cpuid string generated on this platform.
671 * Otherwise return non-zero.
672 */
673int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
674{
675 regex_t re;
676 regmatch_t pmatch[1];
677 int match;
678
679 if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
680 /* Warn unable to generate match particular string. */
681 pr_info("Invalid regular expression %s\n", mapcpuid);
682 return 1;
683 }
684
685 match = !regexec(&re, cpuid, 1, pmatch, 0);
686 regfree(&re);
687 if (match) {
688 size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
689
690 /* Verify the entire string matched. */
691 if (match_len == strlen(cpuid))
692 return 0;
693 }
694 return 1;
695}
696
697static char *perf_pmu__getcpuid(struct perf_pmu *pmu) 658static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
698{ 659{
699 char *cpuid; 660 char *cpuid;