All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@linaro.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Kemeng Shi <shikemeng@huawei.com>,
	James Clark <james.clark@arm.com>, Wei Li <liwei391@huawei.com>,
	Al Grant <Al.Grant@arm.com>, Will Deacon <will@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Mike Leach <mike.leach@linaro.org>,
	linux-kernel@vger.kernel.org
Cc: Leo Yan <leo.yan@linaro.org>
Subject: [PATCH v2 06/14] perf mem: Support AUX trace
Date: Tue,  1 Sep 2020 09:38:07 +0100	[thread overview]
Message-ID: <20200901083815.13755-7-leo.yan@linaro.org> (raw)
In-Reply-To: <20200901083815.13755-1-leo.yan@linaro.org>

Perf memory profiling doesn't support aux trace data so the tool cannot
receive the synthesized samples from hardware tracing data.  On the
Arm64 platform, though it doesn't support PMU events for memory load and
store, but Armv8's SPE is a good candidate for memory profiling, the
hardware tracer can record memory accessing operations with physical
address and virtual address for different cache levels and it also stats
the memory operations for remote access and TLB.

To allow the perf memory tool to support AUX trace, this patches adds
the aux callbacks for session structure.  It passes the predefined
itrace option to ask the AUX trace decoder to generate memory samples.
This patch also invokes the standard API perf_event__process_attr() to
register sample IDs into evlist.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/builtin-mem.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index b9432ee27754..ded416d68d88 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -7,6 +7,7 @@
 #include "perf.h"
 
 #include <subcmd/parse-options.h>
+#include "util/auxtrace.h"
 #include "util/trace-event.h"
 #include "util/tool.h"
 #include "util/session.h"
@@ -252,6 +253,12 @@ static int process_sample_event(struct perf_tool *tool,
 
 static int report_raw_events(struct perf_mem *mem)
 {
+	struct itrace_synth_opts itrace_synth_opts = {
+		.set = true,
+		.mem = true,		/* Memory samples */
+		.default_no_sample = true,
+	};
+
 	struct perf_data data = {
 		.path  = input_name,
 		.mode  = PERF_DATA_MODE_READ,
@@ -264,6 +271,8 @@ static int report_raw_events(struct perf_mem *mem)
 	if (IS_ERR(session))
 		return PTR_ERR(session);
 
+	session->itrace_synth_opts = &itrace_synth_opts;
+
 	if (mem->cpu_list) {
 		ret = perf_session__cpu_bitmap(session, mem->cpu_list,
 					       mem->cpu_bitmap);
@@ -397,6 +406,19 @@ parse_mem_ops(const struct option *opt, const char *str, int unset)
 	return ret;
 }
 
+static int process_attr(struct perf_tool *tool __maybe_unused,
+			union perf_event *event,
+			struct evlist **pevlist)
+{
+	int err;
+
+	err = perf_event__process_attr(tool, event, pevlist);
+	if (err)
+		return err;
+
+	return 0;
+}
+
 int cmd_mem(int argc, const char **argv)
 {
 	struct stat st;
@@ -408,8 +430,12 @@ int cmd_mem(int argc, const char **argv)
 			.comm		= perf_event__process_comm,
 			.lost		= perf_event__process_lost,
 			.fork		= perf_event__process_fork,
+			.attr		= process_attr,
 			.build_id	= perf_event__process_build_id,
 			.namespaces	= perf_event__process_namespaces,
+			.auxtrace_info  = perf_event__process_auxtrace_info,
+			.auxtrace       = perf_event__process_auxtrace,
+			.auxtrace_error = perf_event__process_auxtrace_error,
 			.ordered_events	= true,
 		},
 		.input_name		 = "perf.data",
-- 
2.20.1


  parent reply	other threads:[~2020-09-01  8:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01  8:38 [PATCH v2 00/14] perf mem: Support AUX trace and Arm SPE Leo Yan
2020-09-01  8:38 ` [PATCH v2 01/14] perf mem: Search event name with more flexible path Leo Yan
2020-09-03 13:50   ` Jiri Olsa
2020-09-01  8:38 ` [PATCH v2 02/14] perf mem: Introduce weak function perf_mem_events__ptr() Leo Yan
2020-09-03 13:50   ` Jiri Olsa
2020-09-04  0:34     ` Leo Yan
2020-09-04 15:52       ` Jiri Olsa
2020-09-07  8:17         ` Leo Yan
2020-09-01  8:38 ` [PATCH v2 03/14] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE Leo Yan
2020-09-01  8:38 ` [PATCH v2 04/14] perf mem: Only initialize memory event for recording Leo Yan
2020-09-01  8:38 ` [PATCH v2 05/14] perf auxtrace: Add option '-M' for memory events Leo Yan
2020-09-01  8:38 ` Leo Yan [this message]
2020-09-01  8:38 ` [PATCH v2 07/14] perf mem: Support Arm SPE events Leo Yan
2020-09-01  8:38 ` [PATCH v2 08/14] perf arm-spe: Enable attribution PERF_SAMPLE_DATA_SRC Leo Yan
2020-09-01  8:38 ` [PATCH v2 09/14] perf arm-spe: Save memory addresses in packet Leo Yan
2020-09-01  8:38 ` [PATCH v2 10/14] perf arm-spe: Store operation types " Leo Yan
2020-09-01  8:38 ` [PATCH v2 11/14] perf arm-spe: Fill address info for samples Leo Yan
2020-09-01  8:38 ` [PATCH v2 12/14] perf arm-spe: Synthesize memory event Leo Yan
2020-09-01  8:38 ` [PATCH v2 13/14] perf arm-spe: Set sample's data source field Leo Yan
2020-09-01  8:38 ` [PATCH v2 14/14] perf mem: Document options introduced by Arm SPE Leo Yan

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=20200901083815.13755-7-leo.yan@linaro.org \
    --to=leo.yan@linaro.org \
    --cc=Al.Grant@arm.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=shikemeng@huawei.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 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.