All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/9] perf mem/c2c: Support AUX trace
@ 2020-10-28  6:38 ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The patch set v2 [1] mixed the patches for support perf mem/c2c AUX
trace and for enabling Arm SPE's memory event.  To make easier
reviewing, this patch set extracts the changes for perf mem/c2c AUX
trace.

Patches 01, 02, 03 extend to support more flexible memory event name
and introduce a new event type 'ldst' (besides the existed types 'load'
and 'store').

Patch 04 is a minor refactoring to initailize memory event for recording
but not for reporting.

Patches 05, 06 are to support AUX trace for "perf mem" and "perf c2c"
tools.

Patch 07 enabled SPE memory events for Arm64 arch; patch 08 fixes the
memory event name issue on PowerPC.

Patch 09 is to update documentation to reflect the latest changes.

This patch set has been applied clearly on the perf/core branch with the
latest commit 7cf726a59435 ("Merge tag 'linux-kselftest-kunit-5.10-rc1'
of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest").

This patch set has been verified on x86 and Arm64.

On x86, below commands have been tested:

  # perf c2c record -e ldlat-loads  -- ~/false_sharing.exe 2
  # perf c2c record -e ldlat-stores  -- ~/false_sharing.exe 2
  # perf mem record -t load -- ~/false_sharing.exe 2
  # perf mem record -t store -- ~/false_sharing.exe 2
  # perf mem record -t ldst -- ~/false_sharing.exe 2
      `-> report failure due the type 'ldst' is not supported on x86
  # perf mem record -e ldlat-loads  -- ~/false_sharing.exe 2
  # perf mem record -e ldlat-stores  -- ~/false_sharing.exe 2

On Arm64, below commands have been tested:

  # perf c2c record -e spe-load  -- ~/false_sharing.exe 2
  # perf c2c record -e spe-store  -- ~/false_sharing.exe 2
  # perf c2c record -e spe-ldst  -- ~/false_sharing.exe 2
  # perf mem record -t load -- ~/false_sharing.exe 2
  # perf mem record -t store -- ~/false_sharing.exe 2
  # perf mem record -t ldst -- ~/false_sharing.exe 2
  # perf mem record -e spe-load  -- ~/false_sharing.exe 2
  # perf mem record -e spe-store  -- ~/false_sharing.exe 2
  # perf mem record -e spe-ldst  -- ~/false_sharing.exe 2

[1] https://lore.kernel.org/patchwork/cover/1298085/


Leo Yan (9):
  perf mem: Search event name with more flexible path
  perf mem: Introduce weak function perf_mem_events__ptr()
  perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
  perf mem: Only initialize memory event for recording
  perf mem: Support AUX trace
  perf c2c: Support AUX trace
  perf mem: Support Arm SPE events
  perf mem: Return NULL for event 'ldst' on PowerPC
  perf mem: Document event type 'ldst'

Changes from v2:
* Patch 02 went back to use loops with PERF_MEM_EVENTS__MAX (Jiri);
* Patch 06 for "perf c2c" AUX trace is supported;
* Patch 08 for fixing memory event name on PowerPC.


Changes from v1:
* Refined patch 02 to use perf_mem_events__ptr() to return event pointer
  and check if pointer is NULL, and remove the condition checking for
  PERF_MEM_EVENTS__MAX; (James Clark)
* Added new itrace option 'M' for memory events;
* Added patch 14 to update documentation.


 tools/perf/Documentation/perf-mem.txt     |  6 ++-
 tools/perf/arch/arm64/util/Build          |  2 +-
 tools/perf/arch/arm64/util/mem-events.c   | 37 +++++++++++++++++
 tools/perf/arch/powerpc/util/mem-events.c |  6 ++-
 tools/perf/builtin-c2c.c                  | 22 +++++++---
 tools/perf/builtin-mem.c                  | 49 ++++++++++++++++-------
 tools/perf/util/mem-events.c              | 45 ++++++++++++++++-----
 tools/perf/util/mem-events.h              |  3 +-
 8 files changed, 133 insertions(+), 37 deletions(-)
 create mode 100644 tools/perf/arch/arm64/util/mem-events.c

-- 
2.17.1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v3 0/9] perf mem/c2c: Support AUX trace
@ 2020-10-28  6:38 ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The patch set v2 [1] mixed the patches for support perf mem/c2c AUX
trace and for enabling Arm SPE's memory event.  To make easier
reviewing, this patch set extracts the changes for perf mem/c2c AUX
trace.

Patches 01, 02, 03 extend to support more flexible memory event name
and introduce a new event type 'ldst' (besides the existed types 'load'
and 'store').

Patch 04 is a minor refactoring to initailize memory event for recording
but not for reporting.

Patches 05, 06 are to support AUX trace for "perf mem" and "perf c2c"
tools.

Patch 07 enabled SPE memory events for Arm64 arch; patch 08 fixes the
memory event name issue on PowerPC.

Patch 09 is to update documentation to reflect the latest changes.

This patch set has been applied clearly on the perf/core branch with the
latest commit 7cf726a59435 ("Merge tag 'linux-kselftest-kunit-5.10-rc1'
of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest").

This patch set has been verified on x86 and Arm64.

On x86, below commands have been tested:

  # perf c2c record -e ldlat-loads  -- ~/false_sharing.exe 2
  # perf c2c record -e ldlat-stores  -- ~/false_sharing.exe 2
  # perf mem record -t load -- ~/false_sharing.exe 2
  # perf mem record -t store -- ~/false_sharing.exe 2
  # perf mem record -t ldst -- ~/false_sharing.exe 2
      `-> report failure due the type 'ldst' is not supported on x86
  # perf mem record -e ldlat-loads  -- ~/false_sharing.exe 2
  # perf mem record -e ldlat-stores  -- ~/false_sharing.exe 2

On Arm64, below commands have been tested:

  # perf c2c record -e spe-load  -- ~/false_sharing.exe 2
  # perf c2c record -e spe-store  -- ~/false_sharing.exe 2
  # perf c2c record -e spe-ldst  -- ~/false_sharing.exe 2
  # perf mem record -t load -- ~/false_sharing.exe 2
  # perf mem record -t store -- ~/false_sharing.exe 2
  # perf mem record -t ldst -- ~/false_sharing.exe 2
  # perf mem record -e spe-load  -- ~/false_sharing.exe 2
  # perf mem record -e spe-store  -- ~/false_sharing.exe 2
  # perf mem record -e spe-ldst  -- ~/false_sharing.exe 2

[1] https://lore.kernel.org/patchwork/cover/1298085/


Leo Yan (9):
  perf mem: Search event name with more flexible path
  perf mem: Introduce weak function perf_mem_events__ptr()
  perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
  perf mem: Only initialize memory event for recording
  perf mem: Support AUX trace
  perf c2c: Support AUX trace
  perf mem: Support Arm SPE events
  perf mem: Return NULL for event 'ldst' on PowerPC
  perf mem: Document event type 'ldst'

Changes from v2:
* Patch 02 went back to use loops with PERF_MEM_EVENTS__MAX (Jiri);
* Patch 06 for "perf c2c" AUX trace is supported;
* Patch 08 for fixing memory event name on PowerPC.


Changes from v1:
* Refined patch 02 to use perf_mem_events__ptr() to return event pointer
  and check if pointer is NULL, and remove the condition checking for
  PERF_MEM_EVENTS__MAX; (James Clark)
* Added new itrace option 'M' for memory events;
* Added patch 14 to update documentation.


 tools/perf/Documentation/perf-mem.txt     |  6 ++-
 tools/perf/arch/arm64/util/Build          |  2 +-
 tools/perf/arch/arm64/util/mem-events.c   | 37 +++++++++++++++++
 tools/perf/arch/powerpc/util/mem-events.c |  6 ++-
 tools/perf/builtin-c2c.c                  | 22 +++++++---
 tools/perf/builtin-mem.c                  | 49 ++++++++++++++++-------
 tools/perf/util/mem-events.c              | 45 ++++++++++++++++-----
 tools/perf/util/mem-events.h              |  3 +-
 8 files changed, 133 insertions(+), 37 deletions(-)
 create mode 100644 tools/perf/arch/arm64/util/mem-events.c

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v3 1/9] perf mem: Search event name with more flexible path
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

Perf tool searches memory event name under the folder
'/sys/devices/cpu/events/', this leads to the limitation for selection
memory profiling event which must be under this folder.  Thus it's
impossible to use any other event as memory event which is not under
this specific folder, e.g. Arm SPE hardware event is not located in
'/sys/devices/cpu/events/' so it cannot be enabled for memory profiling.

This patch changes to search folder from '/sys/devices/cpu/events/' to
'/sys/devices', so it give flexibility to find events which can be used
for memory profiling.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/util/mem-events.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index ea0af0bc4314..35c8d175a9d2 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -18,8 +18,8 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
 struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
-	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"mem-loads"),
-	E("ldlat-stores",	"cpu/mem-stores/P",		"mem-stores"),
+	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"cpu/events/mem-loads"),
+	E("ldlat-stores",	"cpu/mem-stores/P",		"cpu/events/mem-stores"),
 };
 #undef E
 
@@ -93,7 +93,7 @@ int perf_mem_events__init(void)
 		struct perf_mem_event *e = &perf_mem_events[j];
 		struct stat st;
 
-		scnprintf(path, PATH_MAX, "%s/devices/cpu/events/%s",
+		scnprintf(path, PATH_MAX, "%s/devices/%s",
 			  mnt, e->sysfs_name);
 
 		if (!stat(path, &st))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 1/9] perf mem: Search event name with more flexible path
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

Perf tool searches memory event name under the folder
'/sys/devices/cpu/events/', this leads to the limitation for selection
memory profiling event which must be under this folder.  Thus it's
impossible to use any other event as memory event which is not under
this specific folder, e.g. Arm SPE hardware event is not located in
'/sys/devices/cpu/events/' so it cannot be enabled for memory profiling.

This patch changes to search folder from '/sys/devices/cpu/events/' to
'/sys/devices', so it give flexibility to find events which can be used
for memory profiling.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/util/mem-events.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index ea0af0bc4314..35c8d175a9d2 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -18,8 +18,8 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
 struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
-	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"mem-loads"),
-	E("ldlat-stores",	"cpu/mem-stores/P",		"mem-stores"),
+	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"cpu/events/mem-loads"),
+	E("ldlat-stores",	"cpu/mem-stores/P",		"cpu/events/mem-stores"),
 };
 #undef E
 
