From: Leo Yan <leo.yan@arm.com>
To: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Cc: John Garry <john.g.garry@oracle.com>,
Will Deacon <will@kernel.org>,
James Clark <james.clark@linaro.org>,
Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linux.dev>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
Graham Woodward <graham.woodward@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores
Date: Mon, 11 Nov 2024 12:55:50 +0000 [thread overview]
Message-ID: <20241111125550.GA350698@e132581.arm.com> (raw)
In-Reply-To: <20241108202946.16835-2-ilkka@os.amperecomputing.com>
On Fri, Nov 08, 2024 at 08:29:45PM +0000, Ilkka Koskinen wrote:
>
> Split Data Source Packet handling to prepare adding support for
> other implementations.
>
> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Reviewed-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/util/arm-spe.c | 42 ++++++++++++++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
> index dbf13f47879c..3064c3f22806 100644
> --- a/tools/perf/util/arm-spe.c
> +++ b/tools/perf/util/arm-spe.c
> @@ -103,6 +103,18 @@ struct arm_spe_queue {
> u32 flags;
> };
>
> +struct data_source_handle {
> + const struct midr_range *midr_ranges;
> + void (*ds_synth)(const struct arm_spe_record *record,
> + union perf_mem_data_src *data_src);
> +};
> +
> +#define DS(range, func) \
> + { \
> + .midr_ranges = range, \
> + .ds_synth = arm_spe__synth_##func, \
> + }
> +
> static void arm_spe_dump(struct arm_spe *spe __maybe_unused,
> unsigned char *buf, size_t len)
> {
> @@ -532,6 +544,10 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor
> }
> }
>
> +static const struct data_source_handle data_source_handles[] = {
> + DS(common_ds_encoding_cpus, data_source_common),
> +};
> +
> static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
> union perf_mem_data_src *data_src)
> {
> @@ -555,12 +571,14 @@ static void arm_spe__synth_memory_level(const struct arm_spe_record *record,
> data_src->mem_lvl |= PERF_MEM_LVL_REM_CCE1;
> }
>
> -static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
> +static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
> + const struct arm_spe_record *record,
> + union perf_mem_data_src *data_src)
> {
> struct arm_spe *spe = speq->spe;
> - bool is_in_cpu_list;
> u64 *metadata = NULL;
> - u64 midr = 0;
> + u64 midr;
> + unsigned int i;
>
> /* Metadata version 1 assumes all CPUs are the same (old behavior) */
> if (spe->metadata_ver == 1) {
> @@ -592,18 +610,20 @@ static bool arm_spe__is_common_ds_encoding(struct arm_spe_queue *speq)
> midr = metadata[ARM_SPE_CPU_MIDR];
> }
>
> - is_in_cpu_list = is_midr_in_range_list(midr, common_ds_encoding_cpus);
> - if (is_in_cpu_list)
> - return true;
> - else
> - return false;
> + for (i = 0; i < ARRAY_SIZE(data_source_handles); i++) {
> + if (is_midr_in_range_list(midr, data_source_handles[i].midr_ranges)) {
> + data_source_handles[i].ds_synth(record, data_src);
> + return true;
> + }
> + }
> +
> + return false;
> }
>
> static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
> const struct arm_spe_record *record)
> {
> union perf_mem_data_src data_src = { .mem_op = PERF_MEM_OP_NA };
> - bool is_common = arm_spe__is_common_ds_encoding(speq);
>
> if (record->op & ARM_SPE_OP_LD)
> data_src.mem_op = PERF_MEM_OP_LOAD;
> @@ -612,9 +632,7 @@ static u64 arm_spe__synth_data_source(struct arm_spe_queue *speq,
> else
> return 0;
>
> - if (is_common)
> - arm_spe__synth_data_source_common(record, &data_src);
> - else
> + if (!arm_spe__synth_ds(speq, record, &data_src))
> arm_spe__synth_memory_level(record, &data_src);
>
> if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) {
> --
> 2.47.0
>
>
next prev parent reply other threads:[~2024-11-11 12:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 20:29 [PATCH v5 0/2] [PATCH v4 0/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
2024-11-08 20:29 ` [PATCH v5 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Ilkka Koskinen
2024-11-11 12:55 ` Leo Yan [this message]
2024-11-08 20:29 ` [PATCH v5 2/2] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Ilkka Koskinen
2024-11-13 10:42 ` [PATCH v5 0/2] [PATCH v4 0/2] " James Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241111125550.GA350698@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=graham.woodward@arm.com \
--cc=ilkka@os.amperecomputing.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).