* [PATCH v4 0/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne
@ 2024-11-08 1:09 Ilkka Koskinen
2024-11-08 1:09 ` [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Ilkka Koskinen
2024-11-08 1:09 ` [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
0 siblings, 2 replies; 7+ messages in thread
From: Ilkka Koskinen @ 2024-11-08 1:09 UTC (permalink / raw)
To: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, Graham Woodward
Cc: Ilkka Koskinen, linux-arm-kernel, linux-perf-users, linux-kernel
v1:
* https://lore.kernel.org/all/20241024233035.7979-1-ilkka@os.amperecomputing.com/
v2:
* Doesn't use read_cpuid_implementor() anymore as that was broken and
unnecessary.
* Convert AmpereOne source field to matching common source fields to
avoid duplicating the code.
* Rebased on top of perf-tools-next/perf-tools-next (ba993e5ada1d)
* https://lore.kernel.org/all/20241031213533.11148-1-ilkka@os.amperecomputing.com/
v3:
* Changed source mapping to simple switch statement
* Dropped is_xyz() stuff
* Added table to map midr to data source decoding function
* https://lore.kernel.org/all/20241106193740.6159-1-ilkka@os.amperecomputing.com/
v4:
* Split midr/decoding function table
* Made AmpereOne DS decoding function to ignore unknown sources
Ilkka Koskinen (2):
perf arm-spe: Prepare for adding data source packet implementations
for other cores
perf arm-spe: Add support for SPE Data Source packet on AmpereOne
.../util/arm-spe-decoder/arm-spe-decoder.h | 9 ++
tools/perf/util/arm-spe.c | 86 ++++++++++++++++---
2 files changed, 83 insertions(+), 12 deletions(-)
--
2.47.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores
2024-11-08 1:09 [PATCH v4 0/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
@ 2024-11-08 1:09 ` Ilkka Koskinen
2024-11-08 14:50 ` Leo Yan
2024-11-08 1:09 ` [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
1 sibling, 1 reply; 7+ messages in thread
From: Ilkka Koskinen @ 2024-11-08 1:09 UTC (permalink / raw)
To: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, Graham Woodward
Cc: Ilkka Koskinen, linux-arm-kernel, linux-perf-users, linux-kernel
Split Data Source Packet handling to prepare adding support for
other implementations.
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
---
tools/perf/util/arm-spe.c | 42 ++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index dbf13f47879c..dfb0c07cb7fe 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -103,6 +103,18 @@ struct arm_spe_queue {
u32 flags;
};
+struct data_source_handle {
+ const struct midr_range *midr_ranges;
+ void (*ds_synth)(const struct arm_spe_record *record,
+ union perf_mem_data_src *data_src);
+};
+
+#define DS(range, func) \
+ { \
+ .midr_ranges = range, \
+ .ds_synth = arm_spe__synth_##func, \
+ }
+
static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
unsigned char *buf, size_t len)
{
@@ -443,6 +455,10 @@ static const struct midr_range common_ds_encoding_cpus[] = {
{},
};
+static const struct data_source_handle data_source_handles[] = {
+ DS(common_ds_encoding_cpus, data_source_common),
+};
+
static void arm_spe__sample_flags(struct arm_spe_queue *speq)
{
const struct arm_spe_record *record = &speq->decoder->record;
@@ -555,12 +571,14 @@ static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
data_src->mem_lvl |= PERF_MEM_LVL_REM_CCE1;
}
-static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
+static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
+ const struct arm_spe_record *record,
+ union perf_mem_data_src *data_src)
{
struct arm_spe *spe = speq->spe;
- bool is_in_cpu_list;
u64 *metadata = NULL;
- u64 midr = 0;
+ u64 midr;
+ unsigned int i;
/* Metadata version 1 assumes all CPUs are the same (old behavior) */
if (spe->metadata_ver == 1) {
@@ -592,18 +610,20 @@ static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
midr = metadata[ARM_SPE_CPU_MIDR];
}
- is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus);
- if (is_in_cpu_list)
- return true;
- else
- return false;
+ for (i = 0; i < ARRAY_SIZE(data_source_handles); i++) {
+ if (is_midr_in_range_list(midr, data_source_handles[i].midr_ranges)) {
+ data_source_handles[i].ds_synth(record, data_src);
+ return true;
+ }
+ }
+
+ return false;
}
static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
const struct arm_spe_record *record)
{
union perf_mem_data_src data_src = { .mem_op = PERF_MEM_OP_NA };
- bool is_common = arm_spe__is_common_ds_encoding(speq);
if (record->op & ARM_SPE_OP_LD)
data_src.mem_op = PERF_MEM_OP_LOAD;
@@ -612,9 +632,7 @@ static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
else
return 0;
- if (is_common)
- arm_spe__synth_data_source_common(record, &data_src);
- else
+ if (!arm_spe__synth_ds(speq, record, &data_src))
arm_spe__synth_memory_level(record, &data_src);
if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) {
--
2.47.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne
2024-11-08 1:09 [PATCH v4 0/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
2024-11-08 1:09 ` [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Ilkka Koskinen
@ 2024-11-08 1:09 ` Ilkka Koskinen
2024-11-08 14:51 ` Leo Yan
1 sibling, 1 reply; 7+ messages in thread
From: Ilkka Koskinen @ 2024-11-08 1:09 UTC (permalink / raw)
To: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, Graham Woodward
Cc: Ilkka Koskinen, linux-arm-kernel, linux-perf-users, linux-kernel
Decode SPE Data Source packets on AmpereOne. The field is IMPDEF.
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
---
.../util/arm-spe-decoder/arm-spe-decoder.h | 9 ++++
tools/perf/util/arm-spe.c | 44 +++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
index 358c611eeddb..4bcd627e859f 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
@@ -67,6 +67,15 @@ enum arm_spe_common_data_source {
ARM_SPE_COMMON_DS_DRAM = 0xe,
};
+enum arm_spe_ampereone_data_source {
+ ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE = 0x0,
+ ARM_SPE_AMPEREONE_SLC = 0x3,
+ ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE = 0x5,
+ ARM_SPE_AMPEREONE_DDR = 0x7,
+ ARM_SPE_AMPEREONE_L1D = 0x8,
+ ARM_SPE_AMPEREONE_L2D = 0x9,
+};
+
struct arm_spe_record {
enum arm_spe_sample_type type;
int err;
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index dfb0c07cb7fe..df84933b673d 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -455,8 +455,14 @@ static const struct midr_range common_ds_encoding_cpus[] = {
{},
};
+static const struct midr_range ampereone_ds_encoding_cpus[] = {
+ MIDR_ALL_VERSIONS(MIDR_AMPERE1A),
+ {},
+};
+
static const struct data_source_handle data_source_handles[] = {
DS(common_ds_encoding_cpus, data_source_common),
+ DS(ampereone_ds_encoding_cpus, data_source_ampereone),
};
static void arm_spe__sample_flags(struct arm_spe_queue *speq)
@@ -548,6 +554,44 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor
}
}
+/*
+ * Source is IMPDEF. Here we convert the source code used on AmpereOne cores
+ * to the common (Neoverse, Cortex) to avoid duplicating the decoding code.
+ */
+static void arm_spe__synth_data_source_ampereone(const struct arm_spe_record *record,
+ union perf_mem_data_src *data_src)
+{
+ struct arm_spe_record common_record;
+
+ switch (record->source) {
+ case ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE:
+ common_record.source = ARM_SPE_COMMON_DS_PEER_CORE;
+ break;
+ case ARM_SPE_AMPEREONE_SLC:
+ common_record.source = ARM_SPE_COMMON_DS_SYS_CACHE;
+ break;
+ case ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE:
+ common_record.source = ARM_SPE_COMMON_DS_REMOTE;
+ break;
+ case ARM_SPE_AMPEREONE_DDR:
+ common_record.source = ARM_SPE_COMMON_DS_DRAM;
+ break;
+ case ARM_SPE_AMPEREONE_L1D:
+ common_record.source = ARM_SPE_COMMON_DS_L1D;
+ break;
+ case ARM_SPE_AMPEREONE_L2D:
+ common_record.source = ARM_SPE_COMMON_DS_L2;
+ break;
+ default:
+ pr_warning_once("AmpereOne: Unknown data source (0x%x)\n",
+ record->source);
+ return;
+ }
+
+ common_record.op = record->op;
+ arm_spe__synth_data_source_common(&common_record, data_src);
+}
+
static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
union perf_mem_data_src *data_src)
{
--
2.47.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores
2024-11-08 1:09 ` [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Ilkka Koskinen
@ 2024-11-08 14:50 ` Leo Yan
2024-11-08 20:24 ` Ilkka Koskinen
0 siblings, 1 reply; 7+ messages in thread
From: Leo Yan @ 2024-11-08 14:50 UTC (permalink / raw)
To: Ilkka Koskinen
Cc: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, Graham Woodward,
linux-arm-kernel, linux-perf-users, linux-kernel
Hi Ilkka,
On Fri, Nov 08, 2024 at 01:09:10AM +0000, Ilkka Koskinen wrote:
>
> Split Data Source Packet handling to prepare adding support for
> other implementations.
>
> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> ---
> tools/perf/util/arm-spe.c | 42 ++++++++++++++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> index dbf13f47879c..dfb0c07cb7fe 100644
> --- a/tools/perf/util/arm-spe.c
> +++ b/tools/perf/util/arm-spe.c
> @@ -103,6 +103,18 @@ struct arm_spe_queue {
> u32 flags;
> };
>
> +struct data_source_handle {
> + const struct midr_range *midr_ranges;
> + void (*ds_synth)(const struct arm_spe_record *record,
> + union perf_mem_data_src *data_src);
> +};
> +
> +#define DS(range, func) \
> + { \
> + .midr_ranges = range, \
> + .ds_synth = arm_spe__synth_##func, \
> + }
> +
> static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
> unsigned char *buf, size_t len)
> {
> @@ -443,6 +455,10 @@ static const struct midr_range common_ds_encoding_cpus[] = {
> {},
> };
>
> +static const struct data_source_handle data_source_handles[] = {
> + DS(common_ds_encoding_cpus, data_source_common),
> +};
> +
Move this structure under arm_spe__synth_data_source_common(),
otherwise, the building will fail:
CC util/arm-spe.o
util/arm-spe.c:115:15: error: ‘arm_spe__synth_data_source_common’ undeclared here (not in a function)
115 | .ds_synth = arm_spe__synth_##func, \
| ^~~~~~~~~~~~~~~
util/arm-spe.c:464:2: note: in expansion of macro ‘DS’
464 | DS(common_ds_encoding_cpus, data_source_common),
| ^~
The rest looks good to me.
Thanks,
Leo
> static void arm_spe__sample_flags(struct arm_spe_queue *speq)
> {
> const struct arm_spe_record *record = &speq->decoder->record;
> @@ -555,12 +571,14 @@ static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
> data_src->mem_lvl |= PERF_MEM_LVL_REM_CCE1;
> }
>
> -static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
> +static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
> + const struct arm_spe_record *record,
> + union perf_mem_data_src *data_src)
> {
> struct arm_spe *spe = speq->spe;
> - bool is_in_cpu_list;
> u64 *metadata = NULL;
> - u64 midr = 0;
> + u64 midr;
> + unsigned int i;
>
> /* Metadata version 1 assumes all CPUs are the same (old behavior) */
> if (spe->metadata_ver == 1) {
> @@ -592,18 +610,20 @@ static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
> midr = metadata[ARM_SPE_CPU_MIDR];
> }
>
> - is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus);
> - if (is_in_cpu_list)
> - return true;
> - else
> - return false;
> + for (i = 0; i < ARRAY_SIZE(data_source_handles); i++) {
> + if (is_midr_in_range_list(midr, data_source_handles[i].midr_ranges)) {
> + data_source_handles[i].ds_synth(record, data_src);
> + return true;
> + }
> + }
> +
> + return false;
> }
>
> static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
> const struct arm_spe_record *record)
> {
> union perf_mem_data_src data_src = { .mem_op = PERF_MEM_OP_NA };
> - bool is_common = arm_spe__is_common_ds_encoding(speq);
>
> if (record->op & ARM_SPE_OP_LD)
> data_src.mem_op = PERF_MEM_OP_LOAD;
> @@ -612,9 +632,7 @@ static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
> else
> return 0;
>
> - if (is_common)
> - arm_spe__synth_data_source_common(record, &data_src);
> - else
> + if (!arm_spe__synth_ds(speq, record, &data_src))
> arm_spe__synth_memory_level(record, &data_src);
>
> if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) {
> --
> 2.47.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne
2024-11-08 1:09 ` [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
@ 2024-11-08 14:51 ` Leo Yan
2024-12-09 15:26 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 7+ messages in thread
From: Leo Yan @ 2024-11-08 14:51 UTC (permalink / raw)
To: Ilkka Koskinen
Cc: John Garry, Will Deacon, James Clark, Mike Leach, Leo Yan,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, Graham Woodward,
linux-arm-kernel, linux-perf-users, linux-kernel
On Fri, Nov 08, 2024 at 01:09:11AM +0000, Ilkka Koskinen wrote:
>
> Decode SPE Data Source packets on AmpereOne. The field is IMPDEF.
>
> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Reviewed-by: Leo Yan <leo.yan@arm.com>
> ---
> .../util/arm-spe-decoder/arm-spe-decoder.h | 9 ++++
> tools/perf/util/arm-spe.c | 44 +++++++++++++++++++
> 2 files changed, 53 insertions(+)
>
> diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
> index 358c611eeddb..4bcd627e859f 100644
> --- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
> +++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
> @@ -67,6 +67,15 @@ enum arm_spe_common_data_source {
> ARM_SPE_COMMON_DS_DRAM = 0xe,
> };
>
> +enum arm_spe_ampereone_data_source {
> + ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE = 0x0,
> + ARM_SPE_AMPEREONE_SLC = 0x3,
> + ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE = 0x5,
> + ARM_SPE_AMPEREONE_DDR = 0x7,
> + ARM_SPE_AMPEREONE_L1D = 0x8,
> + ARM_SPE_AMPEREONE_L2D = 0x9,
> +};
> +
> struct arm_spe_record {
> enum arm_spe_sample_type type;
> int err;
> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> index dfb0c07cb7fe..df84933b673d 100644
> --- a/tools/perf/util/arm-spe.c
> +++ b/tools/perf/util/arm-spe.c
> @@ -455,8 +455,14 @@ static const struct midr_range common_ds_encoding_cpus[] = {
> {},
> };
>
> +static const struct midr_range ampereone_ds_encoding_cpus[] = {
> + MIDR_ALL_VERSIONS(MIDR_AMPERE1A),
> + {},
> +};
> +
> static const struct data_source_handle data_source_handles[] = {
> DS(common_ds_encoding_cpus, data_source_common),
> + DS(ampereone_ds_encoding_cpus, data_source_ampereone),
> };
>
> static void arm_spe__sample_flags(struct arm_spe_queue *speq)
> @@ -548,6 +554,44 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor
> }
> }
>
> +/*
> + * Source is IMPDEF. Here we convert the source code used on AmpereOne cores
> + * to the common (Neoverse, Cortex) to avoid duplicating the decoding code.
> + */
> +static void arm_spe__synth_data_source_ampereone(const struct arm_spe_record *record,
> + union perf_mem_data_src *data_src)
> +{
> + struct arm_spe_record common_record;
> +
> + switch (record->source) {
> + case ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE:
> + common_record.source = ARM_SPE_COMMON_DS_PEER_CORE;
> + break;
> + case ARM_SPE_AMPEREONE_SLC:
> + common_record.source = ARM_SPE_COMMON_DS_SYS_CACHE;
> + break;
> + case ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE:
> + common_record.source = ARM_SPE_COMMON_DS_REMOTE;
> + break;
> + case ARM_SPE_AMPEREONE_DDR:
> + common_record.source = ARM_SPE_COMMON_DS_DRAM;
> + break;
> + case ARM_SPE_AMPEREONE_L1D:
> + common_record.source = ARM_SPE_COMMON_DS_L1D;
> + break;
> + case ARM_SPE_AMPEREONE_L2D:
> + common_record.source = ARM_SPE_COMMON_DS_L2;
> + break;
> + default:
> + pr_warning_once("AmpereOne: Unknown data source (0x%x)\n",
> + record->source);
> + return;
> + }
> +
> + common_record.op = record->op;
> + arm_spe__synth_data_source_common(&common_record, data_src);
> +}
> +
> static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
> union perf_mem_data_src *data_src)
> {
> --
> 2.47.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores
2024-11-08 14:50 ` Leo Yan
@ 2024-11-08 20:24 ` Ilkka Koskinen
0 siblings, 0 replies; 7+ messages in thread
From: Ilkka Koskinen @ 2024-11-08 20:24 UTC (permalink / raw)
To: Leo Yan
Cc: Ilkka Koskinen, John Garry, Will Deacon, James Clark, Mike Leach,
Leo Yan, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan, Graham Woodward,
linux-arm-kernel, linux-perf-users, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 4665 bytes --]
On Fri, 8 Nov 2024, Leo Yan wrote:
> Hi Ilkka,
>
> On Fri, Nov 08, 2024 at 01:09:10AM +0000, Ilkka Koskinen wrote:
>>
>> Split Data Source Packet handling to prepare adding support for
>> other implementations.
>>
>> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>> ---
>> tools/perf/util/arm-spe.c | 42 ++++++++++++++++++++++++++++-----------
>> 1 file changed, 30 insertions(+), 12 deletions(-)
>>
>> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
>> index dbf13f47879c..dfb0c07cb7fe 100644
>> --- a/tools/perf/util/arm-spe.c
>> +++ b/tools/perf/util/arm-spe.c
>> @@ -103,6 +103,18 @@ struct arm_spe_queue {
>> u32 flags;
>> };
>>
>> +struct data_source_handle {
>> + const struct midr_range *midr_ranges;
>> + void (*ds_synth)(const struct arm_spe_record *record,
>> + union perf_mem_data_src *data_src);
>> +};
>> +
>> +#define DS(range, func) \
>> + { \
>> + .midr_ranges = range, \
>> + .ds_synth = arm_spe__synth_##func, \
>> + }
>> +
>> static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
>> unsigned char *buf, size_t len)
>> {
>> @@ -443,6 +455,10 @@ static const struct midr_range common_ds_encoding_cpus[] = {
>> {},
>> };
>>
>> +static const struct data_source_handle data_source_handles[] = {
>> + DS(common_ds_encoding_cpus, data_source_common),
>> +};
>> +
>
> Move this structure under arm_spe__synth_data_source_common(),
> otherwise, the building will fail:
Uh, didn't I build it after I moved the arrays. I fix it right away
--Ilkka
>
> CC util/arm-spe.o
> util/arm-spe.c:115:15: error: ‘arm_spe__synth_data_source_common’ undeclared here (not in a function)
> 115 | .ds_synth = arm_spe__synth_##func, \
> | ^~~~~~~~~~~~~~~
> util/arm-spe.c:464:2: note: in expansion of macro ‘DS’
> 464 | DS(common_ds_encoding_cpus, data_source_common),
> | ^~
>
> The rest looks good to me.
>
> Thanks,
> Leo
>
>> static void arm_spe__sample_flags(struct arm_spe_queue *speq)
>> {
>> const struct arm_spe_record *record = &speq->decoder->record;
>> @@ -555,12 +571,14 @@ static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
>> data_src->mem_lvl |= PERF_MEM_LVL_REM_CCE1;
>> }
>>
>> -static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
>> +static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
>> + const struct arm_spe_record *record,
>> + union perf_mem_data_src *data_src)
>> {
>> struct arm_spe *spe = speq->spe;
>> - bool is_in_cpu_list;
>> u64 *metadata = NULL;
>> - u64 midr = 0;
>> + u64 midr;
>> + unsigned int i;
>>
>> /* Metadata version 1 assumes all CPUs are the same (old behavior) */
>> if (spe->metadata_ver == 1) {
>> @@ -592,18 +610,20 @@ static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
>> midr = metadata[ARM_SPE_CPU_MIDR];
>> }
>>
>> - is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus);
>> - if (is_in_cpu_list)
>> - return true;
>> - else
>> - return false;
>> + for (i = 0; i < ARRAY_SIZE(data_source_handles); i++) {
>> + if (is_midr_in_range_list(midr, data_source_handles[i].midr_ranges)) {
>> + data_source_handles[i].ds_synth(record, data_src);
>> + return true;
>> + }
>> + }
>> +
>> + return false;
>> }
>>
>> static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
>> const struct arm_spe_record *record)
>> {
>> union perf_mem_data_src data_src = { .mem_op = PERF_MEM_OP_NA };
>> - bool is_common = arm_spe__is_common_ds_encoding(speq);
>>
>> if (record->op & ARM_SPE_OP_LD)
>> data_src.mem_op = PERF_MEM_OP_LOAD;
>> @@ -612,9 +632,7 @@ static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
>> else
>> return 0;
>>
>> - if (is_common)
>> - arm_spe__synth_data_source_common(record, &data_src);
>> - else
>> + if (!arm_spe__synth_ds(speq, record, &data_src))
>> arm_spe__synth_memory_level(record, &data_src);
>>
>> if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) {
>> --
>> 2.47.0
>>
>>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne
2024-11-08 14:51 ` Leo Yan
@ 2024-12-09 15:26 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-12-09 15:26 UTC (permalink / raw)
To: Leo Yan
Cc: Ilkka Koskinen, John Garry, Will Deacon, James Clark, Mike Leach,
Leo Yan, Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Liang, Kan, Graham Woodward, linux-arm-kernel, linux-perf-users,
linux-kernel
On Fri, Nov 08, 2024 at 02:51:38PM +0000, Leo Yan wrote:
> On Fri, Nov 08, 2024 at 01:09:11AM +0000, Ilkka Koskinen wrote:
> >
> > Decode SPE Data Source packets on AmpereOne. The field is IMPDEF.
> >
> > Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>
> Reviewed-by: Leo Yan <leo.yan@arm.com>
Thanks, applied to perf-tools-next,
- Arnaldo
> > ---
> > .../util/arm-spe-decoder/arm-spe-decoder.h | 9 ++++
> > tools/perf/util/arm-spe.c | 44 +++++++++++++++++++
> > 2 files changed, 53 insertions(+)
> >
> > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
> > index 358c611eeddb..4bcd627e859f 100644
> > --- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
> > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
> > @@ -67,6 +67,15 @@ enum arm_spe_common_data_source {
> > ARM_SPE_COMMON_DS_DRAM = 0xe,
> > };
> >
> > +enum arm_spe_ampereone_data_source {
> > + ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE = 0x0,
> > + ARM_SPE_AMPEREONE_SLC = 0x3,
> > + ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE = 0x5,
> > + ARM_SPE_AMPEREONE_DDR = 0x7,
> > + ARM_SPE_AMPEREONE_L1D = 0x8,
> > + ARM_SPE_AMPEREONE_L2D = 0x9,
> > +};
> > +
> > struct arm_spe_record {
> > enum arm_spe_sample_type type;
> > int err;
> > diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> > index dfb0c07cb7fe..df84933b673d 100644
> > --- a/tools/perf/util/arm-spe.c
> > +++ b/tools/perf/util/arm-spe.c
> > @@ -455,8 +455,14 @@ static const struct midr_range common_ds_encoding_cpus[] = {
> > {},
> > };
> >
> > +static const struct midr_range ampereone_ds_encoding_cpus[] = {
> > + MIDR_ALL_VERSIONS(MIDR_AMPERE1A),
> > + {},
> > +};
> > +
> > static const struct data_source_handle data_source_handles[] = {
> > DS(common_ds_encoding_cpus, data_source_common),
> > + DS(ampereone_ds_encoding_cpus, data_source_ampereone),
> > };
> >
> > static void arm_spe__sample_flags(struct arm_spe_queue *speq)
> > @@ -548,6 +554,44 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor
> > }
> > }
> >
> > +/*
> > + * Source is IMPDEF. Here we convert the source code used on AmpereOne cores
> > + * to the common (Neoverse, Cortex) to avoid duplicating the decoding code.
> > + */
> > +static void arm_spe__synth_data_source_ampereone(const struct arm_spe_record *record,
> > + union perf_mem_data_src *data_src)
> > +{
> > + struct arm_spe_record common_record;
> > +
> > + switch (record->source) {
> > + case ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE:
> > + common_record.source = ARM_SPE_COMMON_DS_PEER_CORE;
> > + break;
> > + case ARM_SPE_AMPEREONE_SLC:
> > + common_record.source = ARM_SPE_COMMON_DS_SYS_CACHE;
> > + break;
> > + case ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE:
> > + common_record.source = ARM_SPE_COMMON_DS_REMOTE;
> > + break;
> > + case ARM_SPE_AMPEREONE_DDR:
> > + common_record.source = ARM_SPE_COMMON_DS_DRAM;
> > + break;
> > + case ARM_SPE_AMPEREONE_L1D:
> > + common_record.source = ARM_SPE_COMMON_DS_L1D;
> > + break;
> > + case ARM_SPE_AMPEREONE_L2D:
> > + common_record.source = ARM_SPE_COMMON_DS_L2;
> > + break;
> > + default:
> > + pr_warning_once("AmpereOne: Unknown data source (0x%x)\n",
> > + record->source);
> > + return;
> > + }
> > +
> > + common_record.op = record->op;
> > + arm_spe__synth_data_source_common(&common_record, data_src);
> > +}
> > +
> > static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
> > union perf_mem_data_src *data_src)
> > {
> > --
> > 2.47.0
> >
> >
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-12-09 15:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-08 1:09 [PATCH v4 0/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
2024-11-08 1:09 ` [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Ilkka Koskinen
2024-11-08 14:50 ` Leo Yan
2024-11-08 20:24 ` Ilkka Koskinen
2024-11-08 1:09 ` [PATCH v4 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
2024-11-08 14:51 ` Leo Yan
2024-12-09 15:26 ` Arnaldo Carvalho de Melo
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).