From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FBCBD5C0ED for ; Fri, 8 Nov 2024 15:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Hg+GWu+/awj7VGXaP1ruT82O6lXjwDaPHit4Vyqkiao=; b=QLOtFSiW4Gg2hlHxGS/FD/R2HO B8RcV3kFcMzq9qZK2/2QhdiNR/oTOPEs2X+UqQZFmUVeZmxEvWH3Lcktp/f3VdnEayJ3Gb216E+gC CIFH137sylqjR3/7NMWVLQpdR1kvwW4FSkDURXcWl9i73kPT2S93w0wn6Gzm3jjmrntezytp0/0hM xK8UA6KWZQcpxYtw/exHzSNgGBtaXGlp+wWTtDW6hMqgF1FlBlJHDacYy7Pbr3tlcLgzYDVyzugRi k5Fo/f/LWStRy3H60wchG5j0Nv959xNgcHjV1P0/1RrPj2YKoTZ2TeJ759lbiC6UZUQzD41M8nSQi SQQsjs0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t9QvO-0000000B1eX-0pEq; Fri, 08 Nov 2024 15:29:26 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t9QJs-0000000AuX0-4BnZ for linux-arm-kernel@lists.infradead.org; Fri, 08 Nov 2024 14:50:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D8853497; Fri, 8 Nov 2024 06:51:07 -0800 (PST) Received: from localhost (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 95DCB3F528; Fri, 8 Nov 2024 06:50:37 -0800 (PST) Date: Fri, 8 Nov 2024 14:50:35 +0000 From: Leo Yan To: Ilkka Koskinen Cc: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Graham Woodward , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Message-ID: <20241108145035.GE47850@e132581.arm.com> References: <20241108010911.58412-1-ilkka@os.amperecomputing.com> <20241108010911.58412-2-ilkka@os.amperecomputing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20241108010911.58412-2-ilkka@os.amperecomputing.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241108_065041_184084_B9D26B6C X-CRM114-Status: GOOD ( 23.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Ilkka, On Fri, Nov 08, 2024 at 01:09:10AM +0000, Ilkka Koskinen wrote: > > Split Data Source Packet handling to prepare adding support for > other implementations. > > Signed-off-by: Ilkka Koskinen > --- > 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..dfb0c07cb7fe 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) > { > @@ -443,6 +455,10 @@ static const struct midr_range common_ds_encoding_cpus[] = { > {}, > }; > > +static const struct data_source_handle data_source_handles[] = { > + DS(common_ds_encoding_cpus, data_source_common), > +}; > + Move this structure under arm_spe__synth_data_source_common(), otherwise, the building will fail: CC util/arm-spe.o util/arm-spe.c:115:15: error: ‘arm_spe__synth_data_source_common’ undeclared here (not in a function) 115 | .ds_synth = arm_spe__synth_##func, \ | ^~~~~~~~~~~~~~~ util/arm-spe.c:464:2: note: in expansion of macro ‘DS’ 464 | DS(common_ds_encoding_cpus, data_source_common), | ^~ The rest looks good to me. Thanks, Leo > static void arm_spe__sample_flags(struct arm_spe_queue *speq) > { > const struct arm_spe_record *record = &speq->decoder->record; > @@ -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 > >