Skip to content

Commit ba5e716

Browse files
Leo-Yannamhyung
authored andcommitted
perf arm-spe: Use metadata to decide the data source feature
Use the info in the metadata to decide if the data source feature is supported. The CPU MIDR must be in the CPU list for the common data source encoding. For the metadata version 1, it doesn't include info for MIDR. In this case, due to absent info for making decision, print out warning to remind users to upgrade tool and returns false. Signed-off-by: Leo Yan <leo.yan@arm.com> Reviewed-by: James Clark <james.clark@linaro.org> Link: https://lore.kernel.org/r/20241003185322.192357-5-leo.yan@arm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 56ae663 commit ba5e716

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

tools/perf/util/arm-spe.c

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ static int arm_spe_set_tid(struct arm_spe_queue *speq, pid_t tid)
278278
return 0;
279279
}
280280

281+
static u64 *arm_spe__get_metadata_by_cpu(struct arm_spe *spe, u64 cpu)
282+
{
283+
u64 i;
284+
285+
if (!spe->metadata)
286+
return NULL;
287+
288+
for (i = 0; i < spe->metadata_nr_cpu; i++)
289+
if (spe->metadata[i][ARM_SPE_CPU] == cpu)
290+
return spe->metadata[i];
291+
292+
return NULL;
293+
}
294+
281295
static struct simd_flags arm_spe__synth_simd_flags(const struct arm_spe_record *record)
282296
{
283297
struct simd_flags simd_flags = {};
@@ -520,10 +534,57 @@ static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
520534
data_src->mem_lvl |= PERF_MEM_LVL_REM_CCE1;
521535
}
522536

523-
static u64 arm_spe__synth_data_source(const struct arm_spe_record *record, u64 midr)
537+
static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
538+
{
539+
struct arm_spe *spe = speq->spe;
540+
bool is_in_cpu_list;
541+
u64 *metadata = NULL;
542+
u64 midr = 0;
543+
544+
/*
545+
* Metadata version 1 doesn't contain any info for MIDR.
546+
* Simply return false in this case.
547+
*/
548+
if (spe->metadata_ver == 1) {
549+
pr_warning_once("The data file contains metadata version 1, "
550+
"which is absent the info for data source. "
551+
"Please upgrade the tool to record data.\n");
552+
return false;
553+
}
554+
555+
/* CPU ID is -1 for per-thread mode */
556+
if (speq->cpu < 0) {
557+
/*
558+
* On the heterogeneous system, due to CPU ID is -1,
559+
* cannot confirm the data source packet is supported.
560+
*/
561+
if (!spe->is_homogeneous)
562+
return false;
563+
564+
/* In homogeneous system, simply use CPU0's metadata */
565+
if (spe->metadata)
566+
metadata = spe->metadata[0];
567+
} else {
568+
metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu);
569+
}
570+
571+
if (!metadata)
572+
return false;
573+
574+
midr = metadata[ARM_SPE_CPU_MIDR];
575+
576+
is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus);
577+
if (is_in_cpu_list)
578+
return true;
579+
else
580+
return false;
581+
}
582+
583+
static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
584+
const struct arm_spe_record *record)
524585
{
525586
union perf_mem_data_src data_src = { .mem_op = PERF_MEM_OP_NA };
526-
bool is_common = is_midr_in_range_list(midr, common_ds_encoding_cpus);
587+
bool is_common = arm_spe__is_common_ds_encoding(speq);
527588

528589
if (record->op & ARM_SPE_OP_LD)
529590
data_src.mem_op = PERF_MEM_OP_LOAD;
@@ -556,7 +617,7 @@ static int arm_spe_sample(struct arm_spe_queue *speq)
556617
u64 data_src;
557618
int err;
558619

559-
data_src = arm_spe__synth_data_source(record, spe->midr);
620+
data_src = arm_spe__synth_data_source(speq, record);
560621

561622
if (spe->sample_flc) {
562623
if (record->type & ARM_SPE_L1D_MISS) {

0 commit comments

Comments
 (0)