@@ -93,7 +93,7 @@ int perf_mem_events__init(void)
 		struct perf_mem_event *e = &perf_mem_events[j];
 		struct stat st;
 
-		scnprintf(path, PATH_MAX, "%s/devices/cpu/events/%s",
+		scnprintf(path, PATH_MAX, "%s/devices/%s",
 			  mnt, e->sysfs_name);
 
 		if (!stat(path, &st))
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 2/9] perf mem: Introduce weak function perf_mem_events__ptr()
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

Different architectures might use different event or different event
parameters for memory profiling, this patch introduces weak function
perf_mem_events__ptr(), which allows to return back architecture
specific memory event.

Since the variable 'perf_mem_events' can be only accessed by the
function perf_mem_events__ptr(), marks the variable as 'static', this
allows the architectures to define its own memory event array.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/builtin-c2c.c     | 18 ++++++++++++------
 tools/perf/builtin-mem.c     | 21 ++++++++++++++-------
 tools/perf/util/mem-events.c | 26 +++++++++++++++++++-------
 tools/perf/util/mem-events.h |  2 +-
 4 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index d5bea5d3cd51..4d1a08e38233 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2867,6 +2867,7 @@ static int perf_c2c__record(int argc, const char **argv)
 	int ret;
 	bool all_user = false, all_kernel = false;
 	bool event_set = false;
+	struct perf_mem_event *e;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &event_set, "event",
 		     "event selector. Use 'perf c2c record -e list' to list available events",
@@ -2894,11 +2895,15 @@ static int perf_c2c__record(int argc, const char **argv)
 	rec_argv[i++] = "record";
 
 	if (!event_set) {
-		perf_mem_events[PERF_MEM_EVENTS__LOAD].record  = true;
-		perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+		e->record = true;
+
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__STORE);
+		e->record = true;
 	}
 
-	if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
+	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+	if (e->record)
 		rec_argv[i++] = "-W";
 
 	rec_argv[i++] = "-d";
@@ -2906,12 +2911,13 @@ static int perf_c2c__record(int argc, const char **argv)
 	rec_argv[i++] = "--sample-cpu";
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-		if (!perf_mem_events[j].record)
+		e = perf_mem_events__ptr(j);
+		if (!e->record)
 			continue;
 
-		if (!perf_mem_events[j].supported) {
+		if (!e->supported) {
 			pr_err("failed: event '%s' not supported\n",
-			       perf_mem_events[j].name);
+			       perf_mem_events__name(j));
 			free(rec_argv);
 			return -1;
 		}
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 3523279af6af..9a7df8d01296 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -64,6 +64,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	const char **rec_argv;
 	int ret;
 	bool all_user = false, all_kernel = false;
+	struct perf_mem_event *e;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
@@ -86,13 +87,18 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 
 	rec_argv[i++] = "record";
 
-	if (mem->operation & MEM_OPERATION_LOAD)
-		perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true;
+	if (mem->operation & MEM_OPERATION_LOAD) {
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+		e->record = true;
+	}
 
-	if (mem->operation & MEM_OPERATION_STORE)
-		perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
+	if (mem->operation & MEM_OPERATION_STORE) {
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__STORE);
+		e->record = true;
+	}
 
-	if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
+	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+	if (e->record)
 		rec_argv[i++] = "-W";
 
 	rec_argv[i++] = "-d";
@@ -101,10 +107,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		rec_argv[i++] = "--phys-data";
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-		if (!perf_mem_events[j].record)
+		e = perf_mem_events__ptr(j);
+		if (!e->record)
 			continue;
 
-		if (!perf_mem_events[j].supported) {
+		if (!e->supported) {
 			pr_err("failed: event '%s' not supported\n",
 			       perf_mem_events__name(j));
 			free(rec_argv);
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 35c8d175a9d2..7a5a0d699e27 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -17,7 +17,7 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
-struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
+static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"cpu/events/mem-loads"),
 	E("ldlat-stores",	"cpu/mem-stores/P",		"cpu/events/mem-stores"),
 };
@@ -28,19 +28,31 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 static char mem_loads_name[100];
 static bool mem_loads_name__init;
 
+struct perf_mem_event * __weak perf_mem_events__ptr(int i)
+{
+	if (i >= PERF_MEM_EVENTS__MAX)
+		return NULL;
+
+	return &perf_mem_events[i];
+}
+
 char * __weak perf_mem_events__name(int i)
 {
+	struct perf_mem_event *e = perf_mem_events__ptr(i);
+
+	if (!e)
+		return NULL;
+
 	if (i == PERF_MEM_EVENTS__LOAD) {
 		if (!mem_loads_name__init) {
 			mem_loads_name__init = true;
 			scnprintf(mem_loads_name, sizeof(mem_loads_name),
-				  perf_mem_events[i].name,
-				  perf_mem_events__loads_ldlat);
+				  e->name, perf_mem_events__loads_ldlat);
 		}
 		return mem_loads_name;
 	}
 
-	return (char *)perf_mem_events[i].name;
+	return (char *)e->name;
 }
 
 int perf_mem_events__parse(const char *str)
