From patchwork Wed Nov 6 19:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13865503 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 0D37FD59F6C for ; Wed, 6 Nov 2024 19:41:03 +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:References:In-Reply-To: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:List-Owner; bh=ZaoqbpkRgrgy8PNxBKuexzT/HltuIpEhApRiHOA08to=; b=vE4BQ91RxJeW+epVPYzvner3Ek b4muPeehwSlYOzPomnoasr/xzh5G47weCLivGXsMnc5roHyk593kP/WgdXrYxwjZ5BgmlQK7iH5hR RRrvfQf9yYxToQQXk0YL0s207V/iBgVSMwDtCY26Kdr36JOH2P1VJB4hsJxl82+TcIpgkQZLaPtFL XkJFTbjKsxrgUUQyPovYECXPJQY9ZXBueMEhDcq1ybe7mg0hVlj+DMF+0mIdPczM+8Dkcvu15yyJO 17/0+bfAPiZJHyl+U9SVkJFvj+bLv6kLr6jlIkSb/6BVtoLaVYNaa2FNV9Mj4F0ut5uOTxSZ6CAeB 96P9QSJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8ltZ-00000004YV9-2DKV; Wed, 06 Nov 2024 19:40:49 +0000 Received: from mail-eastusazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c101::3] helo=BL0PR05CU006.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8lq6-00000004XZC-0bP5 for linux-arm-kernel@lists.infradead.org; Wed, 06 Nov 2024 19:37:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FG+aJlUGIzP/OnBbB8uMHj9ZscPTHhoMq7mPvogjA/BRwcDksrYsNHybxOhez5HL32uiiEjmsbzLYmE+HIBV+uEWSzW+Hey2dYoJysLBv/BoC1rNJyFSj4NwR1AZAYE183VdMTUi84TEe4oAnFrCJRe9XZfOvlFCmg5TVtnYz+wHionOgpxkboCx4aFJIHfH9zIcMxwEI5iysIBbqdpHEHRLJENZAwsnXMJzFHqlaJ/pF7CrVdC4IK7/2TXEte1ctyDpPE3cqbyNmEzsTS0ploUgAPmopFHTuubHxvxJZLYDfM4VnzNpG/lZPWGVKp7FcWGiG7GQ5JAGx5MH1XN7cQ== 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=ZaoqbpkRgrgy8PNxBKuexzT/HltuIpEhApRiHOA08to=; b=TOYZa0HbB76JLJfkZIEiV45Yjqj+ODdNjVWeJXDmteJjbMvTEQTYBUqR6vNCcae72XOY8tGDZNbn8bsF7WYRYix+1rQORkyDXzwawqfdjkEXRMMspIRYJOuM9/Drbjx2FW/JyAd7t0zFmjgRuBXorXK+Xjt2UGptLIBoT7MQ0lv00P33+2o+pva7CbDG+hXFL6TnzaQhYpdgUxRdHJI6UjCsiPT4Ct0ZnNXMwGRFqsZzetxww7DypQF1fDCPEtI60OYIzHoo49RCmIJuDo8bLDqUnDvpaaHqEPB769t3RdOhZjI33rJPYzzppjA9yet6dE/D4RuBeubUi+DKknTwwg== 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=ZaoqbpkRgrgy8PNxBKuexzT/HltuIpEhApRiHOA08to=; b=lDwgBQed7JjtPlE1DT0Jl8htkp+zYLDyZ+cDY4ohyiM49ToyK7v5DBrprebOVXtAFnUSCLFl14p9qyRzvpvu6wI/PbvMLdG4XlbDcRlynnuFv44vZ0YIQi2W6XCt/sWjWjKcVPs80oIosSxKG0SOnOwsUhZLIbCQdLr4nax8VCE= 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 DS1PR01MB8775.prod.exchangelabs.com (2603:10b6:8:220::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Wed, 6 Nov 2024 19:37:12 +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; Wed, 6 Nov 2024 19:37:11 +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 v3 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Date: Wed, 6 Nov 2024 19:37:39 +0000 Message-ID: <20241106193740.6159-2-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106193740.6159-1-ilkka@os.amperecomputing.com> References: <20241106193740.6159-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0332.namprd03.prod.outlook.com (2603:10b6:610:11a::9) To MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR01MB6228:EE_|DS1PR01MB8775:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c076ac4-b768-47d0-da02-08dcfe9a68e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|52116014|7416014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: ZsBmUxGYXVDbExnXaRPR2a/9ATpn04n5V5riDbBnuBcFZwwuIjSxhp42VVZbOWyut5V5SHBYeVnCO8nACGkjjpvTJNPNjss/4/ZRjfwJ8vB37iRECn4nm3Z/1sIBVbE22Hjt5TTsC9rpG41N67KaHG0mpIQi6Gk980N4xO1LAH+a7b9dsFpfA8/fUnJRO5G/WPBNeWPBQ001ov8qBRc5Z2o1aI20rX+DE8y/4fEo2oDguBH/ZeZRR/4hEZxJm3h03ymzDamQxVecNptWhxE5VL++Y3A3I4aVCajKuSo+f/9tmCzFui5X6JXFUW5FcdIga34/kK8F7TbVhBOtsA5W6nijQJQQdhu6ltmcWpyiwgVHpGKu7v1RXaAyNyzleSYcbAwyAGCxecbgfR0R7+mrH2po3vDkqMH5wJAvCd6JcvodkvzQp9e4d33sljA25NzU6r/ZyVhB3Nf1ZvcG93NgwEfCfzazqruYClYKs4x7nJD/7AkbKsV4pvpDLqaXLz2WeQ/WJLQdpm77cAMBm0MT6uPKVDslLvCxB+YNmTVoaqolHhKEd9Z0Dp6mqbzHoqNfefCTERTPY7YEefJVkNtuvHUM4EfIkWER+BP8drGI+tgEIL8U61jXy+X2loDBTpD8F5lalchxlsRPeOWwecqIYhdPB4rmGF/zK4pkqiPSLpizeS5d61dPwyudO09ZftRHwxfsEkZn1c+rulloLmzeSYQYmuP3BdG8t9WPmyIW/ys4baNCquRcSjh7gsT53Gojd9t0MynB0wSMv1EzpaKYgtyqnK/CnK/fsOi4RVmPzYl+1AJX+mSUV+n9Du2erA0Rmh4SzyIAFj0Zp2BrBi5iNEDdESiKtt4NK9RBUOUMFQ3xXDi4fwi/Cjue0a0okOfXwYKsXgQXjPr7cAhYVR3kPAf46GoBpOndV54Y4XoVA2ZF0a/GXeQoT19PWRT6pBWR14bC0M8Ix8/0giYkQj2No+q4uxXcshElrl5SJFub66rvWTLYG9PlVML/ZmNLZlCsIRyjw+IocX7oBMklHE7QFadmWSQKhTVDft1DDBtXe7Jjz+lTJAOEoWs1IBtdZRLMS0bRzlJSb2s2tp0qPn9S59tQ92hGlGCasVJlkR04cEuEWD7/OsaSdcz+CiT1eZx4u2XeHiGqVCw11N61eXkF4d97Z3DBPFhHQi7e2oWVZa/nC23gP1nQVU/6tVol9NA3aGxlXSeFODcejPPhcmNB7R1j2Lvl0j3cOm/LM5c9lCuQh7GFtUcWgZJF28ntCoPjxZ8ZLHI/nybCbEnTS8+q5+01hDrSKeiPchjV/Rf0g3IRr/4iAzsBznoqO7Uda7dUmvVCO+ioYjHk7TBMWg3kriZHzobOrVDQ3ziojpZKYh6hjy4jdOD6cpqAS5qThqGP 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)(366016)(376014)(52116014)(7416014)(1800799024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jXQozLJJaJfBOgJvMQEPUMDXNUepqApUJNKBVsf2Z8tBjNQamm1jvl2JsqQMM489hTd+TkYomL9TwaoMEgFgA1rVgZkWUJDjrHpxZzcLBua4zynQAIvHBtPRR0knJfxrzzMBeFTMpk9OYqKkTccNhLIUhU/xW7oArZiWkWGz2pJcD43QURbcWqSClqFyScgGynLWVCPnDZ5Lwod/5fkV1hk9A8XT3gG7H/MjTWGR3s0RXFCGX/kmeCkxOkjRdzUaBC4OdonhVWtjRw7tB7fYKQYuTgDh5C2bjMpDB+XWUInuH1I+H7V8fzIkI/abVcLYaGFvwZRFtj4IvtGnXafSzK0IMvSE6PuHgWOKGgheTr3CyoZV+VhANdMkryZwQud+JGzVfvxtBXRGtuIcy17MXTOPSLo2g2t5vQw8zLUVOo+qshnP5K9LxAKVLuFuimfJLJPyEEwiNRZNprlthyKYkXaolnYGep9mClHjdoSlxxIUN4SV1N2BMf6rh5Cw++YaygMmXzfnMNStMnO7PQeVBGp8usdWaUSbsGsSKswQ+LbJAh8bwCvHd+wiJHpxDcnXkD9ukGaPbs/ZecElFD4h2zX4qulbBRrjMjC3+ZTa2BtCw3rBOQFB+r4yTwns3qlev8a6Qpq7e+5QbcqbwLiY= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c076ac4-b768-47d0-da02-08dcfe9a68e0 X-MS-Exchange-CrossTenant-AuthSource: MW4PR01MB6228.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2024 19:37:11.9162 (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: 5408EUNlU3E6NjDx1+gqA4jKX8mXoTKaI2z9PjyCzFslCNIXSdwewDRUZVSCBVBWn824h7m/OtNjcT7YSQTRNBblyJ2W051G+KRk7tJB6fnyeEtVSIY2HbZ+N6HjlxKt X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS1PR01MB8775 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241106_113714_214390_DA7A8D8E X-CRM114-Status: GOOD ( 16.50 ) 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 Split Data Source Packet handling to prepare adding support for other implementations. Signed-off-by: Ilkka Koskinen --- tools/perf/util/arm-spe.c | 65 ++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index dbf13f47879c..b222557cc27a 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_src { + struct midr_range midr_range; + void (*ds_synth)(const struct arm_spe_record *record, + union perf_mem_data_src *data_src); +}; + +#define DS(range, func) \ + { \ + .midr_range = range, \ + .ds_synth = arm_spe__synth_##func, \ + } + static void arm_spe_dump(struct arm_spe *spe __maybe_unused, unsigned char *buf, size_t len) { @@ -430,19 +442,6 @@ static int arm_spe__synth_instruction_sample(struct arm_spe_queue *speq, return arm_spe_deliver_synth_event(spe, speq, event, &sample); } -static const struct midr_range common_ds_encoding_cpus[] = { - MIDR_ALL_VERSIONS(MIDR_CORTEX_A720), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A725), - MIDR_ALL_VERSIONS(MIDR_CORTEX_X1C), - MIDR_ALL_VERSIONS(MIDR_CORTEX_X3), - MIDR_ALL_VERSIONS(MIDR_CORTEX_X925), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V2), - {}, -}; - static void arm_spe__sample_flags(struct arm_spe_queue *speq) { const struct arm_spe_record *record = &speq->decoder->record; @@ -532,6 +531,19 @@ static void arm_spe__synth_data_source_common(const struct arm_spe_record *recor } } +static const struct data_src data_sources[] = { + DS(MIDR_ALL_VERSIONS(MIDR_CORTEX_A720), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_CORTEX_A725), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_CORTEX_X1C), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_CORTEX_X3), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_CORTEX_X925), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), data_source_common), + DS(MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V2), 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 +567,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; + const struct data_src *src = data_sources; u64 *metadata = NULL; - u64 midr = 0; + u64 midr; /* Metadata version 1 assumes all CPUs are the same (old behavior) */ if (spe->metadata_ver == 1) { @@ -592,18 +606,21 @@ 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; + while (src->midr_range.model) { + if (is_midr_in_range(midr, &src->midr_range)) { + src->ds_synth(record, data_src); + return true; + } + src++; + } + + 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 +629,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)) {