From nobody Mon Nov 25 20:38:58 2024 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11023122.outbound.protection.outlook.com [40.107.201.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 A2DF5167D80; Thu, 24 Oct 2024 23:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.122 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729812632; cv=fail; b=awmUF45zXbUxS5qURkqU3OJOdfEaRnetS9cYrvLoC8QXOoaiZcMJ6+Ccx7rwyfXQZSlSecWZltcN/dF3bR3iKB/4s0cxbq2YweRZGcjbFhNx8mRFHXKvVJickcvmWFeWy+7M5YTB1eVSZSfwDb9rCL3apZWTRi39fdlHuF2ElCk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729812632; c=relaxed/simple; bh=MoSxv7KAT3Gldn5Hk84/jas1RiRkQ0MdmE8e4Thv6IU=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=eH0NByubEsiCsQPt2aMhqR66j8cp3p2Lg3hEgwchj47lMvREFgNt87SgqmV4yNQwF9mWVKW1rRyjcdAwt7RGpN7Br+s8Lj5iZGnxQJ/Lh7totzuI+2MQ+njNU0W9opPHShwb+KP5nJIDjUypsycAcf6TrF4Xc6w+fsoXW/gHK7w= 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=k3gapNdy; arc=fail smtp.client-ip=40.107.201.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="k3gapNdy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EjDIkGdm+gzYPR2CnTI9xIqvx+VbY6k8ZscapcmvxWGilwr8xfin8StxjTgGgJ37dtMahL+H0dfIyZa833xzRCg1FhaZ4/8izL83RWqv4TniATkTdWG0bttwVKwgmpBqQZZjhvCEsjR19OEcAXZveQhgAKtVyox0lT5hqwmz3dQSoRTPySpgkGCadMkKg8fHIafsXbyqOUavoPw58wiu8EcbRrm3218zjbHzqIjvx0ovK9UlMan4zuZK9wef2oCHx6uS29aFbwtIH7UoWsp0HYwC//kdVjgjiEy66ChJ4CVzY8jweyvXZ1Pt7f2TW1lXfXgDl8+nLvZ+JexTmnV9Ww== 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=+hN8QfXyhuY0m0xRWFEfnuXb9HpzW22lnsxd10IUIcw=; b=WCPMM/eGtiWGJn9sjdRInnMhmceLMIZXSH+04wa5jilCz7DyOoZ/Y3+2/Rj0xFxZWHwr8fMMTTKnrBpIWL6PXr0M6yynDgW2AmUn/DWi/Kaw0/rO3kOG0GQMX/kvpd7xmmGyIBHsahKJW5oeCAQWmSmYzHnuveoXzJzFhKLReo3m/O2GJUafC5eDSz+8rZnqw3n828yoDhtcfFhNhfYueDtHyMyvhqtINesTPKYlvnOXMGc88UlWxYPWWzVRviuotv/niC28fDs6LT2qxA/JasdLBfeG0rFV7sljLjuNM8idMSZ0iCkeILPw3X9+1tqUg+oznTql3kndrVOrx8Iy2g== 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=+hN8QfXyhuY0m0xRWFEfnuXb9HpzW22lnsxd10IUIcw=; b=k3gapNdyNNkQL585by3dIS6Q4Ir+Sp8qvm+yYFnEmsW5BFyH0FRXGkyScVBKdEgDV99sHbop3diM1hJXgXukqbWa4LSjVibt1axyOdm/8YIgxXHXFMDaGLcECs6YX0/xjSZ9zDSlZgZDALfsH4aeDtQy2EZOROwRzJHwzceC0HM= 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 CH3PR01MB8315.prod.exchangelabs.com (2603:10b6:610:173::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.7; Thu, 24 Oct 2024 23:30:21 +0000 Received: from MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba]) by MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba%7]) with mapi id 15.20.8093.018; Thu, 24 Oct 2024 23:30:19 +0000 From: Ilkka Koskinen To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan Cc: Ilkka Koskinen , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] perf arm-spe: Add support for SPE Data Source packet on AmpereOne Date: Thu, 24 Oct 2024 23:30:35 +0000 Message-ID: <20241024233035.7979-1-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.47.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: CH0PR03CA0341.namprd03.prod.outlook.com (2603:10b6:610:11a::18) 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_|CH3PR01MB8315:EE_ X-MS-Office365-Filtering-Correlation-Id: a94bb584-9c03-4051-6e60-08dcf483d29f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JKQ7vwsRbM+wh/Alf0jhzM+qQTOpn11vz4Fo+HAK5z9zuO+V4bTGvILv9VQ3?= =?us-ascii?Q?29100tFvKs37WIVUplyY4Uu5g3VVTbU8TyEWmn9QjZfGnQ3cGOuTdyUC58zW?= =?us-ascii?Q?FGSTJ2HbX2XHefBAQJjDDXWxzLM5FZUS4mp1P6ouMKvrL3N/XFVCnmr75gbj?= =?us-ascii?Q?lGyRgF9NnnalX5G6Z3WN/GkLPi4EDEnUUJaWyKFNXMpNHyeSKO3G1XT82Dh2?= =?us-ascii?Q?vnbGh0PA7KgnYPMNWMxl0gkcy2RMKZ/HkKQ4cQXhU9XL1eETmrBGSccywyT+?= =?us-ascii?Q?MwTeVq202yzZc/EAfas5z14E2+NrysIF7x+PixawtRIKrK/QBZOD2iSKKJJ+?= =?us-ascii?Q?0RkL3P3JtlZ37AevuQeVobgw9Piqo9PkuIGz2Nl/Mb1tBxbRrQjKlx8odZAr?= =?us-ascii?Q?BupAoGRnWu1xE6IzR21ewVbbNPaxjsRN/cXkK1XV1otykoqFWPBNmjfGE5Cf?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lXhXN1NzNyiMh8a7G3gr?= =?us-ascii?Q?cFg165d+WCcnilGFXwtkzN0onN7q?= 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)(52116014)(376014)(1800799024)(7416014)(366016)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?QQVEKOEnhk5QdX+b1X6dq2h20Hvcwhp2h9+Z+C73+V0NpHdkM2ZY+n3byoIw?= =?us-ascii?Q?KltfPVM/uTlPmhy3QizsaEchX1tXhUxiI9ZCERlAfDhW/idEIrv7aPyWHn3W?= =?us-ascii?Q?5KsEd19bou1ZLYMwsL5LqZt2ec/LFk1olW+Yg9NBDWlz29gqyDpm1E7RGAV9?= =?us-ascii?Q?kCPuKlxJyZ26XGfREuHzg7LSk8gh8SR+eEyHUPXsYN5SvnknY6iQ7Iv4vP7z?= =?us-ascii?Q?qYsyVHh7HcK9pQYpaIqRo1sBwC9IX694b9DR1AgtHoDySPQPERzuXZVGlicj?= =?us-ascii?Q?k6wsyuPS/r1j8YGPn4EHrday2a+EFF1A48JjUQvAyxjJtwt2wcxAuIRIg8yU?= =?us-ascii?Q?fHhmBy0kf3J65CtkxPxfCpAAo1LTBg5nK0QAE6Yz3CsA6rMm5Z/t8wQov7eU?= =?us-ascii?Q?YI1hFE+Wd3K0O1np5ljkWv4tgJ6dmyv7sqM1NaJLeFuhF0i2e9/US97j5w0i?= =?us-ascii?Q?GJNKYIKugYUlCIfzjqZdXLUT5hV14LQFk/YhSafk8SyVpJHMIueSsg43nXcH?= =?us-ascii?Q?pexrXsYu4DmQfSwL8tJgAwVW9mD6839oeyALywkekFDSTI6jFGMmvCvDe0O3?= =?us-ascii?Q?U5akf+m3b54WapwLHtZSjLzI//8qkIyzFc3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y?= =?us-ascii?Q?3VuNR8JPsCslhue8HSyIZww7TiT7oFUhW/qKhpiDKTiPSVgF+0rB3WrF6DLj?= =?us-ascii?Q?O8d6Mq/FCxcFnYQ5nsPN2No7n3GQpWReVQUs2iau1lEmRHFQX0Vvw+BiKp80?= =?us-ascii?Q?n7OE336On+7g/fXBe0/5JWM=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: a94bb584-9c03-4051-6e60-08dcf483d29f X-MS-Exchange-CrossTenant-AuthSource: MW4PR01MB6228.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 23:30:19.3439 (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: tSN1dRD4JlIxSBthso5tALsNrcsfOtr4iGBmoRMiS7P0ATpB9r6NahSklOcj2w1FC5CvfC0t6igHAD3Y9Fccd19tYdJS63jI3Y68jfS0rdqxGH88kbgnU2O+emHLo0Fy X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR01MB8315 Content-Type: text/plain; charset="utf-8" Decode SPE Data Source packets on AmpereOne. The field is IMPDEF. Signed-off-by: Ilkka Koskinen --- .../util/arm-spe-decoder/arm-spe-decoder.h | 9 +++ tools/perf/util/arm-spe.c | 61 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h b/tools/perf= /util/arm-spe-decoder/arm-spe-decoder.h index 1443c28545a9..e4115b1e92b2 100644 --- a/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +++ b/tools/perf/util/arm-spe-decoder/arm-spe-decoder.h @@ -67,6 +67,15 @@ enum arm_spe_neoverse_data_source { ARM_SPE_NV_DRAM =3D 0xe, }; =20 +enum arm_spe_ampereone_data_source { + ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE =3D 0x0, + ARM_SPE_AMPEREONE_SLC =3D 0x3, + ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE =3D 0x5, + ARM_SPE_AMPEREONE_DDR =3D 0x7, + ARM_SPE_AMPEREONE_L1D =3D 0x8, + ARM_SPE_AMPEREONE_L2D =3D 0x9, +}; + struct arm_spe_record { enum arm_spe_sample_type type; int err; diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 138ffc71b32d..04bd21ad7ea8 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -515,10 +515,69 @@ static void arm_spe__synth_data_source_generic(const = struct arm_spe_record *reco data_src->mem_lvl |=3D PERF_MEM_LVL_REM_CCE1; } =20 +static const struct midr_range ampereone_source_spe[] =3D { + MIDR_ALL_VERSIONS(MIDR_AMPERE1A), + {}, +}; + +static void arm_spe__synth_data_source_ampereone(const struct arm_spe_reco= rd *record, + union perf_mem_data_src *data_src, + u64 midr) +{ + if (!is_midr_in_range_list(midr, ampereone_source_spe)) { + arm_spe__synth_data_source_generic(record, data_src); + return; + } + + if (record->op & ARM_SPE_OP_ST) { + data_src->mem_lvl =3D PERF_MEM_LVL_NA; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_NA; + data_src->mem_snoop =3D PERF_MEM_SNOOP_NA; + return; + } + + switch (record->source) { + case ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE: + data_src->mem_lvl =3D PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L2; + data_src->mem_snoopx =3D PERF_MEM_SNOOPX_PEER; + break; + case ARM_SPE_AMPEREONE_SLC: + data_src->mem_lvl =3D PERF_MEM_LVL_L3 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L3; + data_src->mem_snoop =3D PERF_MEM_SNOOP_HIT; + break; + case ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE: + data_src->mem_lvl =3D PERF_MEM_LVL_REM_CCE1; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_ANY_CACHE; + data_src->mem_remote =3D PERF_MEM_REMOTE_REMOTE; + data_src->mem_snoopx =3D PERF_MEM_SNOOPX_PEER; + break; + case ARM_SPE_AMPEREONE_DDR: + data_src->mem_lvl =3D PERF_MEM_LVL_LOC_RAM | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_RAM; + data_src->mem_snoop =3D PERF_MEM_SNOOP_NONE; + break; + case ARM_SPE_AMPEREONE_L1D: + data_src->mem_lvl =3D PERF_MEM_LVL_L1 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L1; + data_src->mem_snoop =3D PERF_MEM_SNOOP_NONE; + break; + case ARM_SPE_AMPEREONE_L2D: + data_src->mem_lvl =3D PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num =3D PERF_MEM_LVLNUM_L2; + data_src->mem_snoop =3D PERF_MEM_SNOOP_NONE; + break; + default: + break; + } +} + static u64 arm_spe__synth_data_source(const struct arm_spe_record *record,= u64 midr) { union perf_mem_data_src data_src =3D { .mem_op =3D PERF_MEM_OP_NA }; bool is_neoverse =3D is_midr_in_range_list(midr, neoverse_spe); + bool is_ampereone =3D (read_cpuid_implementor() =3D=3D ARM_CPU_IMP_AMPERE= ); =20 if (record->op & ARM_SPE_OP_LD) data_src.mem_op =3D PERF_MEM_OP_LOAD; @@ -529,6 +588,8 @@ static u64 arm_spe__synth_data_source(const struct arm_= spe_record *record, u64 m =20 if (is_neoverse) arm_spe__synth_data_source_neoverse(record, &data_src); + else if (is_ampereone) + arm_spe__synth_data_source_ampereone(record, &data_src, midr); else arm_spe__synth_data_source_generic(record, &data_src); =20 --=20 2.47.0