@@ -61,7 +73,7 @@ int perf_mem_events__parse(const char *str)
 
 	while (tok) {
 		for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-			struct perf_mem_event *e = &perf_mem_events[j];
+			struct perf_mem_event *e = perf_mem_events__ptr(j);
 
 			if (strstr(e->tag, tok))
 				e->record = found = true;
@@ -90,7 +102,7 @@ int perf_mem_events__init(void)
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
 		char path[PATH_MAX];
-		struct perf_mem_event *e = &perf_mem_events[j];
+		struct perf_mem_event *e = perf_mem_events__ptr(j);
 		struct stat st;
 
 		scnprintf(path, PATH_MAX, "%s/devices/%s",
@@ -108,7 +120,7 @@ void perf_mem_events__list(void)
 	int j;
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-		struct perf_mem_event *e = &perf_mem_events[j];
+		struct perf_mem_event *e = perf_mem_events__ptr(j);
 
 		fprintf(stderr, "%-13s%-*s%s\n",
 			e->tag,
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 904dad34f7f7..726a9c8103e4 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -31,13 +31,13 @@ enum {
 	PERF_MEM_EVENTS__MAX,
 };
 
-extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
 extern unsigned int perf_mem_events__loads_ldlat;
 
 int perf_mem_events__parse(const char *str);
 int perf_mem_events__init(void);
 
 char *perf_mem_events__name(int i);
+struct perf_mem_event *perf_mem_events__ptr(int i);
 
 void perf_mem_events__list(void);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 2/9] perf mem: Introduce weak function perf_mem_events__ptr()
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

Different architectures might use different event or different event
parameters for memory profiling, this patch introduces weak function
perf_mem_events__ptr(), which allows to return back architecture
specific memory event.

Since the variable 'perf_mem_events' can be only accessed by the
function perf_mem_events__ptr(), marks the variable as 'static', this
allows the architectures to define its own memory event array.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/builtin-c2c.c     | 18 ++++++++++++------
 tools/perf/builtin-mem.c     | 21 ++++++++++++++-------
 tools/perf/util/mem-events.c | 26 +++++++++++++++++++-------
 tools/perf/util/mem-events.h |  2 +-
 4 files changed, 46 insertions(+), 21 deletions(-)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index d5bea5d3cd51..4d1a08e38233 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2867,6 +2867,7 @@ static int perf_c2c__record(int argc, const char **argv)
 	int ret;
 	bool all_user = false, all_kernel = false;
 	bool event_set = false;
+	struct perf_mem_event *e;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &event_set, "event",
 		     "event selector. Use 'perf c2c record -e list' to list available events",
@@ -2894,11 +2895,15 @@ static int perf_c2c__record(int argc, const char **argv)
 	rec_argv[i++] = "record";
 
 	if (!event_set) {
-		perf_mem_events[PERF_MEM_EVENTS__LOAD].record  = true;
-		perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+		e->record = true;
+
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__STORE);
+		e->record = true;
 	}
 
-	if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
+	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+	if (e->record)
 		rec_argv[i++] = "-W";
 
 	rec_argv[i++] = "-d";
@@ -2906,12 +2911,13 @@ static int perf_c2c__record(int argc, const char **argv)
 	rec_argv[i++] = "--sample-cpu";
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-		if (!perf_mem_events[j].record)
+		e = perf_mem_events__ptr(j);
+		if (!e->record)
 			continue;
 
-		if (!perf_mem_events[j].supported) {
+		if (!e->supported) {
 			pr_err("failed: event '%s' not supported\n",
-			       perf_mem_events[j].name);
+			       perf_mem_events__name(j));
 			free(rec_argv);
 			return -1;
 		}
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 3523279af6af..9a7df8d01296 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -64,6 +64,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	const char **rec_argv;
 	int ret;
 	bool all_user = false, all_kernel = false;
+	struct perf_mem_event *e;
 	struct option options[] = {
 	OPT_CALLBACK('e', "event", &mem, "event",
 		     "event selector. use 'perf mem record -e list' to list available events",
@@ -86,13 +87,18 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 
 	rec_argv[i++] = "record";
 
-	if (mem->operation & MEM_OPERATION_LOAD)
-		perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true;
+	if (mem->operation & MEM_OPERATION_LOAD) {
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+		e->record = true;
+	}
 
-	if (mem->operation & MEM_OPERATION_STORE)
-		perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
+	if (mem->operation & MEM_OPERATION_STORE) {
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__STORE);
+		e->record = true;
+	}
 
-	if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
+	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
+	if (e->record)
 		rec_argv[i++] = "-W";
 
 	rec_argv[i++] = "-d";
@@ -101,10 +107,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		rec_argv[i++] = "--phys-data";
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-		if (!perf_mem_events[j].record)
+		e = perf_mem_events__ptr(j);
+		if (!e->record)
 			continue;
 
-		if (!perf_mem_events[j].supported) {
+		if (!e->supported) {
 			pr_err("failed: event '%s' not supported\n",
 			       perf_mem_events__name(j));
 			free(rec_argv);
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 35c8d175a9d2..7a5a0d699e27 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -17,7 +17,7 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 
 #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
 
-struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
+static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"cpu/events/mem-loads"),
 	E("ldlat-stores",	"cpu/mem-stores/P",		"cpu/events/mem-stores"),
 };
@@ -28,19 +28,31 @@ struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 static char mem_loads_name[100];
 static bool mem_loads_name__init;
 
+struct perf_mem_event * __weak perf_mem_events__ptr(int i)
+{
+	if (i >= PERF_MEM_EVENTS__MAX)
+		return NULL;
+
+	return &perf_mem_events[i];
+}
+
 char * __weak perf_mem_events__name(int i)
 {
+	struct perf_mem_event *e = perf_mem_events__ptr(i);
+
+	if (!e)
+		return NULL;
+
 	if (i == PERF_MEM_EVENTS__LOAD) {
 		if (!mem_loads_name__init) {
 			mem_loads_name__init = true;
 			scnprintf(mem_loads_name, sizeof(mem_loads_name),
-				  perf_mem_events[i].name,
-				  perf_mem_events__loads_ldlat);
+				  e->name, perf_mem_events__loads_ldlat);
 		}
 		return mem_loads_name;
 	}
 
-	return (char *)perf_mem_events[i].name;
+	return (char *)e->name;
 }
 
 int perf_mem_events__parse(const char *str)
@@ -61,7 +73,7 @@ int perf_mem_events__parse(const char *str)
 
 	while (tok) {
 		for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-			struct perf_mem_event *e = &perf_mem_events[j];
+			struct perf_mem_event *e = perf_mem_events__ptr(j);
 
 			if (strstr(e->tag, tok))
 				e->record = found = true;
@@ -90,7 +102,7 @@ int perf_mem_events__init(void)
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
 		char path[PATH_MAX];
-		struct perf_mem_event *e = &perf_mem_events[j];
+		struct perf_mem_event *e = perf_mem_events__ptr(j);
 		struct stat st;
 
 		scnprintf(path, PATH_MAX, "%s/devices/%s",
@@ -108,7 +120,7 @@ void perf_mem_events__list(void)
 	int j;
 
 	for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
-		struct perf_mem_event *e = &perf_mem_events[j];
+		struct perf_mem_event *e = perf_mem_events__ptr(j);
 
 		fprintf(stderr, "%-13s%-*s%s\n",
 			e->tag,
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 904dad34f7f7..726a9c8103e4 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -31,13 +31,13 @@ enum {
 	PERF_MEM_EVENTS__MAX,
 };
 
-extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
 extern unsigned int perf_mem_events__loads_ldlat;
 
 int perf_mem_events__parse(const char *str);
 int perf_mem_events__init(void);
 
 char *perf_mem_events__name(int i);
+struct perf_mem_event *perf_mem_events__ptr(int i);
 
 void perf_mem_events__list(void);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

On the architectures with perf memory profiling, two types of hardware
events have been supported: load and store; if want to profile memory
for both load and store operations, the tool will use these two events
at the same time, the usage is:

  # perf mem record -t load,store -- uname

But this cannot be applied for AUX tracing event, the same PMU event can
be used to only trace memory load, or only memory store, or trace for
both memory load and store.

This patch introduces a new event PERF_MEM_EVENTS__LOAD_STORE, which is
used to support the event which can record both memory load and store
operations, thus a new type option "ldst" is added:

  # perf mem record -t ldst -- uname

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/builtin-mem.c     | 13 ++++++++++---
 tools/perf/util/mem-events.c | 13 ++++++++++++-
 tools/perf/util/mem-events.h |  1 +
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 9a7df8d01296..31144f586e77 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -19,8 +19,9 @@
 #include "util/symbol.h"
 #include <linux/err.h>
 
-#define MEM_OPERATION_LOAD	0x1
-#define MEM_OPERATION_STORE	0x2
+#define MEM_OPERATION_LOAD		0x1
+#define MEM_OPERATION_STORE		0x2
+#define MEM_OPERATION_LOAD_STORE	0x4
 
 struct perf_mem {
 	struct perf_tool	tool;
@@ -97,6 +98,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		e->record = true;
 	}
 
+	if (mem->operation & MEM_OPERATION_LOAD_STORE) {
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD_STORE);
+		e->record = true;
+	}
+
 	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
 	if (e->record)
 		rec_argv[i++] = "-W";
@@ -326,6 +332,7 @@ struct mem_mode {
 static const struct mem_mode mem_modes[]={
 	MEM_OPT("load", MEM_OPERATION_LOAD),
 	MEM_OPT("store", MEM_OPERATION_STORE),
+	MEM_OPT("ldst", MEM_OPERATION_LOAD_STORE),
 	MEM_END
 };
 
@@ -405,7 +412,7 @@ int cmd_mem(int argc, const char **argv)
 	};
 	const struct option mem_options[] = {
 	OPT_CALLBACK('t', "type", &mem.operation,
-		   "type", "memory operations(load,store) Default load,store",
+		   "type", "memory operations(load,store,ldst) Default load,store",
 		    parse_mem_ops),
 	OPT_BOOLEAN('D', "dump-raw-samples", &mem.dump_raw,
 		    "dump raw samples in ASCII"),
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 7a5a0d699e27..2e82b4e78f29 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -20,6 +20,7 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"cpu/events/mem-loads"),
 	E("ldlat-stores",	"cpu/mem-stores/P",		"cpu/events/mem-stores"),
+	E(NULL,			NULL,				NULL),
 };
 #undef E
 
@@ -75,6 +76,9 @@ int perf_mem_events__parse(const char *str)
 		for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
 			struct perf_mem_event *e = perf_mem_events__ptr(j);
 
+			if (!e->tag)
+				continue;
+
 			if (strstr(e->tag, tok))
 				e->record = found = true;
 		}
@@ -105,6 +109,13 @@ int perf_mem_events__init(void)
 		struct perf_mem_event *e = perf_mem_events__ptr(j);
 		struct stat st;
 
+		/*
+		 * If the event entry isn't valid, skip initialization
+		 * and "e->supported" will keep false.
+		 */
+		if (!e->tag)
+			continue;
+
 		scnprintf(path, PATH_MAX, "%s/devices/%s",
 			  mnt, e->sysfs_name);
 
@@ -123,7 +134,7 @@ void perf_mem_events__list(void)
 		struct perf_mem_event *e = perf_mem_events__ptr(j);
 
 		fprintf(stderr, "%-13s%-*s%s\n",
-			e->tag,
+			e->tag ? e->tag : "",
 			verbose > 0 ? 25 : 0,
 			verbose > 0 ? perf_mem_events__name(j) : "",
 			e->supported ? ": available" : "");
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 726a9c8103e4..5ef178278909 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -28,6 +28,7 @@ struct mem_info {
 enum {
 	PERF_MEM_EVENTS__LOAD,
 	PERF_MEM_EVENTS__STORE,
+	PERF_MEM_EVENTS__LOAD_STORE,
 	PERF_MEM_EVENTS__MAX,
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

On the architectures with perf memory profiling, two types of hardware
events have been supported: load and store; if want to profile memory
for both load and store operations, the tool will use these two events
at the same time, the usage is:

  # perf mem record -t load,store -- uname

But this cannot be applied for AUX tracing event, the same PMU event can
be used to only trace memory load, or only memory store, or trace for
both memory load and store.

This patch introduces a new event PERF_MEM_EVENTS__LOAD_STORE, which is
used to support the event which can record both memory load and store
operations, thus a new type option "ldst" is added:

  # perf mem record -t ldst -- uname

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/builtin-mem.c     | 13 ++++++++++---
 tools/perf/util/mem-events.c | 13 ++++++++++++-
 tools/perf/util/mem-events.h |  1 +
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 9a7df8d01296..31144f586e77 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -19,8 +19,9 @@
 #include "util/symbol.h"
 #include <linux/err.h>
 
-#define MEM_OPERATION_LOAD	0x1
-#define MEM_OPERATION_STORE	0x2
+#define MEM_OPERATION_LOAD		0x1
+#define MEM_OPERATION_STORE		0x2
+#define MEM_OPERATION_LOAD_STORE	0x4
 
 struct perf_mem {
 	struct perf_tool	tool;
@@ -97,6 +98,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 		e->record = true;
 	}
 
+	if (mem->operation & MEM_OPERATION_LOAD_STORE) {
+		e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD_STORE);
+		e->record = true;
+	}
+
 	e = perf_mem_events__ptr(PERF_MEM_EVENTS__LOAD);
 	if (e->record)
 		rec_argv[i++] = "-W";
@@ -326,6 +332,7 @@ struct mem_mode {
 static const struct mem_mode mem_modes[]={
 	MEM_OPT("load", MEM_OPERATION_LOAD),
 	MEM_OPT("store", MEM_OPERATION_STORE),
+	MEM_OPT("ldst", MEM_OPERATION_LOAD_STORE),
 	MEM_END
 };
 
@@ -405,7 +412,7 @@ int cmd_mem(int argc, const char **argv)
 	};
 	const struct option mem_options[] = {
 	OPT_CALLBACK('t', "type", &mem.operation,
-		   "type", "memory operations(load,store) Default load,store",
+		   "type", "memory operations(load,store,ldst) Default load,store",
 		    parse_mem_ops),
 	OPT_BOOLEAN('D', "dump-raw-samples", &mem.dump_raw,
 		    "dump raw samples in ASCII"),
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 7a5a0d699e27..2e82b4e78f29 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -20,6 +20,7 @@ unsigned int perf_mem_events__loads_ldlat = 30;
 static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
 	E("ldlat-loads",	"cpu/mem-loads,ldlat=%u/P",	"cpu/events/mem-loads"),
 	E("ldlat-stores",	"cpu/mem-stores/P",		"cpu/events/mem-stores"),
+	E(NULL,			NULL,				NULL),
 };
 #undef E
 
@@ -75,6 +76,9 @@ int perf_mem_events__parse(const char *str)
 		for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
 			struct perf_mem_event *e = perf_mem_events__ptr(j);
 
+			if (!e->tag)
+				continue;
+
 			if (strstr(e->tag, tok))
 				e->record = found = true;
 		}
@@ -105,6 +109,13 @@ int perf_mem_events__init(void)
 		struct perf_mem_event *e = perf_mem_events__ptr(j);
 		struct stat st;
 
+		/*
+		 * If the event entry isn't valid, skip initialization
+		 * and "e->supported" will keep false.
+		 */
+		if (!e->tag)
+			continue;
+
 		scnprintf(path, PATH_MAX, "%s/devices/%s",
 			  mnt, e->sysfs_name);
 
@@ -123,7 +134,7 @@ void perf_mem_events__list(void)
 		struct perf_mem_event *e = perf_mem_events__ptr(j);
 
 		fprintf(stderr, "%-13s%-*s%s\n",
-			e->tag,
+			e->tag ? e->tag : "",
 			verbose > 0 ? 25 : 0,
 			verbose > 0 ? perf_mem_events__name(j) : "",
 			e->supported ? ": available" : "");
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 726a9c8103e4..5ef178278909 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -28,6 +28,7 @@ struct mem_info {
 enum {
 	PERF_MEM_EVENTS__LOAD,
 	PERF_MEM_EVENTS__STORE,
+	PERF_MEM_EVENTS__LOAD_STORE,
 	PERF_MEM_EVENTS__MAX,
 };
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 4/9] perf mem: Only initialize memory event for recording
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

It's needless to initialize memory events for reporting, this patch
moves memory event initialization for only recording.  Furthermore,
the change allows to parse perf data on cross platforms, e.g. perf
tool can report result properly even the machine doesn't support
the memory events.

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

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 31144f586e77..f3dc2d2b879c 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -78,6 +78,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_END()
 	};
 
