linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
	<mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>,
	<jolsa@redhat.com>, <namhyung@kernel.org>
Cc: <will@kernel.org>, <ak@linux.intel.com>, <linuxarm@huawei.com>,
	<linux-kernel@vger.kernel.org>, <james.clark@arm.com>,
	<qiangqing.zhang@nxp.com>, John Garry <john.garry@huawei.com>
Subject: [PATCH v2 3/7] perf pmu: Refactor pmu_add_cpu_aliases()
Date: Tue, 17 Mar 2020 19:02:15 +0800	[thread overview]
Message-ID: <1584442939-8911-4-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1584442939-8911-1-git-send-email-john.garry@huawei.com>

Create pmu_add_cpu_aliases_map() from pmu_add_cpu_aliases(), so the caller
can pass the map; the pmu-events test would use this since there would
be no CPUID matching to a mapfile there.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 tools/perf/util/pmu.c | 21 +++++++++++++--------
 tools/perf/util/pmu.h |  3 +++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 8b99fd312aae..c616a06a34a8 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -21,7 +21,6 @@
 #include "pmu.h"
 #include "parse-events.h"
 #include "header.h"
-#include "pmu-events/pmu-events.h"
 #include "string2.h"
 #include "strbuf.h"
 #include "fncache.h"
@@ -744,16 +743,11 @@ static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
  * to the current running CPU. Then, add all PMU events from that table
  * as aliases.
  */
-static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
+void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu,
+			     struct pmu_events_map *map)
 {
 	int i;
-	struct pmu_events_map *map;
 	const char *name = pmu->name;
-
-	map = perf_pmu__find_map(pmu);
-	if (!map)
-		return;
-
 	/*
 	 * Found a matching PMU events table. Create aliases
 	 */
@@ -788,6 +782,17 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
 	}
 }
 
+static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
+{
+	struct pmu_events_map *map;
+
+	map = perf_pmu__find_map(pmu);
+	if (!map)
+		return;
+
+	pmu_add_cpu_aliases_map(head, pmu, map);
+}
+
 struct perf_event_attr * __weak
 perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
 {
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 6737e3d5d568..0b4a0efae38e 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -7,6 +7,7 @@
 #include <linux/perf_event.h>
 #include <stdbool.h>
 #include "parse-events.h"
+#include "pmu-events/pmu-events.h"
 
 struct perf_evsel_config_term;
 
@@ -97,6 +98,8 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
 int perf_pmu__test(void);
 
 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
+void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu,
+			     struct pmu_events_map *map);
 
 struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu);
 
-- 
2.12.3


  parent reply	other threads:[~2020-03-17 11:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 11:02 [PATCH v2 0/7] perf test pmu-events case John Garry
2020-03-17 11:02 ` [PATCH v2 1/7] perf jevents: Add some test events John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 2/7] perf jevents: Support test events folder John Garry
2020-03-17 16:20   ` Jiri Olsa
2020-03-17 16:25     ` John Garry
2020-03-17 17:06       ` Jiri Olsa
2020-03-17 17:42         ` John Garry
2020-03-17 20:41           ` Arnaldo Carvalho de Melo
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` John Garry [this message]
2020-04-04  8:41   ` [tip: perf/urgent] perf pmu: Refactor pmu_add_cpu_aliases() tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 4/7] perf test: Add pmu-events test John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 5/7] perf pmu: Add is_pmu_core() John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 6/7] perf pmu: Make pmu_uncore_alias_match() public John Garry
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-17 11:02 ` [PATCH v2 7/7] perf test: Test pmu-events aliases John Garry
2020-03-17 16:20   ` Jiri Olsa
2020-03-17 16:41     ` John Garry
2020-03-17 17:07       ` Jiri Olsa
2020-03-19 18:36         ` Arnaldo Carvalho de Melo
2020-03-20  9:24           ` John Garry
2020-03-20  9:30             ` Jiri Olsa
2020-04-04  8:41   ` [tip: perf/urgent] " tip-bot2 for John Garry
2020-03-18  7:57 ` [PATCH v2 0/7] perf test pmu-events case Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1584442939-8911-4-git-send-email-john.garry@huawei.com \
    --to=john.garry@huawei.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qiangqing.zhang@nxp.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).