linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs
@ 2024-06-23 13:34 Leo Yan
  2024-06-23 13:34 ` [PATCH v1 1/2] perf arm-spe: " Leo Yan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Leo Yan @ 2024-06-23 13:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, James Clark, Suzuki K Poulose,
	Mike Leach, John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Ian Rogers, Mark Rutland, Alexander Shishkin,
	Adrian Hunter, Liang, Kan, Kajol Jain, coresight,
	linux-arm-kernel, linux-perf-users, linux-kernel
  Cc: Leo Yan

This patch series is to enable multiple Arm SPE PMUs.

The patch 01 is to enable multiple Arm SPE PMUs. The second patch is to
print out warning if not all CPUs support memory events, this can give
users a hint that the memory profiling is absent on some CPUs.


Leo Yan (2):
  perf arm-spe: Support multiple Arm SPE PMUs
  perf mem: Warn if memory events are not supported on all CPUs

 tools/perf/arch/arm/util/pmu.c |  2 +-
 tools/perf/util/mem-events.c   | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

-- 
2.34.1


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

* [PATCH v1 1/2] perf arm-spe: Support multiple Arm SPE PMUs
  2024-06-23 13:34 [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs Leo Yan
@ 2024-06-23 13:34 ` Leo Yan
  2024-06-24 16:16   ` Ian Rogers
  2024-06-23 13:34 ` [PATCH v1 2/2] perf mem: Warn if memory events are not supported on all CPUs Leo Yan
  2024-06-24  9:55 ` [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs James Clark
  2 siblings, 1 reply; 7+ messages in thread
From: Leo Yan @ 2024-06-23 13:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, James Clark, Suzuki K Poulose,
	Mike Leach, John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Ian Rogers, Mark Rutland, Alexander Shishkin,
	Adrian Hunter, Liang, Kan, Kajol Jain, coresight,
	linux-arm-kernel, linux-perf-users, linux-kernel
  Cc: Leo Yan

A platform can have more than one Arm SPE PMU. For example, a system
with multiple clusters may have each cluster enabled with its own Arm
SPE instance. In such case, the PMU devices will be named 'arm_spe_0',
'arm_spe_1', and so on.

Currently, the tool only supports 'arm_spe_0'. This commit extends
support to multiple Arm SPE PMUs by detecting the substring 'arm_spe'.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/arch/arm/util/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c
index 8b7cb68ba1a8..29cfa1e427ed 100644
--- a/tools/perf/arch/arm/util/pmu.c
+++ b/tools/perf/arch/arm/util/pmu.c
@@ -27,7 +27,7 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
 		pmu->selectable = true;
 		pmu->is_uncore = false;
 		pmu->perf_event_attr_init_default = arm_spe_pmu_default_config;
-		if (!strcmp(pmu->name, "arm_spe_0"))
+		if (strstr(pmu->name, "arm_spe"))
 			pmu->mem_events = perf_mem_events_arm;
 	} else if (strstarts(pmu->name, HISI_PTT_PMU_NAME)) {
 		pmu->selectable = true;
-- 
2.34.1


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

* [PATCH v1 2/2] perf mem: Warn if memory events are not supported on all CPUs
  2024-06-23 13:34 [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs Leo Yan
  2024-06-23 13:34 ` [PATCH v1 1/2] perf arm-spe: " Leo Yan
@ 2024-06-23 13:34 ` Leo Yan
  2024-06-24  9:55 ` [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs James Clark
  2 siblings, 0 replies; 7+ messages in thread
From: Leo Yan @ 2024-06-23 13:34 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, James Clark, Suzuki K Poulose,
	Mike Leach, John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Ian Rogers, Mark Rutland, Alexander Shishkin,
	Adrian Hunter, Liang, Kan, Kajol Jain, coresight,
	linux-arm-kernel, linux-perf-users, linux-kernel
  Cc: Leo Yan

It is possible that memory events are not supported on all CPUs.

Prints a warning by dumping the enabled CPU maps in this case.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/util/mem-events.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 6dda47bb774f..8aff2ca8bbd5 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -8,6 +8,7 @@
 #include <unistd.h>
 #include <api/fs/fs.h>
 #include <linux/kernel.h>
+#include "cpumap.h"
 #include "map_symbol.h"
 #include "mem-events.h"
 #include "mem-info.h"
@@ -242,6 +243,7 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr)
 	int i = *argv_nr;
 	const char *s;
 	char *copy;