+	if (perf_mem_events__init()) {
+		pr_err("failed: memory events not supported\n");
+		return -1;
+	}
+
 	argc = parse_options(argc, argv, options, record_mem_usage,
 			     PARSE_OPT_KEEP_UNKNOWN);
 
@@ -436,11 +441,6 @@ int cmd_mem(int argc, const char **argv)
 		NULL
 	};
 
-	if (perf_mem_events__init()) {
-		pr_err("failed: memory events not supported\n");
-		return -1;
-	}
-
 	argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
 					mem_usage, PARSE_OPT_KEEP_UNKNOWN);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 4/9] perf mem: Only initialize memory event for recording
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

It's needless to initialize memory events for reporting, this patch
moves memory event initialization for only recording.  Furthermore,
the change allows to parse perf data on cross platforms, e.g. perf
tool can report result properly even the machine doesn't support
the memory events.

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

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 31144f586e77..f3dc2d2b879c 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -78,6 +78,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_END()
 	};
 
+	if (perf_mem_events__init()) {
+		pr_err("failed: memory events not supported\n");
+		return -1;
+	}
+
 	argc = parse_options(argc, argv, options, record_mem_usage,
 			     PARSE_OPT_KEEP_UNKNOWN);
 
@@ -436,11 +441,6 @@ int cmd_mem(int argc, const char **argv)
 		NULL
 	};
 
-	if (perf_mem_events__init()) {
-		pr_err("failed: memory events not supported\n");
-		return -1;
-	}
-
 	argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
 					mem_usage, PARSE_OPT_KEEP_UNKNOWN);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 5/9] perf mem: Support AUX trace
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

Perf memory tool doesn't support AUX trace data so it cannot receive the
hardware tracing data.  On Arm64, although it doesn't support PMU events
for memory load and store, but Arm SPE is a good candidate for memory
profiling, the hardware tracer can record memory accessing operations
with affiliated information (e.g. physical address and virtual address
for accessing, cache levels, TLB walking, latency, etc).

To allow "perf mem" tool to support AUX trace, this patches adds the AUX
callbacks for session structure.

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

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index f3dc2d2b879c..87c6074e405e 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"
@@ -405,8 +406,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		= perf_event__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.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 5/9] perf mem: Support AUX trace
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

Perf memory tool doesn't support AUX trace data so it cannot receive the
hardware tracing data.  On Arm64, although it doesn't support PMU events
for memory load and store, but Arm SPE is a good candidate for memory
profiling, the hardware tracer can record memory accessing operations
with affiliated information (e.g. physical address and virtual address
for accessing, cache levels, TLB walking, latency, etc).

To allow "perf mem" tool to support AUX trace, this patches adds the AUX
callbacks for session structure.

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

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index f3dc2d2b879c..87c6074e405e 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"
@@ -405,8 +406,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		= perf_event__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.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 6/9] perf c2c: Support AUX trace
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

This patches adds the AUX callbacks in session structure, so support
AUX trace for "perf c2c" tool.

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

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 4d1a08e38233..24f4af997aab 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
 		.exit		= perf_event__process_exit,
 		.fork		= perf_event__process_fork,
 		.lost		= perf_event__process_lost,
+		.attr		= perf_event__process_attr,
+		.auxtrace_info  = perf_event__process_auxtrace_info,
+		.auxtrace       = perf_event__process_auxtrace,
+		.auxtrace_error = perf_event__process_auxtrace_error,
 		.ordered_events	= true,
 		.ordering_requires_timestamps = true,
 	},
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 6/9] perf c2c: Support AUX trace
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

This patches adds the AUX callbacks in session structure, so support
AUX trace for "perf c2c" tool.

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

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 4d1a08e38233..24f4af997aab 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
 		.exit		= perf_event__process_exit,
 		.fork		= perf_event__process_fork,
 		.lost		= perf_event__process_lost,
+		.attr		= perf_event__process_attr,
+		.auxtrace_info  = perf_event__process_auxtrace_info,
+		.auxtrace       = perf_event__process_auxtrace,
+		.auxtrace_error = perf_event__process_auxtrace_error,
 		.ordered_events	= true,
 		.ordering_requires_timestamps = true,
 	},
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 7/9] perf mem: Support Arm SPE events
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

This patch adds Arm SPE events for perf memory profiling:

  'spe-load': event for only recording memory load ops;
  'spe-store': event for only recording memory store ops;
  'spe-ldst': event for recording memory load and store ops.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/arch/arm64/util/Build        |  2 +-
 tools/perf/arch/arm64/util/mem-events.c | 37 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/arch/arm64/util/mem-events.c

diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index b53294d74b01..cf6d7e799f33 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -9,4 +9,4 @@ perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 perf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
 			      ../../arm/util/auxtrace.o \
 			      ../../arm/util/cs-etm.o \
-			      arm-spe.o
+			      arm-spe.o mem-events.o
diff --git a/tools/perf/arch/arm64/util/mem-events.c b/tools/perf/arch/arm64/util/mem-events.c
new file mode 100644
index 000000000000..2a2497372671
--- /dev/null
+++ b/tools/perf/arch/arm64/util/mem-events.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "map_symbol.h"
+#include "mem-events.h"
+
+#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
+
+static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
+	E("spe-load",	"arm_spe_0/ts_enable=1,load_filter=1,store_filter=0,min_latency=%u/",	"arm_spe_0"),
+	E("spe-store",	"arm_spe_0/ts_enable=1,load_filter=0,store_filter=1/",			"arm_spe_0"),
+	E("spe-ldst",	"arm_spe_0/ts_enable=1,load_filter=1,store_filter=1,min_latency=%u/",	"arm_spe_0"),
+};
+
+static char mem_ev_name[100];
+
+struct perf_mem_event *perf_mem_events__ptr(int i)
+{
+	if (i >= PERF_MEM_EVENTS__MAX)
+		return NULL;
+
+	return &perf_mem_events[i];
+}
+
+char *perf_mem_events__name(int i)
+{
+	struct perf_mem_event *e = perf_mem_events__ptr(i);
+
+	if (i >= PERF_MEM_EVENTS__MAX)
+		return NULL;
+
+	if (i == PERF_MEM_EVENTS__LOAD || i == PERF_MEM_EVENTS__LOAD_STORE)
+		scnprintf(mem_ev_name, sizeof(mem_ev_name),
+			  e->name, perf_mem_events__loads_ldlat);
+	else /* PERF_MEM_EVENTS__STORE */
+		scnprintf(mem_ev_name, sizeof(mem_ev_name), e->name);
+
+	return mem_ev_name;
+}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 7/9] perf mem: Support Arm SPE events
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

This patch adds Arm SPE events for perf memory profiling:

  'spe-load': event for only recording memory load ops;
  'spe-store': event for only recording memory store ops;
  'spe-ldst': event for recording memory load and store ops.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/arch/arm64/util/Build        |  2 +-
 tools/perf/arch/arm64/util/mem-events.c | 37 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/arch/arm64/util/mem-events.c

diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index b53294d74b01..cf6d7e799f33 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -9,4 +9,4 @@ perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 perf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
 			      ../../arm/util/auxtrace.o \
 			      ../../arm/util/cs-etm.o \
-			      arm-spe.o
+			      arm-spe.o mem-events.o
diff --git a/tools/perf/arch/arm64/util/mem-events.c b/tools/perf/arch/arm64/util/mem-events.c
new file mode 100644
index 000000000000..2a2497372671
--- /dev/null
+++ b/tools/perf/arch/arm64/util/mem-events.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "map_symbol.h"
+#include "mem-events.h"
+
+#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
+
+static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
+	E("spe-load",	"arm_spe_0/ts_enable=1,load_filter=1,store_filter=0,min_latency=%u/",	"arm_spe_0"),
+	E("spe-store",	"arm_spe_0/ts_enable=1,load_filter=0,store_filter=1/",			"arm_spe_0"),
+	E("spe-ldst",	"arm_spe_0/ts_enable=1,load_filter=1,store_filter=1,min_latency=%u/",	"arm_spe_0"),
+};
+
+static char mem_ev_name[100];
+
+struct perf_mem_event *perf_mem_events__ptr(int i)
+{
+	if (i >= PERF_MEM_EVENTS__MAX)
+		return NULL;
+
+	return &perf_mem_events[i];
+}
+
+char *perf_mem_events__name(int i)
+{
+	struct perf_mem_event *e = perf_mem_events__ptr(i);
+
+	if (i >= PERF_MEM_EVENTS__MAX)
+		return NULL;
+
+	if (i == PERF_MEM_EVENTS__LOAD || i == PERF_MEM_EVENTS__LOAD_STORE)
+		scnprintf(mem_ev_name, sizeof(mem_ev_name),
+			  e->name, perf_mem_events__loads_ldlat);
+	else /* PERF_MEM_EVENTS__STORE */
+		scnprintf(mem_ev_name, sizeof(mem_ev_name), e->name);
+
+	return mem_ev_name;
+}
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 8/9] perf mem: Return NULL for event 'ldst' on PowerPC
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

