Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf arm-spe: Use old behavior when opening old SPE files

Since the linked commit, we stopped interpreting data source if the
perf.data file doesn't have the new metadata version. This means that
perf c2c will show no samples in this case.

Keep the old behavior so old files can be opened, but also still show
the new warning that updating might improve the decoding.

Also re-write the warning to be more concise and specific to a user.

Fixes: ba5e7169e548 ("perf arm-spe: Use metadata to decide the data source feature")
Signed-off-by: James Clark <james.clark@linaro.org>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Cc: Julio.Suarez@arm.com
Cc: Kiel.Friedt@arm.com
Cc: Ryan.Roberts@arm.com
Cc: Will Deacon <will@kernel.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Besar Wicaksono <bwicaksono@nvidia.com>
Cc: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20241029143734.291638-1-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

James Clark and committed by
Namhyung Kim
ba993e5a 064d569e

+24 -26
+24 -26
tools/perf/util/arm-spe.c
··· 562 562 u64 *metadata = NULL; 563 563 u64 midr = 0; 564 564 565 - /* 566 - * Metadata version 1 doesn't contain any info for MIDR. 567 - * Simply return false in this case. 568 - */ 565 + /* Metadata version 1 assumes all CPUs are the same (old behavior) */ 569 566 if (spe->metadata_ver == 1) { 570 - pr_warning_once("The data file contains metadata version 1, " 571 - "which is absent the info for data source. " 572 - "Please upgrade the tool to record data.\n"); 573 - return false; 574 - } 567 + const char *cpuid; 575 568 576 - /* CPU ID is -1 for per-thread mode */ 577 - if (speq->cpu < 0) { 578 - /* 579 - * On the heterogeneous system, due to CPU ID is -1, 580 - * cannot confirm the data source packet is supported. 581 - */ 582 - if (!spe->is_homogeneous) 569 + pr_warning_once("Old SPE metadata, re-record to improve decode accuracy\n"); 570 + cpuid = perf_env__cpuid(spe->session->evlist->env); 571 + midr = strtol(cpuid, NULL, 16); 572 + } else { 573 + /* CPU ID is -1 for per-thread mode */ 574 + if (speq->cpu < 0) { 575 + /* 576 + * On the heterogeneous system, due to CPU ID is -1, 577 + * cannot confirm the data source packet is supported. 578 + */ 579 + if (!spe->is_homogeneous) 580 + return false; 581 + 582 + /* In homogeneous system, simply use CPU0's metadata */ 583 + if (spe->metadata) 584 + metadata = spe->metadata[0]; 585 + } else { 586 + metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu); 587 + } 588 + 589 + if (!metadata) 583 590 return false; 584 591 585 - /* In homogeneous system, simply use CPU0's metadata */ 586 - if (spe->metadata) 587 - metadata = spe->metadata[0]; 588 - } else { 589 - metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu); 592 + midr = metadata[ARM_SPE_CPU_MIDR]; 590 593 } 591 - 592 - if (!metadata) 593 - return false; 594 - 595 - midr = metadata[ARM_SPE_CPU_MIDR]; 596 594 597 595 is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus); 598 596 if (is_in_cpu_list)