From patchwork Fri Sep 6 19:15: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: 13794700 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 13BB3E6FE41 for ; Fri, 6 Sep 2024 19:17:28 +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=G6mCAW33hqgjcgwpBryIP2ae3MxVhnu2w+B9BK9Zpg4=; b=WQpdTgaPeU2IdhqKKl9r6dCg+m Sp7VOWB/dHTrlB7AQm4+KEzYUwelAD+Lo/b56uAOguQUWr0Dao6SwhEiKTFWYfH+z3dEe3kjVwt6l 9JubnEgt8l9aJU5SHjdODmASpqubImQ+T8G/cjdRlq8WAxoZXlz1w/qGY3IXCD8ZZ0Z1jXjit6rZe gmr5mVDeMZkwkFwV1wHzcNlhetL/8OM2scVdq83zeJLPBYbXgPJjRElzOjpVIoSY49V2yxxCjrRTt iNtcIuNZltIf9jZXDDEeV3yWn8iF3Jb27S7UMCgA3Qu4BHOOuri/WwfqWru7yEmP3YGmOAmM+xAQX zfbRxLMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smeSH-0000000DPR0-3UE1; Fri, 06 Sep 2024 19:17:13 +0000 Received: from mail-centralusazlp170100005.outbound.protection.outlook.com ([2a01:111:f403:c111::5] helo=DM1PR04CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smeRI-0000000DPFm-2DCf for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 19:16:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZXu1dCI9HT/Vr32DUOzSrG7Dy/KyWjUk9iL9Uodrxh7qK8G36iXIN1dIfOScpdkBkvjgtBM8Upvow7YJnsjuLCvqP9t8aV41BUwqIEfrhXxWZp/I2Y/IWJ4FV0emF6sT8/Wg6RvkKa9gPfMqlfQ7An/XWIoHII19dzgUzYIErQ6qkYcZZaNfWDPdFO+68HtXea9pbsck+zUbpzXNtsu9ZZCp4athveZfozPORnl2PvUukGWm3opLF/TIXc3lhigUUOcloSXHW/WVTxK95aT0dJzG0OO7ywm1NIx46gcswBwDwsAWmvghM4vbF3uNSRL7OPqV5hhjnY/ZRs6ShlY/sg== 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=G6mCAW33hqgjcgwpBryIP2ae3MxVhnu2w+B9BK9Zpg4=; b=jxvrjurX2Io+40GWnKFaqRdOJkYFuEQUgOwA0EK3dG4JLFAkcIm5Xj9YORfBnkD9L6DDDV7lBvHjtKkJ/t94N75fEj0olGgo4hm0jXVcZx92e8iHH93NGsTrUHIdpqCB0bTubL5XvJ6UngCLJjVcEys49rxYy9YXG5X6LarA0EKxHA5+ldVabIrjP7MuJpH1Z+U36/bW84730d7A9/VQPjTCYASofZtiOaWGfC63HRKIrybhbCoxBvah779k0npOJx0P5ncltHZa5fChqiiUO03lf4F/fDJL4CqtAhJx2oFFRfEnVnPBTtL5LX5F1WOurWWb62vaIqsZgprdjTVQpg== 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=G6mCAW33hqgjcgwpBryIP2ae3MxVhnu2w+B9BK9Zpg4=; b=dP35iIwFRFXZuCJnFP5oaKKHqZtPlQx91bBireXeWGG6ztqcVgKxGopD+yghYqApA+8qGZxcphaKRoPyChOpK0xfrI6hgFzWPUULowD+a1fNzoreJcGM3T4ItLOEl3PMGSnAEnihFaitCyqgGu0aSPWZxLPRHmBqal53QZUQlz4= 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 DM8PR01MB7014.prod.exchangelabs.com (2603:10b6:8:17::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.26; Fri, 6 Sep 2024 19:16:01 +0000 Received: from MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba]) by MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba%6]) with mapi id 15.20.7918.024; Fri, 6 Sep 2024 19:16:01 +0000 From: Ilkka Koskinen To: Anshuman Khandual , Will Deacon , Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ilkka@os.amperecomputing.com Subject: [PATCH v2] perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled Date: Fri, 6 Sep 2024 12:15:39 -0700 Message-ID: <20240906191539.4847-1-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.42.0 X-ClientProxiedBy: CH5PR02CA0018.namprd02.prod.outlook.com (2603:10b6:610:1ed::20) To MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR01MB6228:EE_|DM8PR01MB7014:EE_ X-MS-Office365-Filtering-Correlation-Id: 481a89a6-572d-4529-73fc-08dccea85814 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: AXeKqKDiHQNm0uaOfmO2rNVSJdFPe43m5TX869IJimlXcnLBSyw9l+C7mSoKgzuEzu1F+zz8v96GEjE8h8KmgRUC1QRwr+ZW0DnwNW5BFBVSmgriSgm4eXHVBxtOWw98upqdjEp9JHM9gAC34hWN0Nf4+FmA5p/zkaqDipK5lW4Hah8P7a8yD2PvNPPxQByAsrmnw7YZxbUoCb0LSjIxs7uWQSkDWq+C9DbwjP1LLejKIx6UXYjGeNjkkiJwDOehXffdsVnqm3ge88xfhhfiIVxQkr+LlRnzyYrCNpuiN0ARTMAxYUvMZqruRaPFD4ugMc7X+FJxxAMUesGMv5Ok5wYcdRxvwynOVQYeqQJ0kj7WPgE4mZcQ7HsQQKmLvrN2pJyg3mbNrQfYbn5ynFnwBu5ZmIG7ZZRvrkyDdUoK8DmwcDT0i4K/fLpHIXnQbz8Y3tRZ1TQK8XogZno1XAe1Wi+4HiZ/aROkPZsafhC0thLTd7nFGbLqk64twgiwxUxHtFmEvA0K1pc+x2aE6dc2pCB7+bVGgfclsub1bSYVLdBspwwOrAa/wZuZ3v7XFN5rqzcBTBEKR1vSTVmmZQGnHlW3qqdogevf6/SKSbaQuKkz9+UQOP6wrclphzsmgUOcw1BbUU58HJGaspDeMWQAp5hVZjkjPa8//ksWnwi1BYYhFUATmeQTjShDK/R8mQULAFQgGKubXx7of5W4ztjb5eNlzpkxaFIFt0Amt7mVavc+kRHiBA4RueR8LhHJzt7UjrAWBTLgT1RmYi4NoEmJbOaPO+XHVFiQes9VN9tZ9MoGajuNfaUqmaPXYbIbi/a5/dCUvsC3iQYiN7RND8nR/+j1TI6cugdYi3PHGsAylVBbCOwkuwF8HuzAJ95B7/CrRFAF2hJfxplRQaVarGSYK5fgLBdRUwlfM+e6+A6/FuOAoJvuMbzeHWMAflz++gcHV7xso5YWnzanXQxj1w0yDI31a9mdEgLElxJlFJFRWrCGH/N+9N76+R9yG5ykX43vHKIbcGpQpwS4U3uP3whbN4Chq+UumGM07Q6fzjgFMCiuoqTRo4iAwZW8ERUEgHh2/dFz/A7+3nnApWClIT00Y5o4J7IHvy6Gf7u3/yqRjNO54ZCwALOWyh6zB3n73JHOOMeWiveVMGEQjWFtt6FaitNZN89MF70toWWZ2dWrjKNPNVCRSe5a7XUujiRnszR1FBnrLdy0Tt/UdvtN8e586SrR6rKxanh14GZc5vKvZVY5/SdXIDqQW+mB7eo3VJvsgxCzKtyrnpEz5oWL2rllNBTM+t9dfJ7BtjHUeCxfE57JcmuH/c01WXfYYPItYxn4TxwMp4tU60dL7LcXqWdIi6GBCJO0VpJjgzbjqLhkg8q35db2iKR54Bc2Pj6Y43UHbI7BggY+lVwyYTFWUj5mCA== 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)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YnXtLewCgOU0M+LwqKcTIMuff3c6XCt/o+oSTA9SjRJWI0ecsYJjP0APmd7u+TPIInb5kDbRFolE2alErR6jWyYjXR2jZBocVJTa2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lLEIc7IRDvN9Cj4ib46J2caOSFw+JSq1opwJZG+o5udwtZUCUkD1et7X4jOKr9Qh72jwTVeWomyZfN/jYEeA5RVQ9W15MzSHyzYPC71auRdg/JXIO8FlzMcI+PSau9uQbae+0J/VUzIyO8jLDE4p4lBCpO4xVLgsTcTAMxAB/n/Nbge1LBoDPMMiwGdqOpE/QmY9ilMjkUE7VnCq3LBJrsiovRCWyXytdEB6YRZ0YIV29hRUpwR48Ai+9GBepE5gJGFXUP+GDZlK3OpMZHBJqU55JWuK0MQIdZbD0BSyClt3H5PuS3Qx0j3EeGtJGsIxjN++WFWazhoeBM1csnf731kbU7pJ6ARB0QPTtgPDSotXH/8VtELrqgrzZECOV4OLj+cecXEe8H81H+cKZrXqwqtV5yWZYy+b1nDNUk3/12ePCGrB70r8cu1tLBi9CDL++hOz/Urfw9M= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 481a89a6-572d-4529-73fc-08dccea85814 X-MS-Exchange-CrossTenant-AuthSource: MW4PR01MB6228.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 19:16:01.0449 (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: T/tNSDnGj7vzZagR2Y/LOuzHj5cjAtXFGzPEqF/eRy0C/0i9rcqy3sy4Jh1/Jbs7r8H7nJk+Hb+geBIhKYPKUxM5RmQJlWbF7TyFVp5wB+YGMBtlIF74eGuY7hRraotM X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR01MB7014 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_121612_602276_4F293175 X-CRM114-Status: GOOD ( 11.81 ) 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 The PMU driver attempts to use PC_WRITE_RETIRED for the HW branch event, if enabled. However, PC_WRITE_RETIRED counts only taken branches, whereas BR_RETIRED counts also non-taken ones. Furthermore, perf uses HW branch event to calculate branch misses ratio, implying BR_RETIRED is the correct event to count. We keep PC_WRITE_RETIRED still as an option in case BR_RETIRED isn't implemented. Signed-off-by: Ilkka Koskinen --- v2: Instead of removing PC_WRITE_RETIRED, keep it as an alternative --- drivers/perf/arm_pmuv3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index d246840797b6..f5ee6e2adb30 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -1089,14 +1089,14 @@ static int __armv8_pmuv3_map_event_id(struct arm_pmu *armpmu, if (event->attr.type == PERF_TYPE_HARDWARE && event->attr.config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) { - if (test_bit(ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED, - armpmu->pmceid_bitmap)) - return ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED; - if (test_bit(ARMV8_PMUV3_PERFCTR_BR_RETIRED, armpmu->pmceid_bitmap)) return ARMV8_PMUV3_PERFCTR_BR_RETIRED; + if (test_bit(ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED, + armpmu->pmceid_bitmap)) + return ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED; + return HW_OP_UNSUPPORTED; }