Skip to content

Commit ccdc9e9

Browse files
ilkka-koskinenacmel
authored andcommitted
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. Reviewed-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Graham Woodward <graham.woodward@arm.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linux.dev> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20241108202946.16835-2-ilkka@os.amperecomputing.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 9eef3ec commit ccdc9e9

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

tools/perf/util/arm-spe.c

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ struct arm_spe_queue {
103103
u32 flags;
104104
};
105105

106+
struct data_source_handle {
107+
const struct midr_range *midr_ranges;
108+
void (*ds_synth)(const struct arm_spe_record *record,
109+
union perf_mem_data_src *data_src);
110+
};
111+
112+
#define DS(range, func) \
113+
{ \
114+
.midr_ranges = range, \
115+
.ds_synth = arm_spe__synth_##func, \
116+
}
117+
106118
static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
107119
unsigned char *buf, size_t len)
108120
{
@@ -532,6 +544,10 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor
532544
}
533545
}
534546

547+
static const struct data_source_handle data_source_handles[] = {
548+
DS(common_ds_encoding_cpus, data_source_common),
549+
};
550+
535551
static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
536552
union perf_mem_data_src *data_src)
537553
{
@@ -555,12 +571,14 @@ static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
555571
data_src->mem_lvl |= PERF_MEM_LVL_REM_CCE1;
556572
}
557573

558-
static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
574+
static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
575+
const struct arm_spe_record *record,
576+
union perf_mem_data_src *data_src)
559577
{
560578
struct arm_spe *spe = speq->spe;
561-
bool is_in_cpu_list;
562579
u64 *metadata = NULL;
563-
u64 midr = 0;
580+
u64 midr;
581+
unsigned int i;
564582

565583
/* Metadata version 1 assumes all CPUs are the same (old behavior) */
566584
if (spe->metadata_ver == 1) {
@@ -592,18 +610,20 @@ static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
592610
midr = metadata[ARM_SPE_CPU_MIDR];
593611
}
594612

595-
is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus);
596-
if (is_in_cpu_list)
597-
return true;
598-
else
599-
return false;
613+
for (i = 0; i < ARRAY_SIZE(data_source_handles); i++) {
614+
if (is_midr_in_range_list(midr, data_source_handles[i].midr_ranges)) {
615+
data_source_handles[i].ds_synth(record, data_src);
616+
return true;
617+
}
618+
}
619+
620+
return false;
600621
}
601622

602623
static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
603624
const struct arm_spe_record *record)
604625
{
605626
union perf_mem_data_src data_src = { .mem_op = PERF_MEM_OP_NA };
606-
bool is_common = arm_spe__is_common_ds_encoding(speq);
607627

608628
if (record->op & ARM_SPE_OP_LD)
609629
data_src.mem_op = PERF_MEM_OP_LOAD;
@@ -612,9 +632,7 @@ static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
612632
else
613633
return 0;
614634

615-
if (is_common)
616-
arm_spe__synth_data_source_common(record, &data_src);
617-
else
635+
if (!arm_spe__synth_ds(speq, record, &data_src))
618636
arm_spe__synth_memory_level(record, &data_src);
619637

620638
if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) {

0 commit comments

Comments
 (0)