From nobody Sun Nov 24 01:00:30 2024 Received: from CY4PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11020122.outbound.protection.outlook.com [40.93.198.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C22A1C1F34; Fri, 8 Nov 2024 20:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.122 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731097784; cv=fail; b=NP+2kVVJjaSrqo/pTfNSbh/gfxFOeC0f7DomIVXPha2yU2saYUPzpfSGNb5PS0CmcXA4HeXro2wvBbDyWO+xUNlCyA0RTMp3cKO3yzzWemHTbZ/S795tmOMX8T1FAg/UUbyeFeG7NzfdnXef7vz8GYI3Ns5rzRswT+nN2rsQyDA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731097784; c=relaxed/simple; bh=zzRLp8++scY5Duj8+i6eW+SCkzEEv666qtARkoWnj8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=dtXOvElMVf1DK2OcbnT/abm+XiJghB00SQmzxqf2wXERJcxTv4UwhD/9Dn4uEquvCz52x8IjbSD+/t8nEGEGMgddDySkQ00BAQMBgMJKU37NbcmUe9h5H8VQpL+LI5jVzV0vLr6H4jnjbXMQ85o9UCDhf6UMAzOHf5Ie+58A8Pg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=KEGzpvPS; arc=fail smtp.client-ip=40.93.198.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="KEGzpvPS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xVBD7MpUSDgqWrYN+/Roj+149d8DmSW2s6PQCzDHw9+oZ0PbEW8EZsca0k6FihxdiwPGDqxPyACGdLN845gPZ+4LUaEtT2U8qQyP2gQ20HvJtt+svgheaDGKTDz+idz4Gqc8qFEp13XXn/D0a1QG2+g28u2Z2PTKAd1vm3DfucT+cvk/a2e6nkixNe9+M79KMhUddyJA1VlrosV2wZUZSO9oMoC8K2zHRaPBh1E6nMocxYu7d7WD2qbY0UdhP1bqsYieRD7ZsBvtQHKVra7Ve0cuhiPWKaG0pxWldSZJi6CWJPrZSUbDAeCOpzhaaHynJHNfiqaMS2PxnFid0dWTzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gbuJ11LvjiyiHeAmxVaPXqgB2cuWKI0o5ZvlE4nSWH4=; b=mppLGmwlm1OojJ6VHsFy6TYY0tk4yy+Dk+WaXEJ9v8LblP9LZR9Soq1eVoUfMFwzqkgotN4YdM1eHZE1E6SyiFLA1Z1rvBlEhTPss4IdVC+si7XRTfI1hcjm6bKcI/bJwNcJcVjADHYV+gR9QwLlviE+ZsfBM+IO7LCtKY8r85Kz6bmKf7T+FaPP6FGyVbMocJv1WIR0ANAG4YyIBCjeVZB96wux5E0f3W7YTmEVEyMcYYWRux7h7Rpp2/Co7TfzQckjCY87zGtLVrTSUftvtfLqASk4L7pcHB5CsWo0vav0vpvtTAtvuYC8UEhh9Aqiy7m0ARAg5mhcixVuriWVlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gbuJ11LvjiyiHeAmxVaPXqgB2cuWKI0o5ZvlE4nSWH4=; b=KEGzpvPSpYqxVA5TnB2E2Rl4c4IX+f3Ddu1CIm63WUBazgWglBXeEkoUaI/oTKG/WPKF+u9XRgOv8hmk7axWSmhFQ8i/r66KVAbNgW3zmYljmOxPAmUvldhjtCIwDvw3NDLh/gPQHhI990sgKgBT07NXEUfBq5UXlh8SBVbql+c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) by CH0PR01MB6841.prod.exchangelabs.com (2603:10b6:610:110::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Fri, 8 Nov 2024 20:29:30 +0000 Received: from MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba]) by MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba%3]) with mapi id 15.20.8137.018; Fri, 8 Nov 2024 20:29:27 +0000 From: Ilkka Koskinen To: 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 Cc: Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Date: Fri, 8 Nov 2024 20:29:45 +0000 Message-ID: <20241108202946.16835-2-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241108202946.16835-1-ilkka@os.amperecomputing.com> References: <20241108202946.16835-1-ilkka@os.amperecomputing.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: CH0PR03CA0255.namprd03.prod.outlook.com (2603:10b6:610:e5::20) To MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR01MB6228:EE_|CH0PR01MB6841:EE_ X-MS-Office365-Filtering-Correlation-Id: f87746c0-360b-426a-9f9d-08dd00340acd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|366016|376014|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lmj303yfflY/t0VoaDwOAroKT9Pq4AczTxr/WMCkX9vYMpM1gYAwPEruCHVM?= =?us-ascii?Q?ZbieN0waR03yRsAAmeyAZQn7qdWj/ytMo+nIj6HwTpSjbq3KHPagqW8mLF+p?= =?us-ascii?Q?nMrt3DIbH7Pd7DDIVmJpAiFrFSRb7UZso5HXtUYpiUCkwOP/0J/UWR2Bp/Qb?= =?us-ascii?Q?mzQTPY0n4LpHozIQJicW21a5UC22MKCrwzNVZaBUyZvBu3lDjkQIPCp3xS4Q?= =?us-ascii?Q?/t7FLQS9qwY3QaZFlJ2MtDiniSAuOT0GxVafRB966+9W3s3Z5PEGEP+ANxJZ?= =?us-ascii?Q?lkqzWNEvRGLubXQG7RzLxOAGSNzzHKGaGAiMQN98t6W0G4s9SCTiSHIbg9wG?= =?us-ascii?Q?+T5t1+aCNQeon0UesmVuz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ascii?Q?J+KMc7iP30j/ITaCCEyc7xIyT6w/SlryyTzUtPsuXM1dL7RH2u4a45xjVWpU?= =?us-ascii?Q?pdCnFAHL1i5ASegmiOIDbqPP0qfZiFGPlizT7/9rv9F2uwbYfGcC2wJlKQ8Y?= =?us-ascii?Q?MrAyxg/VO13bvAo0ASkG/f/VJza8?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR01MB6228.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(7416014)(366016)(376014)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7h2FL0li/CsbThTsQZ7vkQ6IZ4hmzdBjMF/+JLM9hJOmqkjm1ubEVcOTjDWB?= =?us-ascii?Q?ZqeHkzH10+N3ZeEnfyvoU7NVrCroe3fFNJ2gKXUyWcose9YQZJ3K6Um52lz9?= =?us-ascii?Q?EmdWd6N8UZxUuHkH8O9zwsNqxM2XRpgDcegGewcHnqEGbjrHcu+NDcHGqqLM?= =?us-ascii?Q?N8lvojD3dN9BC6EwIV4GAmt2Bu2wAfkzAUdrmc2Qj84z+/PlEytow+PtjnxM?= =?us-ascii?Q?9KvXnz8OwmnpN3/1g+k4R0NIqLEL4ocz4JuY4SfWSvQHDjAznPn0rDOu66KP?= =?us-ascii?Q?RruBv1d28n1PDXmUVTca68L1sVmAwgIyeX/seZTStjUTuMyUsRWlv27xJceU?= =?us-ascii?Q?3hafSN1axKstUL8W8/yrYBJURAf2P4ZANC3LmiZSTzpKYM22+IVoCZn+jmRh?= =?us-ascii?Q?N5lGrw1ZEL0nWxNKRch9Fob07J3fzA6zGJx1cJd1erFRyKimDTHiSaT3vr6W?= =?us-ascii?Q?5dbFPo4lhxQB6vodXZp1amAFkawa58dK5s+VULsn0JLshmVX9FGBM8x+k3Pj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6lC7GPoxILVWdh1C3Le?= =?us-ascii?Q?NopjhqpDyyQSBwbiqRW9LKpDAjTayLtOv0ONHgf9V/f5Ys1Az2QWicwsGlbG?= =?us-ascii?Q?8PHC3afVDx2pu2RXWV1PRz2TlsmJHfDAROuMue70pf1yfC/4FCe0Q3XsEReD?= =?us-ascii?Q?RqEbFt6oFBj1B9zEMDzuDmCsUVgyvEwCfiCp+IsnACoxTHCMyQ8fAJIho/TI?= =?us-ascii?Q?oIlmxEVoc+KzbXUPmcXWWng=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: f87746c0-360b-426a-9f9d-08dd00340acd X-MS-Exchange-CrossTenant-AuthSource: MW4PR01MB6228.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 20:29:27.6998 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W4Ex6Cz0NvygIb6ocCSKXJ3s69ikDJizkrtbTCgjoh+Grf0prXKY598IsmiD35P+ibh5vU/4GWx3mKMbTLi2RQs4UhnQ9CZq4ruohZ6/gXvlerTzZlxqKrOZNGHo+e2r X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR01MB6841 Content-Type: text/plain; charset="utf-8" Split Data Source Packet handling to prepare adding support for other implementations. Signed-off-by: Ilkka Koskinen Reviewed-by: Leo Yan --- 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; }; =20 +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 =3D range, \ + .ds_synth =3D 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 st= ruct arm_spe_record *recor } } =20 +static const struct data_source_handle data_source_handles[] =3D { + DS(common_ds_encoding_cpus, data_source_common), +}; + static void arm_spe__synth_memory_level(const struct arm_spe_record *recor= d, 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 |=3D PERF_MEM_LVL_REM_CCE1; } =20 -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 =3D speq->spe; - bool is_in_cpu_list; u64 *metadata =3D NULL; - u64 midr =3D 0; + u64 midr; + unsigned int i; =20 /* Metadata version 1 assumes all CPUs are the same (old behavior) */ if (spe->metadata_ver =3D=3D 1) { @@ -592,18 +610,20 @@ static bool arm_spe__is_common_ds_encoding(struct arm= _spe_queue *speq) midr =3D metadata[ARM_SPE_CPU_MIDR]; } =20 - is_in_cpu_list =3D is_midr_in_range_list(midr, common_ds_encoding_cpus); - if (is_in_cpu_list) - return true; - else - return false; + for (i =3D 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; } =20 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 =3D { .mem_op =3D PERF_MEM_OP_NA }; - bool is_common =3D arm_spe__is_common_ds_encoding(speq); =20 if (record->op & ARM_SPE_OP_LD) data_src.mem_op =3D PERF_MEM_OP_LOAD; @@ -612,9 +632,7 @@ static u64 arm_spe__synth_data_source(struct arm_spe_qu= eue *speq, else return 0; =20 - 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); =20 if (record->type & (ARM_SPE_TLB_ACCESS | ARM_SPE_TLB_MISS)) { --=20 2.47.0