If user specifies event type "ldst", PowerPC's perf_mem_events__name()
will wrongly return the store event name "cpu/mem-stores/".

This patch changes to return NULL for the event "ldst" on PowerPC.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/arch/powerpc/util/mem-events.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c
index 07fb5e049488..90c5a0760685 100644
--- a/tools/perf/arch/powerpc/util/mem-events.c
+++ b/tools/perf/arch/powerpc/util/mem-events.c
@@ -7,6 +7,8 @@ char *perf_mem_events__name(int i)
 {
 	if (i == PERF_MEM_EVENTS__LOAD)
 		return (char *) "cpu/mem-loads/";
-
-	return (char *) "cpu/mem-stores/";
+	else if (i == PERF_MEM_EVENTS__STORE)
+		return (char *) "cpu/mem-stores/";
+	else
+		return NULL;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 8/9] perf mem: Return NULL for event 'ldst' on PowerPC
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

If user specifies event type "ldst", PowerPC's perf_mem_events__name()
will wrongly return the store event name "cpu/mem-stores/".

This patch changes to return NULL for the event "ldst" on PowerPC.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/arch/powerpc/util/mem-events.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c
index 07fb5e049488..90c5a0760685 100644
--- a/tools/perf/arch/powerpc/util/mem-events.c
+++ b/tools/perf/arch/powerpc/util/mem-events.c
@@ -7,6 +7,8 @@ char *perf_mem_events__name(int i)
 {
 	if (i == PERF_MEM_EVENTS__LOAD)
 		return (char *) "cpu/mem-loads/";
-
-	return (char *) "cpu/mem-stores/";
+	else if (i == PERF_MEM_EVENTS__STORE)
+		return (char *) "cpu/mem-stores/";
+	else
+		return NULL;
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 9/9] perf mem: Document event type 'ldst'
  2020-10-28  6:38 ` Leo Yan
@ 2020-10-28  6:38   ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The event type 'ldst' is added for recording both load and store memory
operations, this patch documents for the new event type.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/Documentation/perf-mem.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
index 199ea0f0a6c0..c50ef37dba72 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -38,7 +38,11 @@ OPTIONS
 
 -t::
 --type=<type>::
-	Select the memory operation type: load or store (default: load,store)
+	Select the memory operation type: load, store, ldst (default: load,store).
+	The type 'ldst' means the single event can record both for load and store
+	operations; Intel and PowerPC support the types 'load' and 'store' but
+	'ldst' cannot be used; on Arm64, it uses Arm SPE as memory events and
+	user needs to specify one of these three types.
 
 -D::
 --dump-raw-samples::
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v3 9/9] perf mem: Document event type 'ldst'
@ 2020-10-28  6:38   ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-28  6:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Ian Rogers, Al Grant, James Clark, Wei Li,
	André Przywara, linux-kernel, linux-arm-kernel
  Cc: Leo Yan

The event type 'ldst' is added for recording both load and store memory
operations, this patch documents for the new event type.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/Documentation/perf-mem.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
index 199ea0f0a6c0..c50ef37dba72 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -38,7 +38,11 @@ OPTIONS
 
 -t::
 --type=<type>::
-	Select the memory operation type: load or store (default: load,store)
+	Select the memory operation type: load, store, ldst (default: load,store).
+	The type 'ldst' means the single event can record both for load and store
+	operations; Intel and PowerPC support the types 'load' and 'store' but
+	'ldst' cannot be used; on Arm64, it uses Arm SPE as memory events and
+	user needs to specify one of these three types.
 
 -D::
 --dump-raw-samples::
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 8/9] perf mem: Return NULL for event 'ldst' on PowerPC
  2020-10-28  6:38   ` Leo Yan
@ 2020-10-28  9:35     ` Naveen N. Rao
  -1 siblings, 0 replies; 38+ messages in thread
From: Naveen N. Rao @ 2020-10-28  9:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Alexander Shishkin, Al Grant,
	André Przywara, Ian Rogers, James Clark, John Garry,
	Jiri Olsa, Leo Yan, linux-arm-kernel, linux-kernel, Wei Li,
	Mark Rutland, Mathieu Poirier, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Kemeng Shi, Will Deacon, Madhavan Srinivasan

[+ Maddy]

Leo Yan wrote:
> If user specifies event type "ldst", PowerPC's perf_mem_events__name()
> will wrongly return the store event name "cpu/mem-stores/".
> 
> This patch changes to return NULL for the event "ldst" on PowerPC.
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/arch/powerpc/util/mem-events.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c
> index 07fb5e049488..90c5a0760685 100644
> --- a/tools/perf/arch/powerpc/util/mem-events.c
> +++ b/tools/perf/arch/powerpc/util/mem-events.c
> @@ -7,6 +7,8 @@ char *perf_mem_events__name(int i)
>  {
>  	if (i == PERF_MEM_EVENTS__LOAD)
>  		return (char *) "cpu/mem-loads/";
> -
> -	return (char *) "cpu/mem-stores/";
> +	else if (i == PERF_MEM_EVENTS__STORE)
> +		return (char *) "cpu/mem-stores/";
> +	else
> +		return NULL;
>  }
> -- 
> 2.17.1
> 
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 8/9] perf mem: Return NULL for event 'ldst' on PowerPC
@ 2020-10-28  9:35     ` Naveen N. Rao
  0 siblings, 0 replies; 38+ messages in thread
From: Naveen N. Rao @ 2020-10-28  9:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Alexander Shishkin, Al Grant,
	André Przywara, Ian Rogers, James Clark, John Garry,
	Jiri Olsa, Leo Yan, linux-arm-kernel, linux-kernel, Wei Li,
	Mark Rutland, Mathieu Poirier, Ingo Molnar, Namhyung Kim,
	Peter Zijlstra, Kemeng Shi, Will Deacon, Madhavan Srinivasan

[+ Maddy]

Leo Yan wrote:
> If user specifies event type "ldst", PowerPC's perf_mem_events__name()
> will wrongly return the store event name "cpu/mem-stores/".
> 
> This patch changes to return NULL for the event "ldst" on PowerPC.
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/arch/powerpc/util/mem-events.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/arch/powerpc/util/mem-events.c b/tools/perf/arch/powerpc/util/mem-events.c
> index 07fb5e049488..90c5a0760685 100644
> --- a/tools/perf/arch/powerpc/util/mem-events.c
> +++ b/tools/perf/arch/powerpc/util/mem-events.c
> @@ -7,6 +7,8 @@ char *perf_mem_events__name(int i)
>  {
>  	if (i == PERF_MEM_EVENTS__LOAD)
>  		return (char *) "cpu/mem-loads/";
> -
> -	return (char *) "cpu/mem-stores/";
> +	else if (i == PERF_MEM_EVENTS__STORE)
> +		return (char *) "cpu/mem-stores/";
> +	else
> +		return NULL;
>  }
> -- 
> 2.17.1
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 4/9] perf mem: Only initialize memory event for recording
  2020-10-28  6:38   ` Leo Yan
@ 2020-10-30  1:04     ` Ian Rogers
  -1 siblings, 0 replies; 38+ messages in thread
From: Ian Rogers @ 2020-10-30  1:04 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Al Grant, James Clark, Wei Li,
	André Przywara, LKML, Linux ARM

On Tue, Oct 27, 2020 at 11:38 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> It's needless to initialize memory events for reporting, this patch
> moves memory event initialization for only recording.  Furthermore,
> the change allows to parse perf data on cross platforms, e.g. perf
> tool can report result properly even the machine doesn't support
> the memory events.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/builtin-mem.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
> index 31144f586e77..f3dc2d2b879c 100644
> --- a/tools/perf/builtin-mem.c
> +++ b/tools/perf/builtin-mem.c
> @@ -78,6 +78,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
>         OPT_END()
>         };
>
> +       if (perf_mem_events__init()) {
> +               pr_err("failed: memory events not supported\n");
> +               return -1;
> +       }
> +
>         argc = parse_options(argc, argv, options, record_mem_usage,
>                              PARSE_OPT_KEEP_UNKNOWN);
>
> @@ -436,11 +441,6 @@ int cmd_mem(int argc, const char **argv)
>                 NULL
>         };
>
> -       if (perf_mem_events__init()) {
> -               pr_err("failed: memory events not supported\n");
> -               return -1;
> -       }
> -
>         argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
>                                         mem_usage, PARSE_OPT_KEEP_UNKNOWN);
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 4/9] perf mem: Only initialize memory event for recording
@ 2020-10-30  1:04     ` Ian Rogers
  0 siblings, 0 replies; 38+ messages in thread
From: Ian Rogers @ 2020-10-30  1:04 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Will Deacon, John Garry, LKML,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Jiri Olsa, Linux ARM, Wei Li

On Tue, Oct 27, 2020 at 11:38 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> It's needless to initialize memory events for reporting, this patch
> moves memory event initialization for only recording.  Furthermore,
> the change allows to parse perf data on cross platforms, e.g. perf
> tool can report result properly even the machine doesn't support
> the memory events.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/builtin-mem.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
> index 31144f586e77..f3dc2d2b879c 100644
> --- a/tools/perf/builtin-mem.c
> +++ b/tools/perf/builtin-mem.c
> @@ -78,6 +78,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
>         OPT_END()
>         };
>
> +       if (perf_mem_events__init()) {
> +               pr_err("failed: memory events not supported\n");
> +               return -1;
> +       }
> +
>         argc = parse_options(argc, argv, options, record_mem_usage,
>                              PARSE_OPT_KEEP_UNKNOWN);
>
> @@ -436,11 +441,6 @@ int cmd_mem(int argc, const char **argv)
>                 NULL
>         };
>
> -       if (perf_mem_events__init()) {
> -               pr_err("failed: memory events not supported\n");
> -               return -1;
> -       }
> -
>         argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
>                                         mem_usage, PARSE_OPT_KEEP_UNKNOWN);
>
> --
> 2.17.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 9/9] perf mem: Document event type 'ldst'
  2020-10-28  6:38   ` Leo Yan
