[PATCH 10/12] perf arm_spe: Refactor arm_spe__get_metadata_by_cpu()
James Clark
james.clark at linaro.org
Fri Jun 20 03:45:40 PDT 2025
On 13/06/2025 4:53 pm, Leo Yan wrote:
> Handle "CPU=-1" (per-thread mode) in the arm_spe__get_metadata_by_cpu()
> function. As a result, the function is more general and will be invoked
> by a sequential change.
>
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
> tools/perf/util/arm-spe.c | 30 ++++++++++++++----------------
> 1 file changed, 14 insertions(+), 16 deletions(-)
>
> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> index 2ab38d21d52f73617451a6a79f9d5ae931a34f49..8e93b0d151a98714d0c5e5f6ceec386a2aa63ad0 100644
> --- a/tools/perf/util/arm-spe.c
> +++ b/tools/perf/util/arm-spe.c
> @@ -324,6 +324,19 @@ static u64 *arm_spe__get_metadata_by_cpu(struct arm_spe *spe, u64 cpu)
> if (!spe->metadata)
> return NULL;
>
> + /* CPU ID is -1 for per-thread mode */
> + if (cpu < 0) {
> + /*
> + * On the heterogeneous system, due to CPU ID is -1,
> + * cannot confirm the meta data.
> + */
> + if (!spe->is_homogeneous)
> + return NULL;
> +
> + /* In homogeneous system, simply use CPU0's metadata */
> + return spe->metadata[0];
> + }
> +
> for (i = 0; i < spe->metadata_nr_cpu; i++)
> if (spe->metadata[i][ARM_SPE_CPU] == cpu)
> return spe->metadata[i];
> @@ -924,22 +937,7 @@ static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
> cpuid = perf_env__cpuid(spe->session->evlist->env);
> midr = strtol(cpuid, NULL, 16);
> } else {
> - /* CPU ID is -1 for per-thread mode */
> - if (speq->cpu < 0) {
> - /*
> - * On the heterogeneous system, due to CPU ID is -1,
> - * cannot confirm the data source packet is supported.
> - */
> - if (!spe->is_homogeneous)
> - return false;
> -
> - /* In homogeneous system, simply use CPU0's metadata */
> - if (spe->metadata)
> - metadata = spe->metadata[0];
> - } else {
> - metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu);
> - }
> -
> + metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu);
> if (!metadata)
> return false;
>
>
Reviewed-by: James Clark <james.clark at linaro.org>
More information about the linux-arm-kernel
mailing list