* [PATCH] perf pmu: Move *_cpuid_str() weak functions to header.c
@ 2018-11-21 16:49 kan.liang
2018-11-21 21:04 ` Arnaldo Carvalho de Melo
2018-11-22 7:16 ` [tip:perf/core] " tip-bot for Kan Liang
0 siblings, 2 replies; 3+ messages in thread
From: kan.liang @ 2018-11-21 16:49 UTC (permalink / raw)
To: acme, linux-kernel; +Cc: jolsa, Kan Liang
From: Kan Liang <kan.liang@linux.intel.com>
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>
---
Based on tmp.perf/core branch, on top of
commit 649d656ba01f ("perf vendor events: Add JSON metrics for Cascadelake server")
| 39 +++++++++++++++++++++++++++++++++++++++
tools/perf/util/pmu.c | 39 ---------------------------------------
2 files changed, 39 insertions(+), 39 deletions(-)
--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
@@ -987,6 +987,45 @@ static int write_group_desc(struct feat_fd *ff,
return 0;
}
+/*
+ * Return the CPU id as a raw string.
+ *
+ * Each architecture should provide a more precise id string that
+ * can be use to match the architecture's "mapfile".
+ */
+char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
+{
+ return NULL;
+}
+
+/* Return zero when the cpuid from the mapfile.csv matches the
+ * cpuid string generated on this platform.
+ * Otherwise return non-zero.
+ */
+int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
+{
+ regex_t re;
+ regmatch_t pmatch[1];
+ int match;
+
+ if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
+ /* Warn unable to generate match particular string. */
+ pr_info("Invalid regular expression %s\n", mapcpuid);
+ return 1;
+ }
+
+ match = !regexec(&re, cpuid, 1, pmatch, 0);
+ regfree(&re);
+ if (match) {
+ size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
+
+ /* Verify the entire string matched. */
+ if (match_len == strlen(cpuid))
+ return 0;
+ }
+ return 1;
+}
+
/*
* default get_cpuid(): nothing gets recorded
* actual implementation must be in arch/$(SRCARCH)/util/header.c
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)
return 0;
}
-/*
- * Return the CPU id as a raw string.
- *
- * Each architecture should provide a more precise id string that
- * can be use to match the architecture's "mapfile".
- */
-char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
-{
- return NULL;
-}
-
-/* Return zero when the cpuid from the mapfile.csv matches the
- * cpuid string generated on this platform.
- * Otherwise return non-zero.
- */
-int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
-{
- regex_t re;
- regmatch_t pmatch[1];
- int match;
-
- if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
- /* Warn unable to generate match particular string. */
- pr_info("Invalid regular expression %s\n", mapcpuid);
- return 1;
- }
-
- match = !regexec(&re, cpuid, 1, pmatch, 0);
- regfree(&re);
- if (match) {
- size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
-
- /* Verify the entire string matched. */
- if (match_len == strlen(cpuid))
- return 0;
- }
- return 1;
-}
-
static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
{
char *cpuid;
--
2.14.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf pmu: Move *_cpuid_str() weak functions to header.c
2018-11-21 16:49 [PATCH] perf pmu: Move *_cpuid_str() weak functions to header.c kan.liang
@ 2018-11-21 21:04 ` Arnaldo Carvalho de Melo
2018-11-22 7:16 ` [tip:perf/core] " tip-bot for Kan Liang
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-21 21:04 UTC (permalink / raw)
To: kan.liang; +Cc: linux-kernel, jolsa
Em Wed, Nov 21, 2018 at 08:49:39AM -0800, kan.liang@linux.intel.com escreveu:
> From: Kan Liang <kan.liang@linux.intel.com>
>
> 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.
Thanks, applied.
- Arnaldo
> Suggested-by: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
>
> ---
>
> Based on tmp.perf/core branch, on top of
> commit 649d656ba01f ("perf vendor events: Add JSON metrics for Cascadelake server")
>
> tools/perf/util/header.c | 39 +++++++++++++++++++++++++++++++++++++++
> tools/perf/util/pmu.c | 39 ---------------------------------------
> 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
> @@ -987,6 +987,45 @@ static int write_group_desc(struct feat_fd *ff,
> return 0;
> }
>
> +/*
> + * Return the CPU id as a raw string.
> + *
> + * Each architecture should provide a more precise id string that
> + * can be use to match the architecture's "mapfile".
> + */
> +char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
> +{
> + return NULL;
> +}
> +
> +/* Return zero when the cpuid from the mapfile.csv matches the
> + * cpuid string generated on this platform.
> + * Otherwise return non-zero.
> + */
> +int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
> +{
> + regex_t re;
> + regmatch_t pmatch[1];
> + int match;
> +
> + if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
> + /* Warn unable to generate match particular string. */
> + pr_info("Invalid regular expression %s\n", mapcpuid);
> + return 1;
> + }
> +
> + match = !regexec(&re, cpuid, 1, pmatch, 0);
> + regfree(&re);
> + if (match) {
> + size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
> +
> + /* Verify the entire string matched. */
> + if (match_len == strlen(cpuid))
> + return 0;
> + }
> + return 1;
> +}
> +
> /*
> * default get_cpuid(): nothing gets recorded
> * actual implementation must be in arch/$(SRCARCH)/util/header.c
> 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)
> return 0;
> }
>
> -/*
> - * Return the CPU id as a raw string.
> - *
> - * Each architecture should provide a more precise id string that
> - * can be use to match the architecture's "mapfile".
> - */
> -char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
> -{
> - return NULL;
> -}
> -
> -/* Return zero when the cpuid from the mapfile.csv matches the
> - * cpuid string generated on this platform.
> - * Otherwise return non-zero.
> - */
> -int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
> -{
> - regex_t re;
> - regmatch_t pmatch[1];
> - int match;
> -
> - if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
> - /* Warn unable to generate match particular string. */
> - pr_info("Invalid regular expression %s\n", mapcpuid);
> - return 1;
> - }
> -
> - match = !regexec(&re, cpuid, 1, pmatch, 0);
> - regfree(&re);
> - if (match) {
> - size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
> -
> - /* Verify the entire string matched. */
> - if (match_len == strlen(cpuid))
> - return 0;
> - }
> - return 1;
> -}
> -
> static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
> {
> char *cpuid;
> --
> 2.14.5
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip:perf/core] perf pmu: Move *_cpuid_str() weak functions to header.c
2018-11-21 16:49 [PATCH] perf pmu: Move *_cpuid_str() weak functions to header.c kan.liang
2018-11-21 21:04 ` Arnaldo Carvalho de Melo
@ 2018-11-22 7:16 ` tip-bot for Kan Liang
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Kan Liang @ 2018-11-22 7:16 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, tglx, jolsa, kan.liang, mingo, hpa, acme
Commit-ID: f4a0742b3cc1d03b2ff448017b8c714a77e5a261
Gitweb: https://git.kernel.org/tip/f4a0742b3cc1d03b2ff448017b8c714a77e5a261
Author: Kan Liang <kan.liang@linux.intel.com>
AuthorDate: Wed, 21 Nov 2018 08:49:39 -0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 21 Nov 2018 22:39:59 -0300
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>
---
| 39 +++++++++++++++++++++++++++++++++++++++
tools/perf/util/pmu.c | 39 ---------------------------------------
2 files changed, 39 insertions(+), 39 deletions(-)
--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
@@ -987,6 +987,45 @@ static int write_group_desc(struct feat_fd *ff,
return 0;
}
+/*
+ * Return the CPU id as a raw string.
+ *
+ * Each architecture should provide a more precise id string that
+ * can be use to match the architecture's "mapfile".
+ */
+char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
+{
+ return NULL;
+}
+
+/* Return zero when the cpuid from the mapfile.csv matches the
+ * cpuid string generated on this platform.
+ * Otherwise return non-zero.
+ */
+int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
+{
+ regex_t re;
+ regmatch_t pmatch[1];
+ int match;
+
+ if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
+ /* Warn unable to generate match particular string. */
+ pr_info("Invalid regular expression %s\n", mapcpuid);
+ return 1;
+ }
+
+ match = !regexec(&re, cpuid, 1, pmatch, 0);
+ regfree(&re);
+ if (match) {
+ size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
+
+ /* Verify the entire string matched. */
+ if (match_len == strlen(cpuid))
+ return 0;
+ }
+ return 1;
+}
+
/*
* default get_cpuid(): nothing gets recorded
* actual implementation must be in arch/$(SRCARCH)/util/header.c
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)
return 0;
}
-/*
- * Return the CPU id as a raw string.
- *
- * Each architecture should provide a more precise id string that
- * can be use to match the architecture's "mapfile".
- */
-char * __weak get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
-{
- return NULL;
-}
-
-/* Return zero when the cpuid from the mapfile.csv matches the
- * cpuid string generated on this platform.
- * Otherwise return non-zero.
- */
-int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
-{
- regex_t re;
- regmatch_t pmatch[1];
- int match;
-
- if (regcomp(&re, mapcpuid, REG_EXTENDED) != 0) {
- /* Warn unable to generate match particular string. */
- pr_info("Invalid regular expression %s\n", mapcpuid);
- return 1;
- }
-
- match = !regexec(&re, cpuid, 1, pmatch, 0);
- regfree(&re);
- if (match) {
- size_t match_len = (pmatch[0].rm_eo - pmatch[0].rm_so);
-
- /* Verify the entire string matched. */
- if (match_len == strlen(cpuid))
- return 0;
- }
- return 1;
-}
-
static char *perf_pmu__getcpuid(struct perf_pmu *pmu)
{
char *cpuid;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-22 7:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 16:49 [PATCH] perf pmu: Move *_cpuid_str() weak functions to header.c kan.liang
2018-11-21 21:04 ` Arnaldo Carvalho de Melo
2018-11-22 7:16 ` [tip:perf/core] " tip-bot for Kan Liang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.