@ 2020-10-30  1:10     ` Ian Rogers
  -1 siblings, 0 replies; 38+ messages in thread
From: Ian Rogers @ 2020-10-30  1:10 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Al Grant, James Clark, Wei Li,
	André Przywara, LKML, Linux ARM

On Tue, Oct 27, 2020 at 11:39 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> The event type 'ldst' is added for recording both load and store memory
> operations, this patch documents for the new event type.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/Documentation/perf-mem.txt | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
> index 199ea0f0a6c0..c50ef37dba72 100644
> --- a/tools/perf/Documentation/perf-mem.txt
> +++ b/tools/perf/Documentation/perf-mem.txt
> @@ -38,7 +38,11 @@ OPTIONS
>
>  -t::
>  --type=<type>::
> -       Select the memory operation type: load or store (default: load,store)
> +       Select the memory operation type: load, store, ldst (default: load,store).
> +       The type 'ldst' means the single event can record both for load and store
> +       operations; Intel and PowerPC support the types 'load' and 'store' but
> +       'ldst' cannot be used; on Arm64, it uses Arm SPE as memory events and
> +       user needs to specify one of these three types.

Naive question, could the type remain load,store for mem record and
the tool internally change it to ldst for ARM SPE?

Thanks,
Ian

>  -D::
>  --dump-raw-samples::

> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 9/9] perf mem: Document event type 'ldst'
@ 2020-10-30  1:10     ` Ian Rogers
  0 siblings, 0 replies; 38+ messages in thread
From: Ian Rogers @ 2020-10-30  1:10 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Will Deacon, John Garry, LKML,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Jiri Olsa, Linux ARM, Wei Li

On Tue, Oct 27, 2020 at 11:39 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> The event type 'ldst' is added for recording both load and store memory
> operations, this patch documents for the new event type.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/Documentation/perf-mem.txt | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
> index 199ea0f0a6c0..c50ef37dba72 100644
> --- a/tools/perf/Documentation/perf-mem.txt
> +++ b/tools/perf/Documentation/perf-mem.txt
> @@ -38,7 +38,11 @@ OPTIONS
>
>  -t::
>  --type=<type>::
> -       Select the memory operation type: load or store (default: load,store)
> +       Select the memory operation type: load, store, ldst (default: load,store).
> +       The type 'ldst' means the single event can record both for load and store
> +       operations; Intel and PowerPC support the types 'load' and 'store' but
> +       'ldst' cannot be used; on Arm64, it uses Arm SPE as memory events and
> +       user needs to specify one of these three types.

Naive question, could the type remain load,store for mem record and
the tool internally change it to ldst for ARM SPE?

Thanks,
Ian

>  -D::
>  --dump-raw-samples::

> --
> 2.17.1
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 9/9] perf mem: Document event type 'ldst'
  2020-10-30  1:10     ` Ian Rogers
@ 2020-10-30  1:49       ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-30  1:49 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	John Garry, Will Deacon, Mathieu Poirier, Kemeng Shi,
	Naveen N. Rao, Al Grant, James Clark, Wei Li,
	André Przywara, LKML, Linux ARM

Hi Ian,

On Thu, Oct 29, 2020 at 06:10:40PM -0700, Ian Rogers wrote:
> On Tue, Oct 27, 2020 at 11:39 PM Leo Yan <leo.yan@linaro.org> wrote:
> >
> > The event type 'ldst' is added for recording both load and store memory
> > operations, this patch documents for the new event type.
> >
> > Signed-off-by: Leo Yan <leo.yan@linaro.org>
> > ---
> >  tools/perf/Documentation/perf-mem.txt | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
> > index 199ea0f0a6c0..c50ef37dba72 100644
> > --- a/tools/perf/Documentation/perf-mem.txt
> > +++ b/tools/perf/Documentation/perf-mem.txt
> > @@ -38,7 +38,11 @@ OPTIONS
> >
> >  -t::
> >  --type=<type>::
> > -       Select the memory operation type: load or store (default: load,store)
> > +       Select the memory operation type: load, store, ldst (default: load,store).
> > +       The type 'ldst' means the single event can record both for load and store
> > +       operations; Intel and PowerPC support the types 'load' and 'store' but
> > +       'ldst' cannot be used; on Arm64, it uses Arm SPE as memory events and
> > +       user needs to specify one of these three types.
> 
> Naive question, could the type remain load,store for mem record and
> the tool internally change it to ldst for ARM SPE?

Good point.  I understand you are suggesting to avoid complex options
for usage, looked again at the code, my conclusion is it's feabile to
convert 'load,store' to Arm SPE's ldst type.

If find any block issue when I experiment this idea, will come back to
update it; otherwise, I will apply the suggestion in next spin.

Thanks for suggestion,
Leo

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 9/9] perf mem: Document event type 'ldst'
@ 2020-10-30  1:49       ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-10-30  1:49 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Mark Rutland, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Will Deacon, John Garry, LKML,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Jiri Olsa, Linux ARM, Wei Li

Hi Ian,

On Thu, Oct 29, 2020 at 06:10:40PM -0700, Ian Rogers wrote:
> On Tue, Oct 27, 2020 at 11:39 PM Leo Yan <leo.yan@linaro.org> wrote:
> >
> > The event type 'ldst' is added for recording both load and store memory
> > operations, this patch documents for the new event type.
> >
> > Signed-off-by: Leo Yan <leo.yan@linaro.org>
> > ---
> >  tools/perf/Documentation/perf-mem.txt | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
> > index 199ea0f0a6c0..c50ef37dba72 100644
> > --- a/tools/perf/Documentation/perf-mem.txt
> > +++ b/tools/perf/Documentation/perf-mem.txt
> > @@ -38,7 +38,11 @@ OPTIONS
> >
> >  -t::
> >  --type=<type>::
> > -       Select the memory operation type: load or store (default: load,store)
> > +       Select the memory operation type: load, store, ldst (default: load,store).
> > +       The type 'ldst' means the single event can record both for load and store
> > +       operations; Intel and PowerPC support the types 'load' and 'store' but
> > +       'ldst' cannot be used; on Arm64, it uses Arm SPE as memory events and
> > +       user needs to specify one of these three types.
> 
> Naive question, could the type remain load,store for mem record and
> the tool internally change it to ldst for ARM SPE?

Good point.  I understand you are suggesting to avoid complex options
for usage, looked again at the code, my conclusion is it's feabile to
convert 'load,store' to Arm SPE's ldst type.

If find any block issue when I experiment this idea, will come back to
update it; otherwise, I will apply the suggestion in next spin.

Thanks for suggestion,
Leo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 6/9] perf c2c: Support AUX trace
  2020-10-28  6:38   ` Leo Yan
@ 2020-10-31 20:21     ` Jiri Olsa
  -1 siblings, 0 replies; 38+ messages in thread
From: Jiri Olsa @ 2020-10-31 20:21 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, John Garry,
	Will Deacon, Mathieu Poirier, Kemeng Shi, Naveen N. Rao,
	Ian Rogers, Al Grant, James Clark, Wei Li, André Przywara,
	linux-kernel, linux-arm-kernel

On Wed, Oct 28, 2020 at 02:38:10PM +0800, Leo Yan wrote:
> This patches adds the AUX callbacks in session structure, so support
> AUX trace for "perf c2c" tool.
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/builtin-c2c.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index 4d1a08e38233..24f4af997aab 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
> @@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
>  		.exit		= perf_event__process_exit,
>  		.fork		= perf_event__process_fork,
>  		.lost		= perf_event__process_lost,
> +		.attr		= perf_event__process_attr,
> +		.auxtrace_info  = perf_event__process_auxtrace_info,
> +		.auxtrace       = perf_event__process_auxtrace,
> +		.auxtrace_error = perf_event__process_auxtrace_error,

so this will process aux data, but don't you have to
say which events you want to synthesize?

like in script/report via --itrace option?

aybe arm differs from x86 in this, and it's happening
in the background.. I have no idea ;-)

jirka

>  		.ordered_events	= true,
>  		.ordering_requires_timestamps = true,
>  	},
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 6/9] perf c2c: Support AUX trace
@ 2020-10-31 20:21     ` Jiri Olsa
  0 siblings, 0 replies; 38+ messages in thread
From: Jiri Olsa @ 2020-10-31 20:21 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Ian Rogers, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Wei Li, John Garry, linux-kernel,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Will Deacon, linux-arm-kernel

On Wed, Oct 28, 2020 at 02:38:10PM +0800, Leo Yan wrote:
> This patches adds the AUX callbacks in session structure, so support
> AUX trace for "perf c2c" tool.
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/builtin-c2c.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index 4d1a08e38233..24f4af997aab 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
> @@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
>  		.exit		= perf_event__process_exit,
>  		.fork		= perf_event__process_fork,
>  		.lost		= perf_event__process_lost,
> +		.attr		= perf_event__process_attr,
> +		.auxtrace_info  = perf_event__process_auxtrace_info,
> +		.auxtrace       = perf_event__process_auxtrace,
> +		.auxtrace_error = perf_event__process_auxtrace_error,

so this will process aux data, but don't you have to
say which events you want to synthesize?

like in script/report via --itrace option?

aybe arm differs from x86 in this, and it's happening
in the background.. I have no idea ;-)

jirka

>  		.ordered_events	= true,
>  		.ordering_requires_timestamps = true,
>  	},
> -- 
> 2.17.1
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
  2020-10-28  6:38   ` Leo Yan
@ 2020-10-31 20:23     ` Jiri Olsa
  -1 siblings, 0 replies; 38+ messages in thread
From: Jiri Olsa @ 2020-10-31 20:23 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, John Garry,
	Will Deacon, Mathieu Poirier, Kemeng Shi, Naveen N. Rao,
	Ian Rogers, Al Grant, James Clark, Wei Li, André Przywara,
	linux-kernel, linux-arm-kernel

On Wed, Oct 28, 2020 at 02:38:07PM +0800, Leo Yan wrote:

SNIP

