linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Kilroy <andrew.kilroy@arm.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	acme@kernel.org, john.garry@huawei.com, irogers@google.com,
	ak@linux.intel.com
Cc: Andrew Kilroy <andrew.kilroy@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>
Subject: [RFC PATCH v2 3/5] perf stat: Topdown json metrics setup function
Date: Tue, 11 Jan 2022 15:07:47 +0000	[thread overview]
Message-ID: <20220111150749.13365-4-andrew.kilroy@arm.com> (raw)
In-Reply-To: <20220111150749.13365-1-andrew.kilroy@arm.com>

Move into its own function, the set up of json metrics to measure L1
topdown statistics

Also move the setup of the metrics_only member of stat_config outside,
since its supposed to be common to both the kernel events and json
metrics implementations

Signed-off-by: Andrew Kilroy <andrew.kilroy@arm.com>
---
 tools/perf/builtin-stat.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index ab956ac97d94..6122f3a764f8 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1651,15 +1651,12 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)
 
 static int try_non_json_metrics_topdown(void)
 {
-	int err;
+	int err = 0;
 	const char **metric_attrs = topdown_metric_attrs;
 	unsigned int max_level = 1;
 	char *str = NULL;
 	bool warn = false;
 
-	if (!force_metric_only)
-		stat_config.metric_only = true;
-
 	if (pmu_have_event("cpu", topdown_metric_L2_attrs[5])) {
 		metric_attrs = topdown_metric_L2_attrs;
 		max_level = 2;
@@ -1727,6 +1724,18 @@ static int try_non_json_metrics_topdown(void)
 	return err;
 }
 
+static int try_json_metrics_topdown(void)
+{
+	if (metricgroup__parse_groups_to_evlist(evsel_list, "TopDownL1",
+						stat_config.metric_no_group,
+						stat_config.metric_no_merge,
+						&stat_config.metric_events) < 0) {
+		pr_err("Could not form list of metrics for topdown\n");
+		return -1;
+	}
+	return 0;
+}
+
 /*
  * Add default attributes, if there were no attributes specified or
  * if -d/--detailed, -d -d or -d -d -d is used:
@@ -1926,20 +1935,18 @@ static int add_default_attributes(void)
 	}
 
 	if (topdown_run) {
+		if (!force_metric_only)
+			stat_config.metric_only = true;
+
 		if (topdown_can_use_json_metrics()) {
-			if (metricgroup__parse_groups_to_evlist(evsel_list, "TopDownL1",
-								stat_config.metric_no_group,
-								stat_config.metric_no_merge,
-								&stat_config.metric_events) < 0) {
-				pr_err("Could not form list of metrics for topdown\n");
-				return -1;
-			}
+			err = try_json_metrics_topdown();
+			if (err)
+				return err;
 		} else {
 			err = try_non_json_metrics_topdown();
 			if (err)
 				return err;
 		}
-
 	}
 
 	if (!evsel_list->core.nr_entries) {
-- 
2.17.1


  parent reply	other threads:[~2022-01-11 15:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 12:37 [PATCH v2 0/2] perf vendor events: Arm Neoverse N2 Andrew Kilroy
2021-12-10 12:37 ` [PATCH v2 1/2] perf vendor events: For the " Andrew Kilroy
2021-12-10 13:21   ` John Garry
2021-12-14 18:42     ` [RFC PATCH 0/1] topdown with metrics Andrew Kilroy
2021-12-14 18:42       ` [RFC PATCH 1/1] perf arm64: Implement --topdown " Andrew Kilroy
2021-12-14 20:32         ` Ian Rogers
2021-12-15 10:38           ` James Clark
2021-12-15 10:52           ` John Garry
2021-12-15 12:38             ` Andrew Kilroy
2021-12-15 12:53               ` John Garry
2022-01-06 16:33                 ` Andrew Kilroy
2022-01-06 18:24                   ` John Garry
2022-01-11 15:07                     ` [RFC PATCH v2 0/5] topdown " Andrew Kilroy
2022-01-11 15:07                       ` [RFC PATCH v2 1/5] perf stat: Implement --topdown " Andrew Kilroy
2022-01-28 13:44                         ` John Garry
2022-01-11 15:07                       ` [RFC PATCH v2 2/5] perf stat: Topdown kernel events setup function Andrew Kilroy
2022-01-11 15:07                       ` Andrew Kilroy [this message]
2022-01-11 15:07                       ` [RFC PATCH v2 4/5] perf stat: Detect if topdown kernel events supported Andrew Kilroy
2022-01-11 15:07                       ` [RFC PATCH v2 5/5] perf stat: Ensure only topdown kernel events used on x86 Andrew Kilroy
2022-01-20  9:26                       ` [RFC PATCH v2 0/5] topdown with metrics John Garry
2022-01-20 16:22                         ` Al Grant
2022-01-27 11:42                         ` Andrew Kilroy
2022-02-08 15:58                           ` Andrew Kilroy
2021-12-20 17:21             ` [RFC PATCH 1/1] perf arm64: Implement --topdown " Andrew Kilroy
2021-12-21 14:03               ` Andi Kleen
2022-01-27 11:11                 ` Andrew Kilroy
2021-12-17 10:19         ` John Garry
2021-12-21 14:31           ` Andrew Kilroy
2022-01-05 16:58           ` Andrew Kilroy
2022-01-28 18:00             ` John Garry
2021-12-10 12:37 ` [PATCH v2 2/2] perf vendor events: Rename arm64 arch std event files Andrew Kilroy
2021-12-10 13:46   ` John Garry
2021-12-10 19:01     ` Arnaldo Carvalho de Melo

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=20220111150749.13365-4-andrew.kilroy@arm.com \
    --to=andrew.kilroy@arm.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=john.garry@huawei.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=namhyung@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).