From patchwork Fri Nov 8 01:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13867383 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 59A23D5D695 for ; Fri, 8 Nov 2024 01:12:27 +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=2Lp1zyDQwLkVqbaOZmQccSLK+0L8r2SK7hhIgVY3E50=; b=Qlg6H0TzrxMleEzhigYLS5RK+J NPYi9GD0aGyrfPGL0GS+/7Di9oACxncG2cTNLVlyO1mpRH/4tEWu84lkOtsxE2Am6uXkuDMdrj2ht Bul5tUxWr6X4NdNMUFpP6BUGquD8TdFIkBbM958VhMJHJhp5Zv3KdLkPAH1ghcsfY3FDzmUiZGgKy 5KlXlC0jiKxAFHMwJ/2GXnbPOFaNHmPFHf+GYDy7F06PQikgX51RCTwt+XXZtkgd8HW37UJRUuzoY bLBKEpIHNITs/RtL+PNTRLxpewjeLHm24lX0dT2fT3/PvMYZbS54LcsTl8PHbPg58Uhw7kV5rp34x Us9PLRgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t9DXr-00000008u4M-3Dlt; Fri, 08 Nov 2024 01:12:15 +0000 Received: from mail-westus2azlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c002::] helo=CO1PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t9DUW-00000008tkE-3qdi for linux-arm-kernel@lists.infradead.org; Fri, 08 Nov 2024 01:08:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F5Fhj8hdbPvKM+47fE7nRw15nQuIO3yAmRd2wSEsu91qCFbJmMg9rYnSOMFD2H7AwCozKetT2x1/iSdQrf6newBmy29iaFChsOf34RzsLkDqh3UB6061VGcCk+4cEaHaw5X4fW+NpOL/ZH4jgIcmOnO4Oz+GNzG1cDxoHa/yweX9aV/ZJ94EU7y5fA9EA+ksu49Zl1SoKOPa823HWvDigeC5VKBmpA5K3rkjGRD3+JkR8lro6bM3hc12Pp90yJTN/Lspc4MzO4x5BnUcch0GdSSEt6xtjatw8JEIIaeDDJI11Rzlk97CptPNuBlYy87XK191+dzKug8K/qAdEKyuZA== 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=2Lp1zyDQwLkVqbaOZmQccSLK+0L8r2SK7hhIgVY3E50=; b=mtavcby/75DNf2EhJcwC6s3JfYHfg7gTLn8PQnuoqMEvMz64lXEeKDRegjJ+IjvfT5lJMbd/StZYCl5KVU745e7B8XZsRN3thEVhXo75eDeN9FH1Ox9g47mSoJuXJgzuGJAFXWGtRRer3qpLE+HdZWl8nnHEylKe6I/tRGDhrNaBK2/8xdTwxk/HiqNCB63/MxYKP4i9j94ruSnJf7Am+0b81WOcAb5s1uSBRqObxaSkhj2fOoO57awTA12b7OHSa2BNo1h9+mmemMP0bProHk+josFiVwHt9HxnbBzogmtHjN38Mgg3qtrbx0npqt1jMRxjRMckG6y8itYbeRPU/A== 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=2Lp1zyDQwLkVqbaOZmQccSLK+0L8r2SK7hhIgVY3E50=; b=jtXA31u6ztT1ZrUvIfHst6a/rBFF+5gtPNlfj3cuIza8C877RD46bwSLDaNjnvIIoigB4nSrPl0emk8gABg9ROxVk+RYjHLs75UaaUgNoCYa5XW3IvEUTvmDQS8Y8DagjA0Eh+wr1DCXY/ERY5YaH+qpF0jIvnFzT/Ci9Y0Zn6I= 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 CO1PR01MB7385.prod.exchangelabs.com (2603:10b6:303:158::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Fri, 8 Nov 2024 01:08:43 +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 01:08:43 +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 v4 1/2] perf arm-spe: Prepare for adding data source packet implementations for other cores Date: Fri, 8 Nov 2024 01:09:10 +0000 Message-ID: <20241108010911.58412-2-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241108010911.58412-1-ilkka@os.amperecomputing.com> References: <20241108010911.58412-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0366.namprd03.prod.outlook.com (2603:10b6:610:119::12) To MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR01MB6228:EE_|CO1PR01MB7385:EE_ X-MS-Office365-Filtering-Correlation-Id: 88c7d393-e480-4935-8ad8-08dcff91e370 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014|52116014|38350700014|921020; X-Microsoft-Antispam-Message-Info: B9fAJNDQZJM/DXiiB9+JAZZ/KalGsSvxqTRWtTEgR2mIxgwehOfG4KHuYEpNBQvg++b6P57MyMd6axTThAflFT8cyEMxp2eV+X00VmiAq7BIyNApgf4sUQ4raI2C59Un5emQNOH9rnrjXbVXt2U397N3gtNy0whab8jYXN9kSkhXPbD/u9fLZwkOuqt3jp87+32Q/b0WBvnpUhZwZUkS7ED4aGty9a/KbSCZrC8RrJBTvkPIptDAXZbCzqNGvnozPJt9ilpzYZjGVHBQ/NzFf3kI2g1ILGAmQmObxH7fXD5zHaDeG9cFw0tfOAv0+YCME3B3C1c7b1TkcsCFRHSRPmWgJ+UjfROGDIABFdw2rWUZF9abaKBdiyT+WXs4g1uhuzhfhrOm7vHLcvqUi/2cjhoV9v4hoWIjyAKmrYXf07w//i8Hp0//F+EYXhQgaPrClnZMdDtD9SYwnvqQSNHAWn8vRM58onCCVA700Sp0wQSE1RQx0O8tqviTn9APvc5FIaDQW7B29dX7CYp+UvGc2lyCNm2ANYjUDtopyOUqUMRx/1DgUfSZHxBPCy1fYK/65+oOp0e/sUNk3GK8dIrq7jg7To3r+bmsFAKcHTCM9qH9A/5a8rdkKWRUtzjQFZ8JOBq6iTwVL+SvIavZRjsH+wkWz3XUeB3u5MCkplEQfCiHIOXBN/Leym7ez8V9eSi7+MOJpGf4pFQUHYRSCUWt+bAEu3QgAmTHabYgxc+uE4kJKPI408RX74Fe6kmW4ZKsFhSJUsMe+QAzY4t8jQrt9qMADQzDSU3rvDw60UoH14CFUXTPSVPgDzRsaQM7r4XTs6A4RxjPkySTyEf5yKJ9eaz/elEEnolEJXDNEk9WlM9BNLR1iQhmH7rcE0eM3LgphlnImJ4tlKVWP3qQCny9vkXzUO6W42/Wqjo2LCappwI0eBE/yo2kVt0SSjbwTg0GtXSSds60GcQNcvf28XaPRb6Cbo/jiUijkBoSSIHSSBSvPufoutSO1FndlplPjO/EXbThodKqkSQ78kSY+xf6j8WbJ0nUZXegsxWrpvX3o1y3ZV+CuJEdkLuYSc2dZVvhRu7Ub6M6/eqbw+gsZw8wwhD4aOny0Mb8eqJnbM5vpFmlRfEBtiS4+CBVnYGHAlzjgHwavpz0ItxupZKQKeRlGfUvIxYzIar2QDCTXPXNk62ytHjOA7i4CK+mGlg5BLfsbr2RbJXzCKs9xA7l38OA02LqBxPslHAH4ZREo+CEnwaUtskL723fGT9J1FmMNkxOwKxSNLrTqO6tFKk38f/eg/KvAV3raex5j+dbCYNLuq1qnP7D/1e+vOcdIXdr21UlTskZZv8L4VKh3LmLm2OhHtuoyvsjczZQaLJUWhjQ7UwIYvUieTDxCUdPPHLiwtb6 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)(1800799024)(376014)(7416014)(52116014)(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1DnwJaTAHWLevawMEDRjsPdarAR2mzX+BFPmo2FynzxBfzAVg+bvxYoBBrHjdgYny9/sl3zueBZfRy+uT7b5IcEYXAJLrsmFVybuIfsv9eN13zAQbT/dVks3s+eOJtHz0sLu+Wx+xNXF89QOczYf5nxwqBAOwcvdOgpIu9kvfYbL4IXG6DeR/0PmaoLc21y4K/xDgqYT8zYRQGa2L5GT6hJMAgL2QomU+OIvXtC7gi6/lnMyq+1R+OoCO9UORwBVcJnDTzQIl6RjulxzkZo32xaOqy91mQBPYTdVPRYOGeLtF6N56z6CoTuOWi6TTo51XK1+qxKpElYIv5bD/nB8AdX1qnxfgmPFFULNxV7blIRr14NrnbthRPukjA22FW7oOk2l/CHJnfz4rrK9NukwxzLaSWIlmRy/YaxussR8A5sjfGXgSSW9PmbnpGQ0g2+U35hwnmKfQNyal31GoaWjNklgb4SXNnkkqXB34ot1MpMcfPPXL0S3GxVpdt70G6cuLE0REuKuDx3T8GqpGecviO+/7Kdm4dOPuT2a5lN8HUQ8pCSXM1KQtF5afn2OTCvoLRBxckyEe5xIuvjE4uLjDfFS3aAa3wzr2l5efcI1AnSVakKiSqgcaTAhAK+4gNldGfMj+dygTxmpgPTwI= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88c7d393-e480-4935-8ad8-08dcff91e370 X-MS-Exchange-CrossTenant-AuthSource: MW4PR01MB6228.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 01:08:43.2271 (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: iBlkgr8/TEEvQaLIIca+6X4kF27KvuF8XdvfGfuVgUTQoSs3ew5B4POJGtjyx4ldsmVlAKJV2LCD8d/iQDKuob8MV/uqOxfzJFoflJJC8riOjlIzv1Q3vZECiGuV565G X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB7385 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241107_170848_982545_F5033DFE X-CRM114-Status: GOOD ( 17.05 ) 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 | 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), +}; + 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)) {