>  		struct stat st;
>  
> +		/*
> +		 * If the event entry isn't valid, skip initialization
> +		 * and "e->supported" will keep false.
> +		 */
> +		if (!e->tag)
> +			continue;
> +
>  		scnprintf(path, PATH_MAX, "%s/devices/%s",
>  			  mnt, e->sysfs_name);
>  
> @@ -123,7 +134,7 @@ void perf_mem_events__list(void)
>  		struct perf_mem_event *e = perf_mem_events__ptr(j);
>  
>  		fprintf(stderr, "%-13s%-*s%s\n",
> -			e->tag,
> +			e->tag ? e->tag : "",

nit, could be:          e->tag ?: "",

jirka

>  			verbose > 0 ? 25 : 0,
>  			verbose > 0 ? perf_mem_events__name(j) : "",
>  			e->supported ? ": available" : "");
> diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
> index 726a9c8103e4..5ef178278909 100644
> --- a/tools/perf/util/mem-events.h
> +++ b/tools/perf/util/mem-events.h
> @@ -28,6 +28,7 @@ struct mem_info {
>  enum {
>  	PERF_MEM_EVENTS__LOAD,
>  	PERF_MEM_EVENTS__STORE,
> +	PERF_MEM_EVENTS__LOAD_STORE,
>  	PERF_MEM_EVENTS__MAX,
>  };
>  
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
@ 2020-10-31 20:23     ` Jiri Olsa
  0 siblings, 0 replies; 38+ messages in thread
From: Jiri Olsa @ 2020-10-31 20:23 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Ian Rogers, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Wei Li, John Garry, linux-kernel,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Will Deacon, linux-arm-kernel

On Wed, Oct 28, 2020 at 02:38:07PM +0800, Leo Yan wrote:

SNIP

>  		struct stat st;
>  
> +		/*
> +		 * If the event entry isn't valid, skip initialization
> +		 * and "e->supported" will keep false.
> +		 */
> +		if (!e->tag)
> +			continue;
> +
>  		scnprintf(path, PATH_MAX, "%s/devices/%s",
>  			  mnt, e->sysfs_name);
>  
> @@ -123,7 +134,7 @@ void perf_mem_events__list(void)
>  		struct perf_mem_event *e = perf_mem_events__ptr(j);
>  
>  		fprintf(stderr, "%-13s%-*s%s\n",
> -			e->tag,
> +			e->tag ? e->tag : "",

nit, could be:          e->tag ?: "",

jirka

>  			verbose > 0 ? 25 : 0,
>  			verbose > 0 ? perf_mem_events__name(j) : "",
>  			e->supported ? ": available" : "");
> diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
> index 726a9c8103e4..5ef178278909 100644
> --- a/tools/perf/util/mem-events.h
> +++ b/tools/perf/util/mem-events.h
> @@ -28,6 +28,7 @@ struct mem_info {
>  enum {
>  	PERF_MEM_EVENTS__LOAD,
>  	PERF_MEM_EVENTS__STORE,
> +	PERF_MEM_EVENTS__LOAD_STORE,
>  	PERF_MEM_EVENTS__MAX,
>  };
>  
> -- 
> 2.17.1
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
  2020-10-31 20:23     ` Jiri Olsa
@ 2020-11-02  9:38       ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-11-02  9:38 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, John Garry,
	Will Deacon, Mathieu Poirier, Kemeng Shi, Naveen N. Rao,
	Ian Rogers, Al Grant, James Clark, Wei Li, André Przywara,
	linux-kernel, linux-arm-kernel

On Sat, Oct 31, 2020 at 09:23:07PM +0100, Jiri Olsa wrote:
> On Wed, Oct 28, 2020 at 02:38:07PM +0800, Leo Yan wrote:
> 
> SNIP
> 
> >  		struct stat st;
> >  
> > +		/*
> > +		 * If the event entry isn't valid, skip initialization
> > +		 * and "e->supported" will keep false.
> > +		 */
> > +		if (!e->tag)
> > +			continue;
> > +
> >  		scnprintf(path, PATH_MAX, "%s/devices/%s",
> >  			  mnt, e->sysfs_name);
> >  
> > @@ -123,7 +134,7 @@ void perf_mem_events__list(void)
> >  		struct perf_mem_event *e = perf_mem_events__ptr(j);
> >  
> >  		fprintf(stderr, "%-13s%-*s%s\n",
> > -			e->tag,
> > +			e->tag ? e->tag : "",
> 
> nit, could be:          e->tag ?: "",

Will do.

Thanks,
Leo

> >  			verbose > 0 ? 25 : 0,
> >  			verbose > 0 ? perf_mem_events__name(j) : "",
> >  			e->supported ? ": available" : "");
> > diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
> > index 726a9c8103e4..5ef178278909 100644
> > --- a/tools/perf/util/mem-events.h
> > +++ b/tools/perf/util/mem-events.h
> > @@ -28,6 +28,7 @@ struct mem_info {
> >  enum {
> >  	PERF_MEM_EVENTS__LOAD,
> >  	PERF_MEM_EVENTS__STORE,
> > +	PERF_MEM_EVENTS__LOAD_STORE,
> >  	PERF_MEM_EVENTS__MAX,
> >  };
> >  
> > -- 
> > 2.17.1
> > 
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE
@ 2020-11-02  9:38       ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-11-02  9:38 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Mark Rutland, Ian Rogers, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Wei Li, John Garry, linux-kernel,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Will Deacon, linux-arm-kernel

On Sat, Oct 31, 2020 at 09:23:07PM +0100, Jiri Olsa wrote:
> On Wed, Oct 28, 2020 at 02:38:07PM +0800, Leo Yan wrote:
> 
> SNIP
> 
> >  		struct stat st;
> >  
> > +		/*
> > +		 * If the event entry isn't valid, skip initialization
> > +		 * and "e->supported" will keep false.
> > +		 */
> > +		if (!e->tag)
> > +			continue;
> > +
> >  		scnprintf(path, PATH_MAX, "%s/devices/%s",
> >  			  mnt, e->sysfs_name);
> >  
> > @@ -123,7 +134,7 @@ void perf_mem_events__list(void)
> >  		struct perf_mem_event *e = perf_mem_events__ptr(j);
> >  
> >  		fprintf(stderr, "%-13s%-*s%s\n",
> > -			e->tag,
> > +			e->tag ? e->tag : "",
> 
> nit, could be:          e->tag ?: "",

Will do.

Thanks,
Leo

> >  			verbose > 0 ? 25 : 0,
> >  			verbose > 0 ? perf_mem_events__name(j) : "",
> >  			e->supported ? ": available" : "");
> > diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
> > index 726a9c8103e4..5ef178278909 100644
> > --- a/tools/perf/util/mem-events.h
> > +++ b/tools/perf/util/mem-events.h
> > @@ -28,6 +28,7 @@ struct mem_info {
> >  enum {
> >  	PERF_MEM_EVENTS__LOAD,
> >  	PERF_MEM_EVENTS__STORE,
> > +	PERF_MEM_EVENTS__LOAD_STORE,
> >  	PERF_MEM_EVENTS__MAX,
> >  };
> >  
> > -- 
> > 2.17.1
> > 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 6/9] perf c2c: Support AUX trace
  2020-10-31 20:21     ` Jiri Olsa
@ 2020-11-02 10:08       ` Leo Yan
  -1 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-11-02 10:08 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, John Garry,
	Will Deacon, Mathieu Poirier, Kemeng Shi, Naveen N. Rao,
	Ian Rogers, Al Grant, James Clark, Wei Li, André Przywara,
	linux-kernel, linux-arm-kernel

Hi Jiri,

On Sat, Oct 31, 2020 at 09:21:03PM +0100, Jiri Olsa wrote:
> On Wed, Oct 28, 2020 at 02:38:10PM +0800, Leo Yan wrote:
> > This patches adds the AUX callbacks in session structure, so support
> > AUX trace for "perf c2c" tool.
> > 
> > Signed-off-by: Leo Yan <leo.yan@linaro.org>
> > ---
> >  tools/perf/builtin-c2c.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > index 4d1a08e38233..24f4af997aab 100644
> > --- a/tools/perf/builtin-c2c.c
> > +++ b/tools/perf/builtin-c2c.c
> > @@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
> >  		.exit		= perf_event__process_exit,
> >  		.fork		= perf_event__process_fork,
> >  		.lost		= perf_event__process_lost,
> > +		.attr		= perf_event__process_attr,
> > +		.auxtrace_info  = perf_event__process_auxtrace_info,
> > +		.auxtrace       = perf_event__process_auxtrace,
> > +		.auxtrace_error = perf_event__process_auxtrace_error,
> 
> so this will process aux data, but don't you have to
> say which events you want to synthesize?
> 
> like in script/report via --itrace option?

Indeed, we need to assign "session->itrace_synth_opts", otherwise, the
tool cannot output synthesized samples.

I tried to keep this patch set as small as possible, for easier
reviewing.

Comparing to the previous patch set, I moved out the patch "perf
auxtrace: Add option '-M' for memory events" [1] from this patch set,
at the end my purpose is to introduce the itrace option '-M' to
synthesize memory event; and "perf c2c" tool can use memory event
for output result.  Thus "perf c2c" needs to add itrace_synth_opts:

  struct itrace_synth_opts itrace_synth_opts = {
          .set = true,
          .mem = true,            /* Memory samples */
          .default_no_sample = true,
  };

> aybe arm differs from x86 in this, and it's happening
> in the background.. I have no idea ;-)

There should have no any difference between archs for 'itrace'
behaviour.

Since I moved the patch "perf auxtrace: Add option '-M' for memory
events" out from this patch set, thus I also left out the code for
adding itrace_synth_opts.  This introduced confusion for reviewing the
change (sorry!), I will add back the patch "perf auxtrace: Add option
'-M' for memory events" and add itrace_synth_opts for perf mem/c2c in
next patch set.

Thanks,
Leo

[1] https://lore.kernel.org/patchwork/patch/1298072/

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 6/9] perf c2c: Support AUX trace
@ 2020-11-02 10:08       ` Leo Yan
  0 siblings, 0 replies; 38+ messages in thread
From: Leo Yan @ 2020-11-02 10:08 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Mark Rutland, Ian Rogers, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Wei Li, John Garry, linux-kernel,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Will Deacon, linux-arm-kernel

Hi Jiri,

On Sat, Oct 31, 2020 at 09:21:03PM +0100, Jiri Olsa wrote:
> On Wed, Oct 28, 2020 at 02:38:10PM +0800, Leo Yan wrote:
> > This patches adds the AUX callbacks in session structure, so support
> > AUX trace for "perf c2c" tool.
> > 
> > Signed-off-by: Leo Yan <leo.yan@linaro.org>
> > ---
> >  tools/perf/builtin-c2c.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > index 4d1a08e38233..24f4af997aab 100644
> > --- a/tools/perf/builtin-c2c.c
> > +++ b/tools/perf/builtin-c2c.c
> > @@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
> >  		.exit		= perf_event__process_exit,
> >  		.fork		= perf_event__process_fork,
> >  		.lost		= perf_event__process_lost,
> > +		.attr		= perf_event__process_attr,
> > +		.auxtrace_info  = perf_event__process_auxtrace_info,
> > +		.auxtrace       = perf_event__process_auxtrace,
> > +		.auxtrace_error = perf_event__process_auxtrace_error,
> 
> so this will process aux data, but don't you have to
> say which events you want to synthesize?
> 
> like in script/report via --itrace option?

Indeed, we need to assign "session->itrace_synth_opts", otherwise, the
tool cannot output synthesized samples.

I tried to keep this patch set as small as possible, for easier
reviewing.

Comparing to the previous patch set, I moved out the patch "perf
auxtrace: Add option '-M' for memory events" [1] from this patch set,
at the end my purpose is to introduce the itrace option '-M' to
synthesize memory event; and "perf c2c" tool can use memory event
for output result.  Thus "perf c2c" needs to add itrace_synth_opts:

  struct itrace_synth_opts itrace_synth_opts = {
          .set = true,
          .mem = true,            /* Memory samples */
          .default_no_sample = true,
  };

> aybe arm differs from x86 in this, and it's happening
> in the background.. I have no idea ;-)

There should have no any difference between archs for 'itrace'
behaviour.

Since I moved the patch "perf auxtrace: Add option '-M' for memory
events" out from this patch set, thus I also left out the code for
adding itrace_synth_opts.  This introduced confusion for reviewing the
change (sorry!), I will add back the patch "perf auxtrace: Add option
'-M' for memory events" and add itrace_synth_opts for perf mem/c2c in
next patch set.

Thanks,
Leo

[1] https://lore.kernel.org/patchwork/patch/1298072/

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 6/9] perf c2c: Support AUX trace
  2020-11-02 10:08       ` Leo Yan
