From patchwork Thu Oct 24 23:30:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13849837 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 63AADD10395 for ; Thu, 24 Oct 2024 23:32:33 +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:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=+hN8QfXyhuY0m0xRWFEfnuXb9HpzW22lnsxd10IUIcw=; b=E9L8j0MNpiqJ5IsM5YS+IROkDY y/nLljHxbJSeSDxtlgI77WM5VKtOwQf6oGTd3Km2Q4G9TYkRn7OhQI4sNSDknCJZZUv6dVyRQd1fh IhWOP+xJIz5jLrjVUXKC/ltw7kV1n8OiTYltpnL9b5ZLkrTGy21VwwY1WqMeaX3MAY7mVWVB+Cf9d ynxPw9FlhrnwyFNz0YayeRBGYhBsuxgMPRJ36vNZQY0zmGsVJYZxcuXhnC4qSUZggKBASkvg4nlLM RuCBxUcgNgLFfxYh3duKU0Sd/y55MQlvXQ8oqQsIMFwCuPGQEZF/uZMb07MRfXG1+ytcQl2EPG0FF X+JJYEiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t47JN-000000022Ah-2H5s; Thu, 24 Oct 2024 23:32:13 +0000 Received: from mail-westcentralusazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c112::3] helo=CY4PR02CU008.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t47Ho-000000021zY-2IfD for linux-arm-kernel@lists.infradead.org; Thu, 24 Oct 2024 23:30:37 +0000 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 X-ClientProxiedBy: CH0PR03CA0341.namprd03.prod.outlook.com (2603:10b6:610:11a::18) To MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) 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: JKQ7vwsRbM+wh/Alf0jhzM+qQTOpn11vz4Fo+HAK5z9zuO+V4bTGvILv9VQ329100tFvKs37WIVUplyY4Uu5g3VVTbU8TyEWmn9QjZfGnQ3cGOuTdyUC58zWFGSTJ2HbX2XHefBAQJjDDXWxzLM5FZUS4mp1P6ouMKvrL3N/XFVCnmr75gbjlGyRgF9NnnalX5G6Z3WN/GkLPi4EDEnUUJaWyKFNXMpNHyeSKO3G1XT82Dh2vnbGh0PA7KgnYPMNWMxl0gkcy2RMKZ/HkKQ4cQXhU9XL1eETmrBGSccywyT+MwTeVq202yzZc/EAfas5z14E2+NrysIF7x+PixawtRIKrK/QBZOD2iSKKJJ+0RkL3P3JtlZ37AevuQeVobgw9Piqo9PkuIGz2Nl/Mb1tBxbRrQjKlx8odZArBupAoGRnWu1xE6IzR21ewVbbNPaxjsRN/cXkK1XV1otykoqFWPBNmjfGE5Cfurcb7HxUnb3pKUtKPuAunwQuBCS1bUOEUgGXZcfRg31wlajR7GPdIdzYn0uRx1/IB9xTtWjXTPsXIfw14ix5b2Qj7gF1ignxZL4FjxPjCNlKFDjNst8VxUJF+A1jteRVrsyVTmYfGL9rVWLx3MNzC8E2V1pip1vWtsVluREzmqIjEA6U9k7Rli2D+2dE0ZX8p0RtbslrU7cm5ovV24YildsXXSEESnl+md8n2tm+95FuqmCcCKgdx8seYkASvl6GfZqKDumiyb2BCtTSLuvvOjB+LxnyCPBmVNZsVZp7IvdKIpSwIDW+3i+/C2VmMXKPq/aYiAmpaACKT212os6+DI8U+aiumf8XE2aiSLiFL6qVX71jaglBfcjZjMLnjPD0PD1KZzQSUOaLMx2e2VgRKsvrGFyh8zlttnlXeu96yQ0zwFbD1di6JKu3TCopFDoCeRYLWd5wLYSjAE3dKj89RpaWVuFnbapYUDsFmQlRpCS+PV7hjJ+a+PMAGLwFmaV3U+ryzD39k4uxOAxBi7AtDO6h7hmn6F5gBC6vF4YgBUpDZjOTN2byYZQfYvJWKyKHZ31tOkEVOD95k/1uAf5Q4c58Ts0D8jQIks+0v0rf2YseGPKbwLo5OrBGz4h3pkrhf7bMRsRQi/FVAJBXzCJKkISTCk57U4E9QL9qpSk80xacTAhZvCLuwPGETO/Xw2RHNWIwkNoEpQ70KLr4fZkI5racbjcHNAsqXRP3JQ+AAJtLctUAgtc9cUlpJH5Q7tyxWOMODszp6dqa4homSIxnlhrv9XljV1mIp3X7LnrODLzx1YZjzPkc8TpPppZudV3UuW/rFeCfVzW+owvfpV3ycFm9zfAnUTXJvb5zaVw/sUi7stV0lXhXN1NzNyiMh8a7G3grcFg165d+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-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3bIvWJBFBZdzQ8vcdr+w8t0XcM/2yG8ERKgwaTz1hoGhuIGQumaD5z8AA1LbTCEPlSNsMo5ASxyFb3m9XylZuWzHKAa5McMOr+Lvlu2r552Ou+u+rLQtvZaESSzPAlH9Ernm7o6LNFLK/sybaoBapNRxoLBYT31CHgA/wDFQdIuWFqyxOnhOCcA2FRBApRbf9tsEOe55VUi3/sHpEoDEi4Qo+c8E+fRK736HmAOVWjAxl0PcPMcOwhbNSS4jzto1+shSAgoFfrG4UYIzGA0fxHAkxdjc1GeL5+XUPOjJM+jkWvA+nF2p6cKFYI46Dsf48KINRpeyz8j5gnzikYVCTSFhx3S9j+i8DzbW1gnwSWw2GxHQBaGZkwgl3DvnnSdVep3k4Ajhi1bZ1Ln5/UPniRKnclYQ1rn4yy3irngiF9MEp+sJd+IOZy3VuNR8JPsCslhue8HSyIZww7TiT7oFUhW/qKhpiDKTiPSVgF+0rB3WrF6DLjO8d6Mq/FCxcFnYQ5nsPN2No7n3GQpWReVQUs2iau1lEmRHFQX0Vvw+BiKp80n7OE336On+7g/fXBe0/5JWM= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241024_163036_607831_6A4D6313 X-CRM114-Status: GOOD ( 13.20 ) 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 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 = 0xe, }; +enum arm_spe_ampereone_data_source { + ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE = 0x0, + ARM_SPE_AMPEREONE_SLC = 0x3, + ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE = 0x5, + ARM_SPE_AMPEREONE_DDR = 0x7, + ARM_SPE_AMPEREONE_L1D = 0x8, + ARM_SPE_AMPEREONE_L2D = 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 |= PERF_MEM_LVL_REM_CCE1; } +static const struct midr_range ampereone_source_spe[] = { + MIDR_ALL_VERSIONS(MIDR_AMPERE1A), + {}, +}; + +static void arm_spe__synth_data_source_ampereone(const struct arm_spe_record *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 = PERF_MEM_LVL_NA; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_NA; + data_src->mem_snoop = PERF_MEM_SNOOP_NA; + return; + } + + switch (record->source) { + case ARM_SPE_AMPEREONE_LOCAL_CHIP_CACHE_OR_DEVICE: + data_src->mem_lvl = PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L2; + data_src->mem_snoopx = PERF_MEM_SNOOPX_PEER; + break; + case ARM_SPE_AMPEREONE_SLC: + data_src->mem_lvl = PERF_MEM_LVL_L3 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L3; + data_src->mem_snoop = PERF_MEM_SNOOP_HIT; + break; + case ARM_SPE_AMPEREONE_REMOTE_CHIP_CACHE: + data_src->mem_lvl = PERF_MEM_LVL_REM_CCE1; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_ANY_CACHE; + data_src->mem_remote = PERF_MEM_REMOTE_REMOTE; + data_src->mem_snoopx = PERF_MEM_SNOOPX_PEER; + break; + case ARM_SPE_AMPEREONE_DDR: + data_src->mem_lvl = PERF_MEM_LVL_LOC_RAM | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_RAM; + data_src->mem_snoop = PERF_MEM_SNOOP_NONE; + break; + case ARM_SPE_AMPEREONE_L1D: + data_src->mem_lvl = PERF_MEM_LVL_L1 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L1; + data_src->mem_snoop = PERF_MEM_SNOOP_NONE; + break; + case ARM_SPE_AMPEREONE_L2D: + data_src->mem_lvl = PERF_MEM_LVL_L2 | PERF_MEM_LVL_HIT; + data_src->mem_lvl_num = PERF_MEM_LVLNUM_L2; + data_src->mem_snoop = 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 = { .mem_op = PERF_MEM_OP_NA }; bool is_neoverse = is_midr_in_range_list(midr, neoverse_spe); + bool is_ampereone = (read_cpuid_implementor() == ARM_CPU_IMP_AMPERE); if (record->op & ARM_SPE_OP_LD) data_src.mem_op = PERF_MEM_OP_LOAD; @@ -529,6 +588,8 @@ static u64 arm_spe__synth_data_source(const struct arm_spe_record *record, u64 m 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);