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

perf pmu: Move *_cpuid_str() weak functions to header.c

The weak functions, strcmp_cpuid_str() and get_cpuid_str(), are defined
in pmu.c.

Most of the cpuid related functions, including *_cpuid_str()'s
declaration and platform specific definition, are in header.c/h.

To make the declaration and definition of all cpuid related functions in
a consistent place, move the weak functions to header.c.

There is no functional change.

Suggested-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Link: http://lkml.kernel.org/r/20181121164939.13482-1-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Kan Liang and committed by
Arnaldo Carvalho de Melo
f4a0742b 1e628569

+39 -39
+39
tools/perf/util/header.c
··· 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 + */ 996 + char * __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 + */ 1005 + int __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 1030 * default get_cpuid(): nothing gets recorded 992 1031 * actual implementation must be in arch/$(SRCARCH)/util/header.c 993 1032 */
-39
tools/perf/util/pmu.c
··· 655 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 - */ 664 - char * __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 - */ 673 - int __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 - 697 658 static char *perf_pmu__getcpuid(struct perf_pmu *pmu) 698 659 { 699 660 char *cpuid;