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

perf arm-spe: Add support for SPE Data Source packet on AmpereOne

Decode SPE Data Source packets on AmpereOne. The field is IMPDEF.

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-3-ilkka@os.amperecomputing.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ilkka Koskinen and committed by
Arnaldo Carvalho de Melo
9e7a00ec ccdc9e9c

+53
+9
tools/perf/util/arm-spe-decoder/arm-spe-decoder.h
··· 67 67 ARM_SPE_COMMON_DS_DRAM = 0xe, 68 68 }; 69 69 70 + enum arm_spe_ampereone_data_source { 71 + ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE = 0x0, 72 + ARM_SPE_AMPEREONE_SLC = 0x3, 73 + ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE = 0x5, 74 + ARM_SPE_AMPEREONE_DDR = 0x7, 75 + ARM_SPE_AMPEREONE_L1D = 0x8, 76 + ARM_SPE_AMPEREONE_L2D = 0x9, 77 + }; 78 + 70 79 struct arm_spe_record { 71 80 enum arm_spe_sample_type type; 72 81 int err;
+44
tools/perf/util/arm-spe.c
··· 455 455 {}, 456 456 }; 457 457 458 + static const struct midr_range ampereone_ds_encoding_cpus[] = { 459 + MIDR_ALL_VERSIONS(MIDR_AMPERE1A), 460 + {}, 461 + }; 462 + 458 463 static void arm_spe__sample_flags(struct arm_spe_queue *speq) 459 464 { 460 465 const struct arm_spe_record *record = &speq->decoder->record; ··· 549 544 } 550 545 } 551 546 547 + /* 548 + * Source is IMPDEF. Here we convert the source code used on AmpereOne cores 549 + * to the common (Neoverse, Cortex) to avoid duplicating the decoding code. 550 + */ 551 + static void arm_spe__synth_data_source_ampereone(const struct arm_spe_record *record, 552 + union perf_mem_data_src *data_src) 553 + { 554 + struct arm_spe_record common_record; 555 + 556 + switch (record->source) { 557 + case ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE: 558 + common_record.source = ARM_SPE_COMMON_DS_PEER_CORE; 559 + break; 560 + case ARM_SPE_AMPEREONE_SLC: 561 + common_record.source = ARM_SPE_COMMON_DS_SYS_CACHE; 562 + break; 563 + case ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE: 564 + common_record.source = ARM_SPE_COMMON_DS_REMOTE; 565 + break; 566 + case ARM_SPE_AMPEREONE_DDR: 567 + common_record.source = ARM_SPE_COMMON_DS_DRAM; 568 + break; 569 + case ARM_SPE_AMPEREONE_L1D: 570 + common_record.source = ARM_SPE_COMMON_DS_L1D; 571 + break; 572 + case ARM_SPE_AMPEREONE_L2D: 573 + common_record.source = ARM_SPE_COMMON_DS_L2; 574 + break; 575 + default: 576 + pr_warning_once("AmpereOne: Unknown data source (0x%x)\n", 577 + record->source); 578 + return; 579 + } 580 + 581 + common_record.op = record->op; 582 + arm_spe__synth_data_source_common(&common_record, data_src); 583 + } 584 + 552 585 static const struct data_source_handle data_source_handles[] = { 553 586 DS(common_ds_encoding_cpus, data_source_common), 587 + DS(ampereone_ds_encoding_cpus, data_source_ampereone), 554 588 }; 555 589 556 590 static void arm_spe__synth_memory_level(const struct arm_spe_record *record,