+	struct perf_cpu_map *cpu_map = NULL;
 
 	while ((pmu = perf_pmus__scan_mem(pmu)) != NULL) {
 		for (int j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
@@ -266,7 +268,19 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr)
 
 			rec_argv[i++] = "-e";
 			rec_argv[i++] = copy;
+
+			cpu_map = perf_cpu_map__merge(cpu_map, pmu->cpus);
+		}
+	}
+
+	if (cpu_map) {
+		if (!perf_cpu_map__equal(cpu_map, cpu_map__online())) {
+			char buf[200];
+
+			cpu_map__snprint(cpu_map, buf, sizeof(buf));
+			pr_warning("Memory events are enabled on a subset of CPUs: %s\n", buf);
 		}
+		perf_cpu_map__put(cpu_map);
 	}
 
 	*argv_nr = i;
-- 
2.34.1


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

* Re: [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs
  2024-06-23 13:34 [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs Leo Yan
  2024-06-23 13:34 ` [PATCH v1 1/2] perf arm-spe: " Leo Yan
  2024-06-23 13:34 ` [PATCH v1 2/2] perf mem: Warn if memory events are not supported on all CPUs Leo Yan
@ 2024-06-24  9:55 ` James Clark
  2 siblings, 0 replies; 7+ messages in thread
From: James Clark @ 2024-06-24  9:55 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Suzuki K Poulose, Mike Leach,
	John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Ian Rogers, Mark Rutland, Alexander Shishkin,
	Adrian Hunter, Liang, Kan, Kajol Jain, coresight,
	linux-arm-kernel, linux-perf-users, linux-kernel



On 23/06/2024 14:34, Leo Yan wrote:
> This patch series is to enable multiple Arm SPE PMUs.
> 
> The patch 01 is to enable multiple Arm SPE PMUs. The second patch is to
> print out warning if not all CPUs support memory events, this can give
> users a hint that the memory profiling is absent on some CPUs.
> 
> 
> Leo Yan (2):
>   perf arm-spe: Support multiple Arm SPE PMUs
>   perf mem: Warn if memory events are not supported on all CPUs
> 
>  tools/perf/arch/arm/util/pmu.c |  2 +-
>  tools/perf/util/mem-events.c   | 14 ++++++++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 

Reviewed-by: James Clark <james.clark@arm.com>

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

* Re: [PATCH v1 1/2] perf arm-spe: Support multiple Arm SPE PMUs
  2024-06-23 13:34 ` [PATCH v1 1/2] perf arm-spe: " Leo Yan
@ 2024-06-24 16:16   ` Ian Rogers
  2024-06-25 16:49     ` Leo Yan
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Rogers @ 2024-06-24 16:16 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, James Clark, Suzuki K Poulose,
	Mike Leach, John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Adrian Hunter,
	Liang, Kan, Kajol Jain, coresight, linux-arm-kernel,
	linux-perf-users, linux-kernel

On Sun, Jun 23, 2024 at 6:34 AM Leo Yan <leo.yan@arm.com> wrote:
>
> A platform can have more than one Arm SPE PMU. For example, a system
> with multiple clusters may have each cluster enabled with its own Arm
> SPE instance. In such case, the PMU devices will be named 'arm_spe_0',
> 'arm_spe_1', and so on.
>
> Currently, the tool only supports 'arm_spe_0'. This commit extends
> support to multiple Arm SPE PMUs by detecting the substring 'arm_spe'.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>  tools/perf/arch/arm/util/pmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c
> index 8b7cb68ba1a8..29cfa1e427ed 100644
> --- a/tools/perf/arch/arm/util/pmu.c
> +++ b/tools/perf/arch/arm/util/pmu.c
> @@ -27,7 +27,7 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
>                 pmu->selectable = true;
>                 pmu->is_uncore = false;
>                 pmu->perf_event_attr_init_default = arm_spe_pmu_default_config;
> -               if (!strcmp(pmu->name, "arm_spe_0"))
> +               if (strstr(pmu->name, "arm_spe"))

Why not use strstarts?

Thanks,
Ian


>                         pmu->mem_events = perf_mem_events_arm;
>         } else if (strstarts(pmu->name, HISI_PTT_PMU_NAME)) {
>                 pmu->selectable = true;
> --
> 2.34.1
>

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

* Re: [PATCH v1 1/2] perf arm-spe: Support multiple Arm SPE PMUs
  2024-06-24 16:16   ` Ian Rogers
@ 2024-06-25 16:49     ` Leo Yan
  2024-06-27 22:37       ` Namhyung Kim
  0 siblings, 1 reply; 7+ messages in thread
From: Leo Yan @ 2024-06-25 16:49 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, James Clark, Suzuki K Poulose,
	Mike Leach, John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Adrian Hunter,
	Liang, Kan, Kajol Jain, coresight, linux-arm-kernel,
	linux-perf-users, linux-kernel

Hi Ian,

On 6/24/24 17:16, Ian Rogers wrote:
> On Sun, Jun 23, 2024 at 6:34 AM Leo Yan <leo.yan@arm.com> wrote:
>>
>> A platform can have more than one Arm SPE PMU. For example, a system
>> with multiple clusters may have each cluster enabled with its own Arm
>> SPE instance. In such case, the PMU devices will be named 'arm_spe_0',
>> 'arm_spe_1', and so on.
>>
>> Currently, the tool only supports 'arm_spe_0'. This commit extends
>> support to multiple Arm SPE PMUs by detecting the substring 'arm_spe'.
>>
>> Signed-off-by: Leo Yan <leo.yan@arm.com>
>> ---
>>   tools/perf/arch/arm/util/pmu.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c
>> index 8b7cb68ba1a8..29cfa1e427ed 100644
>> --- a/tools/perf/arch/arm/util/pmu.c
>> +++ b/tools/perf/arch/arm/util/pmu.c
>> @@ -27,7 +27,7 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
>>                  pmu->selectable = true;
>>                  pmu->is_uncore = false;
>>                  pmu->perf_event_attr_init_default = arm_spe_pmu_default_config;
>> -               if (!strcmp(pmu->name, "arm_spe_0"))
>> +               if (strstr(pmu->name, "arm_spe"))
> 
> Why not use strstarts?

Indeed, strstarts() is better, will spin for this.

Thank for suggestion.
Leo

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

* Re: [PATCH v1 1/2] perf arm-spe: Support multiple Arm SPE PMUs
  2024-06-25 16:49     ` Leo Yan
@ 2024-06-27 22:37       ` Namhyung Kim
  0 siblings, 0 replies; 7+ messages in thread
From: Namhyung Kim @ 2024-06-27 22:37 UTC (permalink / raw)
  To: Leo Yan
  Cc: Ian Rogers, Arnaldo Carvalho de Melo, James Clark,
	Suzuki K Poulose, Mike Leach, John Garry, Will Deacon,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Adrian Hunter, Liang, Kan, Kajol Jain, coresight,
	linux-arm-kernel, linux-perf-users, linux-kernel

Hello Leo,

On Tue, Jun 25, 2024 at 05:49:16PM +0100, Leo Yan wrote:
> Hi Ian,
> 
> On 6/24/24 17:16, Ian Rogers wrote:
> > On Sun, Jun 23, 2024 at 6:34 AM Leo Yan <leo.yan@arm.com> wrote:
> > > 
> > > A platform can have more than one Arm SPE PMU. For example, a system
> > > with multiple clusters may have each cluster enabled with its own Arm
> > > SPE instance. In such case, the PMU devices will be named 'arm_spe_0',
> > > 'arm_spe_1', and so on.
> > > 
> > > Currently, the tool only supports 'arm_spe_0'. This commit extends
> > > support to multiple Arm SPE PMUs by detecting the substring 'arm_spe'.
> > > 
> > > Signed-off-by: Leo Yan <leo.yan@arm.com>
> > > ---
> > >   tools/perf/arch/arm/util/pmu.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c
> > > index 8b7cb68ba1a8..29cfa1e427ed 100644
> > > --- a/tools/perf/arch/arm/util/pmu.c
> > > +++ b/tools/perf/arch/arm/util/pmu.c
> > > @@ -27,7 +27,7 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
> > >                  pmu->selectable = true;
> > >                  pmu->is_uncore = false;
> > >                  pmu->perf_event_attr_init_default = arm_spe_pmu_default_config;
> > > -               if (!strcmp(pmu->name, "arm_spe_0"))
> > > +               if (strstr(pmu->name, "arm_spe"))
> > 
> > Why not use strstarts?
> 
> Indeed, strstarts() is better, will spin for this.
> 
> Thank for suggestion.

Probably we need to check the last underscore too to prevent potential
name clashes..

Thanks,
Namhyung


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

end of thread, other threads:[~2024-06-27 22:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-23 13:34 [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs Leo Yan
2024-06-23 13:34 ` [PATCH v1 1/2] perf arm-spe: " Leo Yan
2024-06-24 16:16   ` Ian Rogers
2024-06-25 16:49     ` Leo Yan
2024-06-27 22:37       ` Namhyung Kim
2024-06-23 13:34 ` [PATCH v1 2/2] perf mem: Warn if memory events are not supported on all CPUs Leo Yan
2024-06-24  9:55 ` [PATCH v1 0/2] perf mem: Support multiple Arm SPE PMUs James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).