@ 2020-11-02 16:35         ` Jiri Olsa
  -1 siblings, 0 replies; 38+ messages in thread
From: Jiri Olsa @ 2020-11-02 16:35 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, John Garry,
	Will Deacon, Mathieu Poirier, Kemeng Shi, Naveen N. Rao,
	Ian Rogers, Al Grant, James Clark, Wei Li, André Przywara,
	linux-kernel, linux-arm-kernel

On Mon, Nov 02, 2020 at 06:08:23PM +0800, Leo Yan wrote:
> Hi Jiri,
> 
> On Sat, Oct 31, 2020 at 09:21:03PM +0100, Jiri Olsa wrote:
> > On Wed, Oct 28, 2020 at 02:38:10PM +0800, Leo Yan wrote:
> > > This patches adds the AUX callbacks in session structure, so support
> > > AUX trace for "perf c2c" tool.
> > > 
> > > Signed-off-by: Leo Yan <leo.yan@linaro.org>
> > > ---
> > >  tools/perf/builtin-c2c.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > > 
> > > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > > index 4d1a08e38233..24f4af997aab 100644
> > > --- a/tools/perf/builtin-c2c.c
> > > +++ b/tools/perf/builtin-c2c.c
> > > @@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
> > >  		.exit		= perf_event__process_exit,
> > >  		.fork		= perf_event__process_fork,
> > >  		.lost		= perf_event__process_lost,
> > > +		.attr		= perf_event__process_attr,
> > > +		.auxtrace_info  = perf_event__process_auxtrace_info,
> > > +		.auxtrace       = perf_event__process_auxtrace,
> > > +		.auxtrace_error = perf_event__process_auxtrace_error,
> > 
> > so this will process aux data, but don't you have to
> > say which events you want to synthesize?
> > 
> > like in script/report via --itrace option?
> 
> Indeed, we need to assign "session->itrace_synth_opts", otherwise, the
> tool cannot output synthesized samples.
> 
> I tried to keep this patch set as small as possible, for easier
> reviewing.
> 
> Comparing to the previous patch set, I moved out the patch "perf
> auxtrace: Add option '-M' for memory events" [1] from this patch set,
> at the end my purpose is to introduce the itrace option '-M' to
> synthesize memory event; and "perf c2c" tool can use memory event
> for output result.  Thus "perf c2c" needs to add itrace_synth_opts:
> 
>   struct itrace_synth_opts itrace_synth_opts = {
>           .set = true,
>           .mem = true,            /* Memory samples */
>           .default_no_sample = true,
>   };
> 
> > aybe arm differs from x86 in this, and it's happening
> > in the background.. I have no idea ;-)
> 
> There should have no any difference between archs for 'itrace'
> behaviour.
> 
> Since I moved the patch "perf auxtrace: Add option '-M' for memory
> events" out from this patch set, thus I also left out the code for
> adding itrace_synth_opts.  This introduced confusion for reviewing the
> change (sorry!), I will add back the patch "perf auxtrace: Add option
> '-M' for memory events" and add itrace_synth_opts for perf mem/c2c in
> next patch set.

ok either way works for me, I just wanted to understand ;-)

thanks,
jirka


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v3 6/9] perf c2c: Support AUX trace
@ 2020-11-02 16:35         ` Jiri Olsa
  0 siblings, 0 replies; 38+ messages in thread
From: Jiri Olsa @ 2020-11-02 16:35 UTC (permalink / raw)
  To: Leo Yan
  Cc: Mark Rutland, Ian Rogers, Al Grant, Mathieu Poirier, Kemeng Shi,
	Peter Zijlstra, Wei Li, John Garry, linux-kernel,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Ingo Molnar,
	James Clark, André Przywara, Namhyung Kim, Naveen N. Rao,
	Will Deacon, linux-arm-kernel

On Mon, Nov 02, 2020 at 06:08:23PM +0800, Leo Yan wrote:
> Hi Jiri,
> 
> On Sat, Oct 31, 2020 at 09:21:03PM +0100, Jiri Olsa wrote:
> > On Wed, Oct 28, 2020 at 02:38:10PM +0800, Leo Yan wrote:
> > > This patches adds the AUX callbacks in session structure, so support
> > > AUX trace for "perf c2c" tool.
> > > 
> > > Signed-off-by: Leo Yan <leo.yan@linaro.org>
> > > ---
> > >  tools/perf/builtin-c2c.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > > 
> > > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > > index 4d1a08e38233..24f4af997aab 100644
> > > --- a/tools/perf/builtin-c2c.c
> > > +++ b/tools/perf/builtin-c2c.c
> > > @@ -369,6 +369,10 @@ static struct perf_c2c c2c = {
> > >  		.exit		= perf_event__process_exit,
> > >  		.fork		= perf_event__process_fork,
> > >  		.lost		= perf_event__process_lost,
> > > +		.attr		= perf_event__process_attr,
> > > +		.auxtrace_info  = perf_event__process_auxtrace_info,
> > > +		.auxtrace       = perf_event__process_auxtrace,
> > > +		.auxtrace_error = perf_event__process_auxtrace_error,
> > 
> > so this will process aux data, but don't you have to
> > say which events you want to synthesize?
> > 
> > like in script/report via --itrace option?
> 
> Indeed, we need to assign "session->itrace_synth_opts", otherwise, the
> tool cannot output synthesized samples.
> 
> I tried to keep this patch set as small as possible, for easier
> reviewing.
> 
> Comparing to the previous patch set, I moved out the patch "perf
> auxtrace: Add option '-M' for memory events" [1] from this patch set,
> at the end my purpose is to introduce the itrace option '-M' to
> synthesize memory event; and "perf c2c" tool can use memory event
> for output result.  Thus "perf c2c" needs to add itrace_synth_opts:
> 
>   struct itrace_synth_opts itrace_synth_opts = {
>           .set = true,
>           .mem = true,            /* Memory samples */
>           .default_no_sample = true,
>   };
> 
> > aybe arm differs from x86 in this, and it's happening
> > in the background.. I have no idea ;-)
> 
> There should have no any difference between archs for 'itrace'
> behaviour.
> 
> Since I moved the patch "perf auxtrace: Add option '-M' for memory
> events" out from this patch set, thus I also left out the code for
> adding itrace_synth_opts.  This introduced confusion for reviewing the
> change (sorry!), I will add back the patch "perf auxtrace: Add option
> '-M' for memory events" and add itrace_synth_opts for perf mem/c2c in
> next patch set.

ok either way works for me, I just wanted to understand ;-)

thanks,
jirka


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2020-11-02 16:37 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28  6:38 [PATCH v3 0/9] perf mem/c2c: Support AUX trace Leo Yan
2020-10-28  6:38 ` Leo Yan
2020-10-28  6:38 ` [PATCH v3 1/9] perf mem: Search event name with more flexible path Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-28  6:38 ` [PATCH v3 2/9] perf mem: Introduce weak function perf_mem_events__ptr() Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-28  6:38 ` [PATCH v3 3/9] perf mem: Support new memory event PERF_MEM_EVENTS__LOAD_STORE Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-31 20:23   ` Jiri Olsa
2020-10-31 20:23     ` Jiri Olsa
2020-11-02  9:38     ` Leo Yan
2020-11-02  9:38       ` Leo Yan
2020-10-28  6:38 ` [PATCH v3 4/9] perf mem: Only initialize memory event for recording Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-30  1:04   ` Ian Rogers
2020-10-30  1:04     ` Ian Rogers
2020-10-28  6:38 ` [PATCH v3 5/9] perf mem: Support AUX trace Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-28  6:38 ` [PATCH v3 6/9] perf c2c: " Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-31 20:21   ` Jiri Olsa
2020-10-31 20:21     ` Jiri Olsa
2020-11-02 10:08     ` Leo Yan
2020-11-02 10:08       ` Leo Yan
2020-11-02 16:35       ` Jiri Olsa
2020-11-02 16:35         ` Jiri Olsa
2020-10-28  6:38 ` [PATCH v3 7/9] perf mem: Support Arm SPE events Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-28  6:38 ` [PATCH v3 8/9] perf mem: Return NULL for event 'ldst' on PowerPC Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-28  9:35   ` Naveen N. Rao
2020-10-28  9:35     ` Naveen N. Rao
2020-10-28  6:38 ` [PATCH v3 9/9] perf mem: Document event type 'ldst' Leo Yan
2020-10-28  6:38   ` Leo Yan
2020-10-30  1:10   ` Ian Rogers
2020-10-30  1:10     ` Ian Rogers
2020-10-30  1:49     ` Leo Yan
2020-10-30  1:49       ` Leo Yan

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.