perf arm-spe: Add support for SPE Data Source packet on AmpereOne
Subsystems (2)
v4 cover perf arm-spe: Add support for SPE Data Source packet on AmpereOne
v1:
* https://lore.kernel.org/all/[email protected]/
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/[email protected]/
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/[email protected]/
v4:
* Split midr/decoding function table
* Made AmpereOne DS decoding function to ignore unknown sources
* https://lore.kernel.org/all/[email protected]/
v5:
* Moved data_source_handles[] to fix the build issue
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(-)
Signature · 1 line
2.47.0
PATCH v5 1/2 perf arm-spe: Prepare for adding data source packet implementations for other cores
Split Data Source Packet handling to prepare adding support for other implementations.
--- tools/perf/util/arm-spe.c | 42 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-)
tools/perf/util/arm-spe.c +30 -12
@@ -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) {
@@ -532,6 +544,10 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor } } +static const struct data_source_handle data_source_handles[] = { +DS (common_ds_encoding_cpus, data_source_common), +}; +static void arm_spe__synth_memory_level (const struct arm_spe_record *record,union perf_mem_data_src *data_src) {
@@ -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 )) {
Signature · 1 line
2.47.0
Re: [PATCH v5 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores
Quoted 5 lines · Ilkka Koskinen
Split Data Source Packet handling to prepare adding support for other implementations.
Signed-off-by Ilkka Koskinen <[email protected]>
Quoted 98 lines
--- tools/perf/util/arm-spe.c | 42 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-)tools/perf/util/arm-spe.c +30
-13@@ -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) {@@ -532,6 +544,10 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor } } +static const struct data_source_handle data_source_handles[] = { +DS (common_ds_encoding_cpus, data_source_common), +}; +static void arm_spe__synth_memory_level (const struct arm_spe_record *record,union perf_mem_data_src *data_src) {@@ -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
PATCH v5 2/2 perf arm-spe: Add support for SPE Data Source packet on AmpereOne
In reply to Ilkka KoskinenDecode SPE Data Source packets on AmpereOne. The field is IMPDEF.
--- .../util/arm-spe-decoder/arm-spe-decoder.h | 9 ++++ tools/perf/util/arm-spe.c | 44 +++++++++++++++++++ 2 files changed, 53 insertions(+)
tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +9 -0
@@ -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;
tools/perf/util/arm-spe.c +44 -0
58 lines not on this page · raw message
Signature · 1 line
2.47.0
Quoted 25 lines · Ilkka Koskinen
v1:
* https://lore.kernel.org/all/[email protected]/v2:
* Doesn't useread_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/[email protected]/v3:
* Changed source mapping to simple switch statement
* Droppedis_xyz()stuff
* Added table to map midr to data source decoding function
* https://lore.kernel.org/all/[email protected]/v4:
* Split midr/decoding function table
* Made AmpereOne DS decoding function to ignore unknown sources
* https://lore.kernel.org/all/[email protected]/v5:
* Moved data_source_handles[] to fix the build issue
Quoted 9 lines
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(-)