From patchwork Thu Jul 11 10:24:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812192 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) (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 5995B158DC0; Thu, 11 Jul 2024 10:27:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693632; cv=fail; b=bsVRkCyXRBbcAFH55LION10gR5dbegcvGgQiaH/JkWlPP4VrN4AX48mFDAc9bRD80JPWL6k/YwniVYobM+9mvrkw82As9QbeTKA5lU4ocIcewe9xqBLpbKcIWgTuVm2lBSUpPLFd1Gr4dkcD1eCZ6c8iljfiO5UxoZQj9lGBYoA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693632; c=relaxed/simple; bh=bdSf84gGt2+ppfupKPnT53Dz8c8Prw7bUBSUOhNtm3k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p8PMrznmJqTFhRO3ZhsRwd3ohGwa2LumU5WO3YcvFno9PEsagoFC2l1oaVKsk+p3I9XzYXxtC8FdJlsaxmj7ScU+rfPia+9eOdqVgPb7Nkyc0hGcMYpCHOPqhnTYTfD0sXB5MMvMm9EUAqUNR2JAZMPMgby3dVevH0UHq0CjaiU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=HT/6EPti; arc=fail smtp.client-ip=40.107.237.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="HT/6EPti" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UhqYgrHsIdyCa/+Q38Ylu0QwSAa48pYQ5HSD9A25ACRVIsuWogUp2i16ZuhFZ7BR9Didq8q3//Z7PVJ3OdgVrNWZNjuOr1KIh7Fxrv3R4g3piR3lpT91zixhxh5mZNRM6YWgiJOryk3/ISvZsLebhqt0OsStCfozWIdmrSjAgRNWb8AYk1dLz8Hiw1zJoAd6SRg5dUJL50bIX4rl4veHldNI70sQeKz06YhrQ0xRJCSugJvUM0DnxqSBEu2MQqVh8PPv9EDRY5D85dnCr1T9G2944hkNc57zJxS8HpYn7wxWtryrLY7jbMgwbXOKq2AWY3Mwm71w/nhT7vIUYrguPA== 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=4VB0mnWMAMkAvDfdiuyx2za+lkYjWygNVTD0XXerRk4=; b=kv91LRROX8Zoi7ZyM46Y5uqsv/ZDmdkasSWmuFD9Woi+ppKn15GvmYfm0iGvKi8O+E3Zw3zk6+X3qHdGRVenWuZDPvyQjXkMXbKcbvkzxwFWqyoImX9aSP+R4KIJEaNlvOI8jgIMoRMs6e0xDAoqmxPJkoCnWjKekRQz7SWbjApex0JrbwK7BuzmL8gaPwpFLjE4mSfSkZb3pU1ZkMqMHn2XMeJOaPLW8APbg02wMDdhKHw0OeEPRw3OnpAJvPFcQxHT6m4bCupiw/nDDe0E3oIjBbWe5pqkahtIy4nFWbHcXaQ6GQAzmz2ZGluF7a6KyRoCdw/1NDM2i10gmFaJJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4VB0mnWMAMkAvDfdiuyx2za+lkYjWygNVTD0XXerRk4=; b=HT/6EPtixFuHlomlGjo02Wf2r//V8UwaJYMZ1iezPoDBOaO37ORHib/P/ifWN/Z3+K9oiLWYi2G3ddeiilhLkoa9HL1NA4yDWBuRsAv3Ncsx50poeIu1pqOGxaDWIC6Fj/SR5mmH0w5PNp2hmfx11WRTgce7u0/uF3P4yK0OeiM= Received: from PH7PR03CA0015.namprd03.prod.outlook.com (2603:10b6:510:339::19) by IA0PR12MB9048.namprd12.prod.outlook.com (2603:10b6:208:408::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36; Thu, 11 Jul 2024 10:27:07 +0000 Received: from SN1PEPF000397B1.namprd05.prod.outlook.com (2603:10b6:510:339:cafe::86) by PH7PR03CA0015.outlook.office365.com (2603:10b6:510:339::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Thu, 11 Jul 2024 10:27:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000397B1.mail.protection.outlook.com (10.167.248.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:27:05 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:26:57 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 01/11] x86/topology: Introduce topology_logical_core_id() Date: Thu, 11 Jul 2024 10:24:28 +0000 Message-ID: <20240711102436.4432-2-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000397B1:EE_|IA0PR12MB9048:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a641676-d6e0-4471-0716-08dca1940330 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|7416014|36860700013|376014|921020; X-Microsoft-Antispam-Message-Info: 3PcR446S6hVNtbDqZ2gsU+KKfrBlQ7GoeVGKjHdjlt7nYQsOIpia1hO5C94innWd6BXUwKST47xfJG4OvYR3LINvfMsBzN8XjaCkJ2AvLa3a6Bsy1GTi04KM8z/qA5vJ2/+qMfQqXzxcSu9PCgcSsQyurek1m+S8kF58y5ibxMXQ/ykTnqsiqy/4ITMP98VvctwLNcUkLic4wB6CjHr5ZFF8mXFJubSlA87ZVCO9mZO1tCodj7Wyva2dQ3jbdLo3KHMlO7OxOXw/M6uGBZklsT0+Jjk2X22OqlZf2C/OPo9BLpzkrtM270ROIiIA7vITAKA9j9J86KQM92pre4lzJG//q6nj8ucaNagOMpKfd16kk2PGZNS9/63iHJDTy6cgFvWPmr4Mt0AVz8Fp4vCDdwVtcVHtI0fNmPGtGLh50G0KtDOfjnYFMGn+VdDR6tQI/Y6hO26WCoV5KWrU0/B2ddmNg0maV5gp1cZYq5F+axjDhSAEnoHfORwuwL3cuBhCw+OB3AF1vKUGdIYlO7xftPA5At2ySc/AbU3w1dgSOHLe/z8fzKQx7U5c2UkFt+q8LqkSUGk8cfyzGMNP/1Q7Dz4GmAt1HNKglnWx6FF0RCiqOURml357xMrOrYxRlcnk4ND4bUTC3E/6Byq3R5hkC5FwJeLfebmRMwXHIaISni/WtRN7a29NYtYknlpriw42JmUshtcRmxGtDu+GTPisgQSvEtQIy5n5f0O/bp53p8q1Otvc2ZGdYJNr96arrMepF2ad2zxAVnx1HkRSvIEM0yrkHafbwCuCazuFWss31kClgNqc3QQQDiVKc3mo/YBdlSVcPUpuoQTko1RtDVHmXEzgoScu6nkGVi9rOTZEELVThTTIP1/j7vhsfAasOyNNN5KYhpDaEahMe1oFVp9HYzd+oMl8N1qrDdBRXoEfSaQRiZgDJ86EnM7grIkiS6q/jYCV9JHEHe9p4XRagY9DxJWDiRLCFaYrleqkkU+QblFsFrWyhUG2Ojyh0ELykAMqIpT1SVcV1FZ++fv55vlev+PairrsMnIQ9LahFI3P0lR2X8/dcYMObTgIjatogvRAjAgTvXWH4pdqDGhHVtD3neGL0NorJtwDNGLPICMzsKCxLwc6Gkvhk7nFIIq65zqcZhBLSPvfySgcB7OQijvDtWyMwRdhG9SiNRfbg7w5EATlAjb/q5wif2QIKH04k+r/GFIQgQ+jNyBznyrMF7/sFpJx3xm4z4UbttXzZbRt+mvCwLDnYy4EgsP0SrRchjwcKdwQMJ5VNLuYhLq67FsCUhlCobeqAI55HGIN9wI77nNhYE/6zpuPIbAFF80AkN8wZTcHkccCsLlG6ThBYHv0X2WjATJxuLXf6BoMXFe7DNQlpSwZp5KvvxOf1rKyjjjZyUtYTqDXkB5piIpRj8Yp0PTX5LCKb4O9OPIWbjADSzZzuhdOcK9MzserP1IaYzzQMNyoYvM7a5H6/8ZbeDj/WA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(7416014)(36860700013)(376014)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:27:05.8134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a641676-d6e0-4471-0716-08dca1940330 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000397B1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB9048 From: K Prateek Nayak On x86, topology_core_id() returns a unique core ID within the PKG domain. Looking at match_smt() suggests that a core ID just needs to be unique within a LLC domain. For use cases such as the per-core RAPL PMU, there exists a need for a unique core ID across the entire system with multiple PKG domains. Introduce topology_logical_core_id() to derive a unique core ID across the system. Signed-off-by: K Prateek Nayak Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- Documentation/arch/x86/topology.rst | 4 ++++ arch/x86/include/asm/processor.h | 1 + arch/x86/include/asm/topology.h | 1 + arch/x86/kernel/cpu/debugfs.c | 1 + arch/x86/kernel/cpu/topology_common.c | 1 + 5 files changed, 8 insertions(+) diff --git a/Documentation/arch/x86/topology.rst b/Documentation/arch/x86/topology.rst index 7352ab89a55a..c12837e61bda 100644 --- a/Documentation/arch/x86/topology.rst +++ b/Documentation/arch/x86/topology.rst @@ -135,6 +135,10 @@ Thread-related topology information in the kernel: The ID of the core to which a thread belongs. It is also printed in /proc/cpuinfo "core_id." + - topology_logical_core_id(); + + The logical core ID to which a thread belongs. + System topology examples diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index cb4f6c513c48..1ffe4260bef6 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -98,6 +98,7 @@ struct cpuinfo_topology { // Logical ID mappings u32 logical_pkg_id; u32 logical_die_id; + u32 logical_core_id; // AMD Node ID and Nodes per Package info u32 amd_node_id; diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index abe3a8f22cbd..2a6dbf965d92 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -137,6 +137,7 @@ extern const struct cpumask *cpu_clustergroup_mask(int cpu); #define topology_logical_package_id(cpu) (cpu_data(cpu).topo.logical_pkg_id) #define topology_physical_package_id(cpu) (cpu_data(cpu).topo.pkg_id) #define topology_logical_die_id(cpu) (cpu_data(cpu).topo.logical_die_id) +#define topology_logical_core_id(cpu) (cpu_data(cpu).topo.logical_core_id) #define topology_die_id(cpu) (cpu_data(cpu).topo.die_id) #define topology_core_id(cpu) (cpu_data(cpu).topo.core_id) #define topology_ppin(cpu) (cpu_data(cpu).ppin) diff --git a/arch/x86/kernel/cpu/debugfs.c b/arch/x86/kernel/cpu/debugfs.c index 3baf3e435834..b1eb6d7828db 100644 --- a/arch/x86/kernel/cpu/debugfs.c +++ b/arch/x86/kernel/cpu/debugfs.c @@ -24,6 +24,7 @@ static int cpu_debug_show(struct seq_file *m, void *p) seq_printf(m, "core_id: %u\n", c->topo.core_id); seq_printf(m, "logical_pkg_id: %u\n", c->topo.logical_pkg_id); seq_printf(m, "logical_die_id: %u\n", c->topo.logical_die_id); + seq_printf(m, "logical_core_id: %u\n", c->topo.logical_core_id); seq_printf(m, "llc_id: %u\n", c->topo.llc_id); seq_printf(m, "l2c_id: %u\n", c->topo.l2c_id); seq_printf(m, "amd_node_id: %u\n", c->topo.amd_node_id); diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/topology_common.c index 9a6069e7133c..23722aa21e2f 100644 --- a/arch/x86/kernel/cpu/topology_common.c +++ b/arch/x86/kernel/cpu/topology_common.c @@ -151,6 +151,7 @@ static void topo_set_ids(struct topo_scan *tscan, bool early) if (!early) { c->topo.logical_pkg_id = topology_get_logical_id(apicid, TOPO_PKG_DOMAIN); c->topo.logical_die_id = topology_get_logical_id(apicid, TOPO_DIE_DOMAIN); + c->topo.logical_core_id = topology_get_logical_id(apicid, TOPO_CORE_DOMAIN); } /* Package relative core ID */ From patchwork Thu Jul 11 10:24:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812435 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.45]) (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 553B3158848; Thu, 11 Jul 2024 10:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693692; cv=fail; b=CmnfD4pOeOZ2GZSkrdpJPWdqDXsnBeAJykd8X75nguufZJ1f+qv9UUDkPXG1Ox2hELh+6ufZo7SODAOeJcIjwIJMZ2Pe1ntlA2yv7pHg6m3CrwhsT8t0xnYLMcEn/2NXuE8xnyt20uI0YyP8iESBts4K14ACZIYWIwyLiMZGbms= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693692; c=relaxed/simple; bh=tc3Q859CSwhKHx/BLwIc/LmdIQWtI9bBgazGP2E6fys=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JXITEXeF8zXOCp+7MubkJJX6hHeQH1QkPJ/1/I2I8XH3jlFP6gHsLfILVI2MVe2M/gcM5y2696tlWPDpu8U45sR2s/zHLSNPUfoaOTvdSFU43K7r6caiXamjsXSXXZ0FoH9FwmBeI67KlY36SgFv0yQmT6QhZMvA59rczuY60K4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=gJAWRbRK; arc=fail smtp.client-ip=40.107.92.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gJAWRbRK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LCuiNsRQrZh9iBaQdgct48aPKxTnO3KlgQeHTJcLorQ4hCb46B8YLXE8+iBGhz2/NmrigDRu8v8jp3gotBpLB6y34IKZoF+zUTS1OcAXgMbO8bwGSY97jQS7ktrk5PClWZEreXADEomkM3Qv0GwngKrISp6uhpOomjowt+bbdjkFHJeNUP36lCJM//zFrx81Ku7ggLD/dlAHQCEjflgzB84/cfjNsRh6Jff8vEAX1fLthnHikF2ZRihFlEzZy+2cA7q39iOSEGqfkE8ZUlMabetkFqvE4fm/5MNlJ//iwwSvVWDCMlaqOk+8daetzlZymSFwlfg9eAtGPe+uDSn7XQ== 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=Zjo3XaldyVDUq39KrnjoyFEf3qPrAenby5GCwF8FBhY=; b=WwrIAopiwEjn2NX7VwAo1GkMICgv74bC2b1E/ujjMfsCk+sYuFqkigi4xwlT5Htf9N+k68CmEl3KRglyhvk6m0U71pBk2Z5P8Y8w7jCP5aj+VeEjHiZCggfQoZnaMQqmR+LFjVbmFbh0BUcFhFtPTMaYmGbDNuqOlhIdCew5sfW70MPk6ohMBkYAf7I2vlDbcEGq0sNDuDTz9W/OTS39Iz7sgtmglCxdIno9clyDZg+v38/TMV50nauUK8b0h5Inw3ceBtUoeYiY27kdOC4ro945ODn3DbcNKYbuZTGDoE5/gi+CVqLhdXbQI0ZdTgm2afGQwmq9CdE2JCXfVipUmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zjo3XaldyVDUq39KrnjoyFEf3qPrAenby5GCwF8FBhY=; b=gJAWRbRKUXb8jE0mmkfE8vyw/aRi5/129ek4DeTN2uAnCF65SE2G4Lu+LnbOuiEg5mHhvqz6+y6g00GgD7YSbj6Bt8PbbM/lR9+AIcO/tM6MG0kRAOKqRSdwj65ufJDPFz426/rYQ1KuqljT9ACJ1IaxM9hWJsCJFy7ZUgRp5+Y= Received: from SN7PR04CA0106.namprd04.prod.outlook.com (2603:10b6:806:122::21) by CH2PR12MB4102.namprd12.prod.outlook.com (2603:10b6:610:a9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22; Thu, 11 Jul 2024 10:28:07 +0000 Received: from SA2PEPF00003AE8.namprd02.prod.outlook.com (2603:10b6:806:122:cafe::51) by SN7PR04CA0106.outlook.office365.com (2603:10b6:806:122::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Thu, 11 Jul 2024 10:28:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AE8.mail.protection.outlook.com (10.167.248.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:28:06 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:27:58 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 02/11] perf/x86/rapl: Fix the energy-pkg event for AMD CPUs Date: Thu, 11 Jul 2024 10:24:30 +0000 Message-ID: <20240711102436.4432-3-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE8:EE_|CH2PR12MB4102:EE_ X-MS-Office365-Filtering-Correlation-Id: dfcaa805-a401-4356-9003-08dca194274e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: /Gab+ywB1rdV73grQys8/AxaxgjwUdruts6j2oiPzWmQfwnucY9GtyHSmLQLH9h9IIBnPTH9IgkKUj4G2aEaesJvokPVzgvU+Zw7FgEvoO3x2Gomf7Cd9JPCuTDEI9rGec+WgHPPRYNe4oIFoHO3uvtnHoGjji4b/DLYxll/WV/iv9Bu2QT6CJRA3TfE2TgTsv69Eu4W35pmIl21Mh/Tr8VEmSscYuTn83OauPmEnwOtFImqHWYKww9SU5Ayokp9ZV4ctbazzJ8Ctn91fWlJ8E7RS7vBue6ed6awJ8ZVIErD2pY66Wxu+LRYD3CZvJKQ5oAP+ylTCqYCEFU+BMQ0BnS91hOEOoLyNALKnPo2QLfitJBLI2YTRU6oHWrtl2i6TqSd9t9j1v0OqYcHKtGbmGLtzJzOcVNpwsrPBwQ5cgibNtWhXUlqhB5Zt8v9k4jR0QK8lhTogLkvVAjLd3ym52pVzlKcKt2E4rnkgH4b5HPIZRIAWwQZGENP1bNf2nsjvjGbZwUQKlnfCFCAl0GoilQJLkuuAMmYDjQKdNyKUXt5Vsc8uBjTzdz5i0MYD7cnY9JAhMIDgWMa7zgQWV7maZFC9XnytXeLKfos9Sz/eshldzUj9gLmXX/9YeJWnlr5iymgJy/praw4oU2CyQ1iL1H+hbumW5BnQ4e6NCLNkGRwm3tQ5++F8G8FQsw4z579cB7NSPsqH3qAUzchxTFA7edH1GeVTsNxs/tzeOa+S5HTFzBGj6ECNh7epnP+a4NdSEBdhPK62lNXEfklMc8MI+WxgBcjnFmY/DpLUumhFO6R8ZhmcImp9h/LjAXpeIrec+J/qAxS1H8fW2tH8T2lpgj+bia5FzeN5IRsWTNKW2uTZtvN5m0Ns4MlqQX5jkpgJIrHgMKouaL45fPh7w7Hu82KZuuRlv7jS3c627sYxYMycfQDnZsc8E4TIR/1DRJm5/l1GaUE2x3qCqZh7XrOAuivLrRI4ulTuja9kjk4BR+5YKGR4HoPy5QUwNt1QAggETdw7hVAyf/jydx6gvX+4c4eles78lwCOOyyF3gzTaOmlsMoBqOHEKepT231kzJ/wnn8Dg3n47CRRXoUfqLkE8P/zY8YR14MoOBedcIsO9fCazNq+VqOQgh0oCaIsrb4dEBdREAcpvZhT/FuhTF+UjxGq8yHuGfp1fgZmV4M0nbswp3geENmeddyQo6lpimSek9nizlujIkjOU65Nf39oX8hyRLtAej1Qf8iKlYypAjyEgfWovurA/FYwqwL9r6hKQv/CbK3xCs3Zo1c3BBxlRQt6hgbKxFBncgpUCtY69ubA/HjJZtT9nucjTt458+Ntm0BEUOi68sf+eF3p2DnUzToqDYbhYtDit6T1q5CvBIAQFqAOVfBSPMH7Njkl5D1+npHn/Z9HdqNUvee1pF91olzzintgOZK59THtOCBCfjyOLwLWChGq+E2TJHsedyCj9UK7hCjrm/+r8wvSkFuvA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:28:06.4115 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfcaa805-a401-4356-9003-08dca194274e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4102 After commit ("x86/cpu/topology: Add support for the AMD 0x80000026 leaf"), on AMD processors that support extended CPUID leaf 0x80000026, the topology_die_cpumask() and topology_logical_die_id() macros, no longer return the package cpumask and package id, instead they return the CCD (Core Complex Die) mask and id respectively. This leads to the energy-pkg event scope to be modified to CCD instead of package. Replacing these macros with their package counterparts fixes the energy-pkg event for AMD CPUs. However due to the difference between the scope of energy-pkg event for Intel and AMD CPUs, we have to replace these macros conditionally only for AMD CPUs. On a 12 CCD 1 Package AMD Zen4 Genoa machine: Before: $ cat /sys/devices/power/cpumask 0,8,16,24,32,40,48,56,64,72,80,88. The expected cpumask here is supposed to be just "0", as it is a package scope event, only one CPU will be collecting the event for all the CPUs in the package. After: $ cat /sys/devices/power/cpumask 0 Signed-off-by: Dhananjay Ugwekar Fixes: 63edbaa48a57 ("x86/cpu/topology: Add support for the AMD 0x80000026 leaf") --- Changes in v4: * Invert the pkg scope check in init_rapl_pmus() (Peter) * Add comments to explain the pkg scope check (Peter) PS: Scope check logic is still kept the same (i.e., all Intel systems being considered as die scope), Rui will be modifying it to limit the die-scope only to Cascadelake-AP in a future patch on top of this patchset. --- arch/x86/events/rapl.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 0c5e7a7c43ac..df71f38ad98d 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -103,6 +103,13 @@ static struct perf_pmu_events_attr event_attr_##v = { \ .event_str = str, \ }; +/* + * RAPL PMU scope for AMD is package whereas for Intel it is die. + */ +#define rapl_pmu_is_pkg_scope() \ + (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || \ + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) + struct rapl_pmu { raw_spinlock_t lock; int n_active; @@ -140,9 +147,25 @@ static unsigned int rapl_cntr_mask; static u64 rapl_timer_ms; static struct perf_msr *rapl_msrs; +/* + * Helper functions to get the correct topology macros according to the + * RAPL PMU scope. + */ +static inline unsigned int get_rapl_pmu_idx(int cpu) +{ + return rapl_pmu_is_pkg_scope() ? topology_logical_package_id(cpu) : + topology_logical_die_id(cpu); +} + +static inline const struct cpumask *get_rapl_pmu_cpumask(int cpu) +{ + return rapl_pmu_is_pkg_scope() ? topology_core_cpumask(cpu) : + topology_die_cpumask(cpu); +} + static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu) { - unsigned int rapl_pmu_idx = topology_logical_die_id(cpu); + unsigned int rapl_pmu_idx = get_rapl_pmu_idx(cpu); /* * The unsigned check also catches the '-1' return value for non @@ -543,6 +566,7 @@ static struct perf_msr amd_rapl_msrs[] = { static int rapl_cpu_offline(unsigned int cpu) { + const struct cpumask *rapl_pmu_cpumask = get_rapl_pmu_cpumask(cpu); struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu); int target; @@ -552,7 +576,7 @@ static int rapl_cpu_offline(unsigned int cpu) pmu->cpu = -1; /* Find a new cpu to collect rapl events */ - target = cpumask_any_but(topology_die_cpumask(cpu), cpu); + target = cpumask_any_but(rapl_pmu_cpumask, cpu); /* Migrate rapl events to the new target */ if (target < nr_cpu_ids) { @@ -565,6 +589,8 @@ static int rapl_cpu_offline(unsigned int cpu) static int rapl_cpu_online(unsigned int cpu) { + unsigned int rapl_pmu_idx = get_rapl_pmu_idx(cpu); + const struct cpumask *rapl_pmu_cpumask = get_rapl_pmu_cpumask(cpu); struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu); int target; @@ -579,14 +605,14 @@ static int rapl_cpu_online(unsigned int cpu) pmu->timer_interval = ms_to_ktime(rapl_timer_ms); rapl_hrtimer_init(pmu); - rapl_pmus->pmus[topology_logical_die_id(cpu)] = pmu; + rapl_pmus->pmus[rapl_pmu_idx] = pmu; } /* * Check if there is an online cpu in the package which collects rapl * events already. */ - target = cpumask_any_and(&rapl_cpu_mask, topology_die_cpumask(cpu)); + target = cpumask_any_and(&rapl_cpu_mask, rapl_pmu_cpumask); if (target < nr_cpu_ids) return 0; @@ -675,7 +701,10 @@ static const struct attribute_group *rapl_attr_update[] = { static int __init init_rapl_pmus(void) { - int nr_rapl_pmu = topology_max_packages() * topology_max_dies_per_package(); + int nr_rapl_pmu = topology_max_packages(); + + if (!rapl_pmu_is_pkg_scope()) + nr_rapl_pmu *= topology_max_dies_per_package(); rapl_pmus = kzalloc(struct_size(rapl_pmus, pmus, nr_rapl_pmu), GFP_KERNEL); if (!rapl_pmus) From patchwork Thu Jul 11 10:24:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812191 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) (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 A787F15884B; Thu, 11 Jul 2024 10:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693714; cv=fail; b=MVZqmzdhmrD6Jkj8PxFNOcieNfxdKkysYkAjWGB/vB9L7pyRZ8fYvCocml0hV7sBNBwUazyfBPehNPh30QY/RLxIx/S8Y3/+xynr8frD80YmOM1d6oh6VBtJiQtMxa2gitAHFVWN3CImZ/tFNmBnk2jHHSDuacRTsvGwAqslKus= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693714; c=relaxed/simple; bh=xTBlUvYaEIIIGYJV0fVDx9dMMuSyz4NabjTP1bAYJAo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E9C9cXNGE2AbOqzAQciG2V83V4awIVyxY8lVCVL8moj7zE20oo6o6oNDmbfSkX32/KwpXcKx+pn8ezMCYZkWwE5tS2WqSIH8E3uprrH6oN+abcGcrmtfUd77/11p/cCB+3r4jPciG2LO4A3JS7cvi+1TJ3l37tFU8A0o6aysmZo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0lrLyAu3; arc=fail smtp.client-ip=40.107.243.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0lrLyAu3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X5U+/bwqbtS4hmvcKTU1bVaMP7oEdD9GK3YSh3HIZ1LU45hO54yiI4e6eJfHShpZ/zreW7O0lRF9IOfSoGmBkM+ZpPHTog18ChUj/4yxAFisp52Ru7bAv+DDFz2vL/8izUVMsQRaoXdd+80qK8FZw1vtWqW+4fnuYG+YfG6i+M7xBbUXlvf3T4qvXhuKtCX2RpAEmfjkKieozu0gvE5sVEKF57zN/vA2b1DlO6xo5iYgoaL4dGb1PmftNYNNOW9LRS3CclLMZLlPfoV1wsQIFdVazL+8nHS374KCHAcQF8Hg4IPvWVzZMuopuUKo48Pfl7QPE8IIrTSeSnK3o6r3MQ== 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=RIPhj8h4cQiIYc0jDEwV0VDQenk3gExjAwQTQlQcimk=; b=ipqK2vPym0wxfAihUOK6c5AJz2hLYxlnmrfwne2LWX+/ghulwZHFweGCadHCFzJ5XtCDyVJg6NP9ic5JYnVY3DjZxj90YACCmJzpJJ+U/Pfqg+vwYFAkjjnfnQnA05geJGWq57sJNSLK5ct7PhEaGJ7j8U/+jfypq1s2sSGLnYA5/Y1EnS8NAANYlZTmA6wyrSGLuhMPvLv5x9QNbNKxx8pCJgYqzKE5zjrQBUgQrjNDDS8OBKV5aahNlN5BipUHJWVlhOQEYe6TnbSfRco7jBuDOYy6yNR6rtWDinIIetJfDE0kUlIvwb+nhN/EVY950MR1dDKQ1mWwr0GPL49GOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RIPhj8h4cQiIYc0jDEwV0VDQenk3gExjAwQTQlQcimk=; b=0lrLyAu3GuxfGbw+SuPtXtyM7PtqSZo/MkX8EIlFPy673Chug+fQ045PB3T2nnVbSF8Sg2NQC8i0bRxqtSl1VjweOZ9eBauQDMLdBBAIX1v9EtGUXvIfgj3+5VKBMx4ljqD1amuFCXVUqIFW9EypIWQ+EP7/6qBOQGajwm9Nr+Y= Received: from SA1PR02CA0011.namprd02.prod.outlook.com (2603:10b6:806:2cf::28) by SN7PR12MB8129.namprd12.prod.outlook.com (2603:10b6:806:323::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Thu, 11 Jul 2024 10:28:27 +0000 Received: from SA2PEPF00003AEA.namprd02.prod.outlook.com (2603:10b6:806:2cf:cafe::d0) by SA1PR02CA0011.outlook.office365.com (2603:10b6:806:2cf::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.21 via Frontend Transport; Thu, 11 Jul 2024 10:28:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AEA.mail.protection.outlook.com (10.167.248.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:28:26 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:28:18 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 03/11] perf/x86/rapl: Rename rapl_pmu variables Date: Thu, 11 Jul 2024 10:24:31 +0000 Message-ID: <20240711102436.4432-4-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AEA:EE_|SN7PR12MB8129:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fbcab8c-05f6-4653-1c96-08dca194337e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: 1l+Eho19HR5ArgE6EqX8t/9tB6leb09I2p44C3P9uTxEUJcErfwonbXizUH9oXC+//5dK6za3tP8XRLwU1fhIfm64rVxvfj04lHBFXn7al+Dkg1H6XCPzsaCrxqNEXZcVKG8TM2PVreLnhlzC9Dqz18dsJVQXkVqlH+qFwmfNZKeuuO3mp/K4PCXMHLg0JvXN+ewuOsO+g6nOGrQ4f7XKr7l29+mz06zQjTRzbuQO1yJMZ6zyCOoPe9dKqxGSSdav9OZ3RkXBA75UnmxMT7/SibRFhy0bkAEm0ioE/mrUNW7+Q33l1B39pOV5fmhoHdZQTh6yAfDlA0oTkJ886p93AT3QBLpnOwbyO8Vv69ZaLMwr/HliJu0j+xMkp4u2fPPETXKRlhoYzYHkVHni9MBCYqoF1ZghmK42kpw0g+087rKA9MqQg+8R/5Bae0Mf/zLshMvBioYURp9fELNXzX5w6TmSSraB1fWIF60iMoi16qD6MZ//K+EWr2FSN+GF1k1y68IdZ9UH1HVpSZi87NKAOfBtVKZq7kFjC18CPtpiVnCqSbAUbtyUdwe48C+dRzALL28EsoYjejoUCLbedjOIBssBYT6W6A80E6MJrjuj2R2SWPccddbexR3VQurFQQ/Oo+g7oM6WaglJm9ed0Q+0I+o4o7u2ZJOVy/TXXgAHMbGPPwIWzFX1+y5ESSsx2OrVayIXYeTFypd9OHJXOytJbNB/TH/nRjmu3X/GFnO7TqChVSvVYETTZfSyynnXrr9sRQlsfl+9BQrZnFGSY40o+hCGA+vXrJ1AroLeSNqB6KadfTYfNbYBAjdCfhdRJyVHyPD1Twl3/XdlsOVSvK0AQPgxfZwbvlL2tkKT/izJNw0QIXG+ACYRqPzJXbtLkCGH8APVFaH1l5cJywNNfcbYnwuOrfwTTXrYY5lFviltULDY0eVhF2PU9YyHlT5grKwbALofP1toeIAgSyScLV4YyuEUcFcBylWSVVW6eHVQqRjEQfYTyVYNJRAYCYLLDB772G2fyriE5aLr50PdM29n/0gqfACZaIiPClJ2I8DM7KVkU3Vcg4qkG1ZArmwKc+EDXYXNAfigRVP97vR2YaTc9jnHKyepB/+34EQwwoheYvspSnEVPVOdkF/CfEKbKcMr7InIwxWGlRpxQ6V8hc0Gbj8KInHxklGWQjErNe84HuXeX8+0KvC7M/GMK4R3Bp/cpqsxOoMJQ8oLPR7HDqLI+7mPyugtofs1LPJjmggpBT003R3StPm0Ax8VgGj+0TXBNMxmgpeMJSxoRm05ATGno7UMg0n2CfxXC0qL/yLJ7A77t7LVwQ40HMw0Tov1htQFBR7fL57MWpRy6k1ol1S9czMNHcg0BLwesOgbKWcpqXhkpWXXwz9Zn7MCzjCBnRsGsyVZkB9uq+0lZWZS9gRyHn1L+D5uh+CUfoyhL3LxnVCRUkscMsP9R5jw7dk5rRZDuQn/xChyYdhxVcT4nsxuQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(7416014)(376014)(1800799024)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:28:26.9027 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fbcab8c-05f6-4653-1c96-08dca194337e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AEA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8129 Rename struct rapl_pmu variables from "pmu" to "rapl_pmu", to avoid any confusion between the variables of two different structs pmu and rapl_pmu. As rapl_pmu also contains a pointer to struct pmu, which leads to situations in code like pmu->pmu, which is needlessly confusing. Above scenario is replaced with much more readable rapl_pmu->pmu with this change. Also rename "pmus" member in rapl_pmus struct, for same reason. No functional change. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- arch/x86/events/rapl.c | 104 ++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index df71f38ad98d..e6162bd84f23 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -123,7 +123,7 @@ struct rapl_pmu { struct rapl_pmus { struct pmu pmu; unsigned int nr_rapl_pmu; - struct rapl_pmu *pmus[] __counted_by(nr_rapl_pmu); + struct rapl_pmu *rapl_pmu[] __counted_by(nr_rapl_pmu); }; enum rapl_unit_quirk { @@ -171,7 +171,7 @@ static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu) * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ - return rapl_pmu_idx < rapl_pmus->nr_rapl_pmu ? rapl_pmus->pmus[rapl_pmu_idx] : NULL; + return rapl_pmu_idx < rapl_pmus->nr_rapl_pmu ? rapl_pmus->rapl_pmu[rapl_pmu_idx] : NULL; } static inline u64 rapl_read_counter(struct perf_event *event) @@ -235,34 +235,34 @@ static void rapl_start_hrtimer(struct rapl_pmu *pmu) static enum hrtimer_restart rapl_hrtimer_handle(struct hrtimer *hrtimer) { - struct rapl_pmu *pmu = container_of(hrtimer, struct rapl_pmu, hrtimer); + struct rapl_pmu *rapl_pmu = container_of(hrtimer, struct rapl_pmu, hrtimer); struct perf_event *event; unsigned long flags; - if (!pmu->n_active) + if (!rapl_pmu->n_active) return HRTIMER_NORESTART; - raw_spin_lock_irqsave(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); - list_for_each_entry(event, &pmu->active_list, active_entry) + list_for_each_entry(event, &rapl_pmu->active_list, active_entry) rapl_event_update(event); - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); - hrtimer_forward_now(hrtimer, pmu->timer_interval); + hrtimer_forward_now(hrtimer, rapl_pmu->timer_interval); return HRTIMER_RESTART; } -static void rapl_hrtimer_init(struct rapl_pmu *pmu) +static void rapl_hrtimer_init(struct rapl_pmu *rapl_pmu) { - struct hrtimer *hr = &pmu->hrtimer; + struct hrtimer *hr = &rapl_pmu->hrtimer; hrtimer_init(hr, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hr->function = rapl_hrtimer_handle; } -static void __rapl_pmu_event_start(struct rapl_pmu *pmu, +static void __rapl_pmu_event_start(struct rapl_pmu *rapl_pmu, struct perf_event *event) { if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED))) @@ -270,39 +270,39 @@ static void __rapl_pmu_event_start(struct rapl_pmu *pmu, event->hw.state = 0; - list_add_tail(&event->active_entry, &pmu->active_list); + list_add_tail(&event->active_entry, &rapl_pmu->active_list); local64_set(&event->hw.prev_count, rapl_read_counter(event)); - pmu->n_active++; - if (pmu->n_active == 1) - rapl_start_hrtimer(pmu); + rapl_pmu->n_active++; + if (rapl_pmu->n_active == 1) + rapl_start_hrtimer(rapl_pmu); } static void rapl_pmu_event_start(struct perf_event *event, int mode) { - struct rapl_pmu *pmu = event->pmu_private; + struct rapl_pmu *rapl_pmu = event->pmu_private; unsigned long flags; - raw_spin_lock_irqsave(&pmu->lock, flags); - __rapl_pmu_event_start(pmu, event); - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); + __rapl_pmu_event_start(rapl_pmu, event); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); } static void rapl_pmu_event_stop(struct perf_event *event, int mode) { - struct rapl_pmu *pmu = event->pmu_private; + struct rapl_pmu *rapl_pmu = event->pmu_private; struct hw_perf_event *hwc = &event->hw; unsigned long flags; - raw_spin_lock_irqsave(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); /* mark event as deactivated and stopped */ if (!(hwc->state & PERF_HES_STOPPED)) { - WARN_ON_ONCE(pmu->n_active <= 0); - pmu->n_active--; - if (pmu->n_active == 0) - hrtimer_cancel(&pmu->hrtimer); + WARN_ON_ONCE(rapl_pmu->n_active <= 0); + rapl_pmu->n_active--; + if (rapl_pmu->n_active == 0) + hrtimer_cancel(&rapl_pmu->hrtimer); list_del(&event->active_entry); @@ -320,23 +320,23 @@ static void rapl_pmu_event_stop(struct perf_event *event, int mode) hwc->state |= PERF_HES_UPTODATE; } - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); } static int rapl_pmu_event_add(struct perf_event *event, int mode) { - struct rapl_pmu *pmu = event->pmu_private; + struct rapl_pmu *rapl_pmu = event->pmu_private; struct hw_perf_event *hwc = &event->hw; unsigned long flags; - raw_spin_lock_irqsave(&pmu->lock, flags); + raw_spin_lock_irqsave(&rapl_pmu->lock, flags); hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED; if (mode & PERF_EF_START) - __rapl_pmu_event_start(pmu, event); + __rapl_pmu_event_start(rapl_pmu, event); - raw_spin_unlock_irqrestore(&pmu->lock, flags); + raw_spin_unlock_irqrestore(&rapl_pmu->lock, flags); return 0; } @@ -350,7 +350,7 @@ static int rapl_pmu_event_init(struct perf_event *event) { u64 cfg = event->attr.config & RAPL_EVENT_MASK; int bit, ret = 0; - struct rapl_pmu *pmu; + struct rapl_pmu *rapl_pmu; /* only look at RAPL events */ if (event->attr.type != rapl_pmus->pmu.type) @@ -380,11 +380,11 @@ static int rapl_pmu_event_init(struct perf_event *event) return -EINVAL; /* must be done before validate_group */ - pmu = cpu_to_rapl_pmu(event->cpu); - if (!pmu) + rapl_pmu = cpu_to_rapl_pmu(event->cpu); + if (!rapl_pmu) return -EINVAL; - event->cpu = pmu->cpu; - event->pmu_private = pmu; + event->cpu = rapl_pmu->cpu; + event->pmu_private = rapl_pmu; event->hw.event_base = rapl_msrs[bit].msr; event->hw.config = cfg; event->hw.idx = bit; @@ -567,22 +567,22 @@ static struct perf_msr amd_rapl_msrs[] = { static int rapl_cpu_offline(unsigned int cpu) { const struct cpumask *rapl_pmu_cpumask = get_rapl_pmu_cpumask(cpu); - struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu); + struct rapl_pmu *rapl_pmu = cpu_to_rapl_pmu(cpu); int target; /* Check if exiting cpu is used for collecting rapl events */ if (!cpumask_test_and_clear_cpu(cpu, &rapl_cpu_mask)) return 0; - pmu->cpu = -1; + rapl_pmu->cpu = -1; /* Find a new cpu to collect rapl events */ target = cpumask_any_but(rapl_pmu_cpumask, cpu); /* Migrate rapl events to the new target */ if (target < nr_cpu_ids) { cpumask_set_cpu(target, &rapl_cpu_mask); - pmu->cpu = target; - perf_pmu_migrate_context(pmu->pmu, cpu, target); + rapl_pmu->cpu = target; + perf_pmu_migrate_context(rapl_pmu->pmu, cpu, target); } return 0; } @@ -591,21 +591,21 @@ static int rapl_cpu_online(unsigned int cpu) { unsigned int rapl_pmu_idx = get_rapl_pmu_idx(cpu); const struct cpumask *rapl_pmu_cpumask = get_rapl_pmu_cpumask(cpu); - struct rapl_pmu *pmu = cpu_to_rapl_pmu(cpu); + struct rapl_pmu *rapl_pmu = cpu_to_rapl_pmu(cpu); int target; - if (!pmu) { - pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu)); - if (!pmu) + if (!rapl_pmu) { + rapl_pmu = kzalloc_node(sizeof(*rapl_pmu), GFP_KERNEL, cpu_to_node(cpu)); + if (!rapl_pmu) return -ENOMEM; - raw_spin_lock_init(&pmu->lock); - INIT_LIST_HEAD(&pmu->active_list); - pmu->pmu = &rapl_pmus->pmu; - pmu->timer_interval = ms_to_ktime(rapl_timer_ms); - rapl_hrtimer_init(pmu); + raw_spin_lock_init(&rapl_pmu->lock); + INIT_LIST_HEAD(&rapl_pmu->active_list); + rapl_pmu->pmu = &rapl_pmus->pmu; + rapl_pmu->timer_interval = ms_to_ktime(rapl_timer_ms); + rapl_hrtimer_init(rapl_pmu); - rapl_pmus->pmus[rapl_pmu_idx] = pmu; + rapl_pmus->rapl_pmu[rapl_pmu_idx] = rapl_pmu; } /* @@ -617,7 +617,7 @@ static int rapl_cpu_online(unsigned int cpu) return 0; cpumask_set_cpu(cpu, &rapl_cpu_mask); - pmu->cpu = cpu; + rapl_pmu->cpu = cpu; return 0; } @@ -686,7 +686,7 @@ static void cleanup_rapl_pmus(void) int i; for (i = 0; i < rapl_pmus->nr_rapl_pmu; i++) - kfree(rapl_pmus->pmus[i]); + kfree(rapl_pmus->rapl_pmu[i]); kfree(rapl_pmus); } @@ -706,7 +706,7 @@ static int __init init_rapl_pmus(void) if (!rapl_pmu_is_pkg_scope()) nr_rapl_pmu *= topology_max_dies_per_package(); - rapl_pmus = kzalloc(struct_size(rapl_pmus, pmus, nr_rapl_pmu), GFP_KERNEL); + rapl_pmus = kzalloc(struct_size(rapl_pmus, rapl_pmu, nr_rapl_pmu), GFP_KERNEL); if (!rapl_pmus) return -ENOMEM; From patchwork Thu Jul 11 10:24:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812434 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) (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 4AAFA1586F5; Thu, 11 Jul 2024 10:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693732; cv=fail; b=e4pDqQ92HsR75wvyYtW6i1P0MmiEmMSbp0WAXvrB2VcVvZAPENx6DzSQy8aDBfgXhIvG+35Ng6FcCJ91y6k0O/H4igLtcWenjdyKZYiX0+O7IbjjqCKSsoeTBWJfHgPQKY/CYVg83VVnGo4y60drgWu7Ei2gLGM9uynm0QTCwkE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693732; c=relaxed/simple; bh=BGlL3wKkjX1ahoEXEoOMehGxN0nrWF1fTc5vtApf8bs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iPeVly2+ZlgscR6wvevY+gbBPDimnCBl+n+WZEiOgCgj4Kd/uCB8Oy/YBJ2xAJshQqlZrUi6rS7FxwzrONoAH+SosffJj2uQciikLDcYlqczzMKU/HbhelZqIMIxHvDufNMpKk0srNyW5CBDOzxaYBnuHiTvago6pz83hGXNUFA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=mKwvcYCs; arc=fail smtp.client-ip=40.107.237.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mKwvcYCs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WGzOkjkT4FnG5n5s2O0LA+6jQs7xTvrWZWOUrhavqTbHiX1Ml4t7VmDkUMeqZl0fMeLhelIIT/IagfGhWegoJwxpZ0MNSmO4SSfPhUhfVxMigFalhgm7Z5iQQTxg1aRBSSzpewzXp7vv/oWYmorNlZMM8tkTuogHCiQrfhgOqNdf45WDZxUCFOZgECCjecwTPyhv8YPqRo1S+w7Wlmc5ln6P+33BXyALGnrf/ez2BN6XwrL49pfDJCeTzUkzmn7Czc5D3+dW0Oeu/PQiag/5YqCyd3Zc1f6aNlNKgmwGWZrlfAAOKKeJZyTIGsqvnZDTWqeT1sr3HrByYU1SoewIMA== 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=QwvKzhiCu8RUG++KiyHsiIQq6fkd/iM2B2yf3UIOWqs=; b=Po+Id89Ql8e7cT7yKoRrVSjWdSqEran8lBGDAz+cJs7hcyrqvqh7D8QGKnHzQz1wQhXfG439PDcMDMLS5KTgVhZgZzuPdfjiJOo0c3zCdosUHJI9R0bR5E4+n0o1NI4HKxdGGiCrF88X5PBHvEMYs6lkmr0lSbvgMjVfv6Zo1nZv3Ww3Gw4qPm1O0c4ScA68UcUlxA6PQpCQwBF8BBo+5ggkKODF+mfDKnD/kkgFpfD7bN0MWAGdQfoQZjRDU91t5DO72sbv5IDib4l8rHQ3Ku1v5NC+rIpb2wGNA6qfMEHUkLB5QC5vLM4dvZs3tLv2dAm/7hYegFjR/w1UIX/wBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QwvKzhiCu8RUG++KiyHsiIQq6fkd/iM2B2yf3UIOWqs=; b=mKwvcYCsibFuXG/SoGCROQoo950RLEZRb0qfyIDD2Pf5xMecEY4/E/zjDJiRcDQQkdonkc6J1r3DClZ4d9UXDE0UaEFOADgQSOWU/xTRZmg5C2VhDyR5/QHYQnyRxuDQP5b1ZaGEhsEeTkzbBB+esdX2yMG3DgK/iUVwIKlwFdg= Received: from SA0PR11CA0173.namprd11.prod.outlook.com (2603:10b6:806:1bb::28) by CYXPR12MB9428.namprd12.prod.outlook.com (2603:10b6:930:d5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Thu, 11 Jul 2024 10:28:48 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:1bb:cafe::32) by SA0PR11CA0173.outlook.office365.com (2603:10b6:806:1bb::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Thu, 11 Jul 2024 10:28:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:28:47 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:28:38 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 04/11] perf/x86/rapl: Make rapl_model struct global Date: Thu, 11 Jul 2024 10:24:32 +0000 Message-ID: <20240711102436.4432-5-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE6:EE_|CYXPR12MB9428:EE_ X-MS-Office365-Filtering-Correlation-Id: 70ae9840-6cc6-4a4c-371b-08dca1943f8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|1800799024|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: A92bHzRfxvni/+0xNpYjNKodt/MRu24cQsOkLCvZc0Yzvhpgp9Q1e72JXUnFxKmjW0yQRNLMu1ZoKUo3hhfkNGMIbeKB0XrS9kkCo7fJeDblzX9hRScvPJuu0a+bLzDuxjosmPqv5jnyXBg/l7Z6vFFoMrHnjxTX0gxm+0evifWgTK7tIKfCoH4qHyLPBcyJ2b8Tfv3phOJ3pJZRtY6GhugTuc5zF6SKh0q8HqPk3lGWQpbEFoUMKSSRRqmrzwgtQLCm7u9XA16UGZoBIN4EO8ml33jzPPLcLxQtn4aeg0hOrND54vqoXzhzPOlhXWWCu+w2xFI7wDPR6+gnMCftTtY86oMFs+8Sf8IXMMIG9wHHqg4iFZLMruZPDL3Dm97yWD6rrziXaKnjmrpqg0wKFetxJMF3sWGgaBiNEKhCl7WF/uid/BKQshUidnoMBYL2MZJvqLELkmMibPIzCc+UU32OXoQK3oZg2bWNkVHh53FWafU+XpWaAznm9vCGrKzQSrzcU/rZR3BxTb6IWfAe8njkog5B716+/H8aw3F7It4I0cn6Q+GBY+z9G5FblAA9227698q3/lxhgAyi7OorlFgi/lvONG53q7FNvdB9E9qmttWFTfJRk0w6bYskygdMIS1Ia3zLSz3JOOUGDpb31g5NVl4c/Kxu3azyVRe3jKg+RtK9ONI2ZB2sr6V1qvRjl8VLSft6byQDRJYwDmcVDkGWp8cYeohVxAhn1btYfuFJb+WF2Dv+gK+1D9LwFc0ywugynrLMc8j3STN70mdEaJBFZD06MOdASTge/Cuhp9pr8b9r4CZ+GfA7KVC4q4PQgDvEQQ9SV/76CAFeLosKf9CNPnFI6dfWyNlCdhuJeiijvAxqyFt9sQanucQyTBLeAPZ5ZONfRxx+6Mpe6etNKXXxT8KGzcewLVqZZr0m91XySlXuT8cLWcr0Z5kjhd6TTavDB9Wlc9AgyzwJgT/uvKDSU8WFkJlbkmOvjE7UuejwqLt/2btit4BDgv/6k330zd9WQMZDVnsd6a1AKsm3w3YMj5kL6663OKoSx9ZsEG+IadOsRYoa/2r0dt40CGVnTdwibm76mfk9qDWOPbH5a6zP4T5WCDR9R95vhiM+ZL00qxO2s85ARr0QnJ3/p2eIBsFf92ZEqAWa7zozuW25YKX9jDer8i7zudDNG6PXxj61J1LHIc8L/mtbtGINLRdz1GsRPgRv2Vc/qWDpL8fljpSwSdDBpecR2fXSNPxrsdl6yYbxnnq1mnsouwFM+e5stsEfoE/k7tUx4ETyOFZ3kl6ZgWdxOjIfKsi/WLo+3INWHOkbBO8BBex+8xpQMpBlwBJ+aykrIm3mz22p6XfHzznZkJNsKGqNoKWUdAfNswIpXl1Qni+dZBoijUgUJYGym8/Q2yOcOhgqp2K8NzJ9OaSifw3Ze1Fhu1PoWujmKAgNYXWYg76M1sIEWy8F8orP5sLiTkaD1QZDkC7rbGnaOA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:28:47.1096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70ae9840-6cc6-4a4c-371b-08dca1943f8e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9428 To support AMD's per_core RAPL counter, we will need to check per_core capability of the current rapl_model multiple times in rapl_cpu_online/offline, init_rapl_pmus functions, so cache the matched rapl model in a global variable, to avoid calling x86_match_cpu() multiple times. No functional change. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- arch/x86/events/rapl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index c3afeaf679c2..4ee0877eb4d8 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -146,6 +146,7 @@ static cpumask_t rapl_cpu_mask; static unsigned int rapl_cntr_mask; static u64 rapl_timer_ms; static struct perf_msr *rapl_msrs; +static struct rapl_model *rapl_model; /* * Helper functions to get the correct topology macros according to the @@ -621,18 +622,18 @@ static int rapl_cpu_online(unsigned int cpu) return 0; } -static int rapl_check_hw_unit(struct rapl_model *rm) +static int rapl_check_hw_unit(void) { u64 msr_rapl_power_unit_bits; int i; /* protect rdmsrl() to handle virtualization */ - if (rdmsrl_safe(rm->msr_power_unit, &msr_rapl_power_unit_bits)) + if (rdmsrl_safe(rapl_model->msr_power_unit, &msr_rapl_power_unit_bits)) return -1; for (i = 0; i < NR_RAPL_DOMAINS; i++) rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; - switch (rm->unit_quirk) { + switch (rapl_model->unit_quirk) { /* * DRAM domain on HSW server and KNL has fixed energy unit which can be * different than the unit from power unit MSR. See @@ -846,21 +847,20 @@ MODULE_DEVICE_TABLE(x86cpu, rapl_model_match); static int __init rapl_pmu_init(void) { const struct x86_cpu_id *id; - struct rapl_model *rm; int ret; id = x86_match_cpu(rapl_model_match); if (!id) return -ENODEV; - rm = (struct rapl_model *) id->driver_data; + rapl_model = (struct rapl_model *) id->driver_data; - rapl_msrs = rm->rapl_msrs; + rapl_msrs = rapl_model->rapl_msrs; rapl_cntr_mask = perf_msr_probe(rapl_msrs, PERF_RAPL_MAX, - false, (void *) &rm->events); + false, (void *) &rapl_model->events); - ret = rapl_check_hw_unit(rm); + ret = rapl_check_hw_unit(); if (ret) return ret; From patchwork Thu Jul 11 10:24:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812190 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2047.outbound.protection.outlook.com [40.107.95.47]) (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 7AB0E158848; Thu, 11 Jul 2024 10:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693752; cv=fail; b=Z4OfoU8FL9NJjOTghuoaqWuItlQLgWkgqRgXIBamYeqO9yiyXmMPZQQaYo5G+s1mdm7ufsbHKvSaoxkrqqg9pskOtGPNwlqxQBBAM3DO6Er1G3hJIh+++1G7RqwBcfGMsBLnf4Z/enqvvmPodjywsaLmUBybyNuisfqs1od49XM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693752; c=relaxed/simple; bh=jjxwjpSIDFQutneFONkeSDsEjZqIAuJN1SIlg57ByYk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RhNdV6jD6NLQ8i0172AiLMj+lytVp1oKjITUktcT4VokFW84eTnDxS2oRGs/uoNPOtM7CrHemBEn+0dHBkU/mp6J5LJchftd8jgnzOmf4JfnIqQMievbN6fsmrnQzDOiq3m9ejslperYlJOXStEbMQxD5QV2QiDKcp2x6wH5f3c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=mT1SzqLv; arc=fail smtp.client-ip=40.107.95.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mT1SzqLv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Na5L2OMsR2DZMzdGNq243eiq3QsBjx5+grytGBA/PUzYBiaEpo3skjmPLF0gCI12DekNAD2t2m/DKRX/BgEf87lC0euIf6YnrUiBEqjzKegDG/9UZn8qNQuqq5JumTgCT9Bk4c50j3hkX97RNak3ZzIeIUuQV2COSMZWdVxob+ttgpKUdQgE+L7Bn6Q2OwKdjzm+h+ngyS/KTTxcm5Nd5X0Mnymg7FsimUaJZSagCohg6x07TDiMboLdP2Lz6Zh4+/tmLDnxMMtE6j38xDME5Q7kCQgVJQmORrkoaobbs0BSpZHMjGbbBXK0CZG1fTZsBhW/BCJviGP5nbYJdAP9wA== 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=vPshdKt/fF0jFAO0KhsERHATLshGVzQ8svzvQSujM/Q=; b=l2H9mt0lqFnbeSueJIu9VaEmxWOpqc0deea55/Mi3WfCuhLx7Y+nZ3IHt9rnkf74SnVjqrvgo27SzCF/4xDLR3lihPIvVD06lDY1K9fladZFDrXjusPjqOlANE7y1PrYetWp5iS4maaq7lvreJBLnCs/D+A8PG7JUGypBP7yk6AagPvhYm3c4652D+QT4jEsuvXH8DEcX61wga3q4hA7GqP++ATrAVajrpUAiC7nAo5H98L5p3QwFEWPD9mtGeoAZrRaz6eLFO3fwwzBPqyEevaGeWhV+nAzHDvNEYcpYT5Ic58PtK72AfcqbZdZF0jNLhIxP9TQ8JrwcVZcC+2VKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vPshdKt/fF0jFAO0KhsERHATLshGVzQ8svzvQSujM/Q=; b=mT1SzqLv25hccZi2uJfSGESPxAkJZf3f3rsjCGf2SVPfFM8oobgT5lyC/Iuovv1rOnqE8TzNks7UTFCLmJbLNtOw6qnOpYsZ/HGCaoBNF73y6IK0mXnKMoIfJ7nhP42ekauZWFQbZS1EpD+CO0tXvqAV6ZL21SFT/jQg6eZga+I= Received: from SN7P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::18) by CH3PR12MB9314.namprd12.prod.outlook.com (2603:10b6:610:1c5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20; Thu, 11 Jul 2024 10:29:06 +0000 Received: from SA2PEPF00003AE7.namprd02.prod.outlook.com (2603:10b6:806:123:cafe::ac) by SN7P220CA0013.outlook.office365.com (2603:10b6:806:123::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22 via Frontend Transport; Thu, 11 Jul 2024 10:29:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AE7.mail.protection.outlook.com (10.167.248.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:29:06 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:28:59 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 05/11] perf/x86/rapl: Move cpumask variable to rapl_pmus struct Date: Thu, 11 Jul 2024 10:24:33 +0000 Message-ID: <20240711102436.4432-6-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE7:EE_|CH3PR12MB9314:EE_ X-MS-Office365-Filtering-Correlation-Id: 2618600f-cf65-4452-1e47-08dca1944b20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: 5qY1FXIOmYT5s9i5arx0IReEYUzbGFLRztLuCnHKZWkEN4ZfEBbLsoa4LeKXTNMvofDeSb9FUR1eaxDmXaRBiU/S0Vsh/6f7yQu3vdDcfv8l5Tmg7Gyqa/I7U+k/X8Z8GxaSjmjRORo5ZK2CQzzD9x7Aab0Xpb3rGDbyYqD2MinpjYiSsz/gm6Qryft2RD3hM14E2Zud1Nx8v7pOdVU05bmimD0ZnHnqvRFeZPQVA/x/v258wZQ/eBFx0hucCaH6TuUueB/Oh7ElgD+L1DVZSkxjbYEdCgTRC55hpnOwufQZSdKpVbaCSS+/a5MzsCeFcJ8vicnt8eEOs+GUtOhx7Ij2pvfrx7XtTtIFljmDXU3bnKWUN0iTqArlUyvXbqlI8W9qJCPOP5G+SYs8ygW1d+kMJ3SBtKN/bXzGZp2WP6B7m4G4fbHr3hrnc7Dc66FLNYs8v31n6VOUV8RpPItnn9jqwNPT7P4nx+CqHe+MxZZhIPUqlKZHgUgmHdqFpHM84Z7YEAa3CzxohdAOFIrGq3WjZKfYvBykSnpbIowNNLCMegpr0LrAba3/6OIkb/IVU2nfTAZ2ox4DmY9wFU9VQMmSeOU42COutTSN59u5kLOTW7lSq2DdNqJIcrVxgMTGcqV01TV/f/JwJNWmqmK5B0YB6YBKl/pLJ8H/dxcZw/ZDNZaYz6skzuvop4cg7Ac9PZhdPoeLHqEhvW9kOOEUMeUry4bVSMQbsPeYe3047D2PH7oLePlzzAxPF8ZEPKJrz1B2y/awRbKjwkND6CfSBBeJYX6tdtTHKPyJa72y+Qp6JsgyEgos+WmfHqSjOIpYgK4JnCxu2Z7s70luJTME8CtFJl2N9i2Pbm7bqt33Z1VChlfFAivXIsMqtvW2Kzp/+dblrOa9mH1hWUuRKmSiH/C8I+TCcfeCuQsqQQMePhPwKWkSz4fNpN55I5L1OAbQ3t3zqG/Wu/s9fVr6gZ7L3lVrOb/HhTopyVSKgFmRHRoTt5ClWHtQxOtAxpQKiiRzn7dyPUJdP1O8o6asLGbH0E+YGmuALA4LVJDcKiz7X3SZDqfxPWog91537jT7gyBKba03CijH+gkdVnkWqdy8x9QpBaiySvRuVYUFNp2f/RITNarTIjC9DhzfaBDSl62Fjx8eMeLtJ8Og7C1VcR+zknFG/6QVmETU340j9B+aERlBmFTI44uF1vXUAAC8WRWCODh0ttJdGzifgiEd4K9sjWLW4KpFsIoaXzaa0idPhNZXRyabHFNaVl0QR6Q1qmIwlkwtZiAo28u/3z+T0sPPIy0hcIC+vSEX0ittd55/gGu2g7aB21nLm4g0wo8RnJp8rvbZlrpSiMMRXWzGGtq3wgMjSY/Vr1WLjWW7QjqUPse4EdABxdh8U2NuPNFMvi3WhmOknNgS/S7f5Vm/i62RaG4oR4dAcZtq1gPE8bM4+SDXpS8xQIRdjm6HH4pGck2NkfQHIbATq/0GWZ+qm3vEZg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:29:06.5208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2618600f-cf65-4452-1e47-08dca1944b20 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9314 This patch is in preparation for addition of per-core energy counter support for AMD CPUs. Per-core energy counter PMU will need a separate cpumask. It seems like a better approach to add the cpumask inside the rapl_pmus struct, instead of creating another global cpumask variable for per-core PMU. This way, in future, if there is a need for a new PMU with a different scope (e.g. CCD), adding a new global cpumask variable won't be necessary. No functional change. Signed-off-by: Dhananjay Ugwekar --- Changes in v4: * Use cpumask_var_t instead of cpumask_t (Peter) --- arch/x86/events/rapl.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index d231a9c068af..e3d0a82e12b9 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -122,6 +122,7 @@ struct rapl_pmu { struct rapl_pmus { struct pmu pmu; + cpumask_var_t cpumask; unsigned int nr_rapl_pmu; struct rapl_pmu *rapl_pmu[] __counted_by(nr_rapl_pmu); }; @@ -142,7 +143,6 @@ struct rapl_model { /* 1/2^hw_unit Joule */ static int rapl_hw_unit[NR_RAPL_DOMAINS] __read_mostly; static struct rapl_pmus *rapl_pmus; -static cpumask_t rapl_cpu_mask; static unsigned int rapl_cntr_mask; static u64 rapl_timer_ms; static struct perf_msr *rapl_msrs; @@ -401,7 +401,7 @@ static void rapl_pmu_event_read(struct perf_event *event) static ssize_t rapl_get_attr_cpumask(struct device *dev, struct device_attribute *attr, char *buf) { - return cpumap_print_to_pagebuf(true, buf, &rapl_cpu_mask); + return cpumap_print_to_pagebuf(true, buf, rapl_pmus->cpumask); } static DEVICE_ATTR(cpumask, S_IRUGO, rapl_get_attr_cpumask, NULL); @@ -572,7 +572,7 @@ static int rapl_cpu_offline(unsigned int cpu) int target; /* Check if exiting cpu is used for collecting rapl events */ - if (!cpumask_test_and_clear_cpu(cpu, &rapl_cpu_mask)) + if (!cpumask_test_and_clear_cpu(cpu, rapl_pmus->cpumask)) return 0; rapl_pmu->cpu = -1; @@ -581,7 +581,7 @@ static int rapl_cpu_offline(unsigned int cpu) /* Migrate rapl events to the new target */ if (target < nr_cpu_ids) { - cpumask_set_cpu(target, &rapl_cpu_mask); + cpumask_set_cpu(target, rapl_pmus->cpumask); rapl_pmu->cpu = target; perf_pmu_migrate_context(rapl_pmu->pmu, cpu, target); } @@ -613,11 +613,11 @@ static int rapl_cpu_online(unsigned int cpu) * Check if there is an online cpu in the package which collects rapl * events already. */ - target = cpumask_any_and(&rapl_cpu_mask, rapl_pmu_cpumask); + target = cpumask_any_and(rapl_pmus->cpumask, rapl_pmu_cpumask); if (target < nr_cpu_ids) return 0; - cpumask_set_cpu(cpu, &rapl_cpu_mask); + cpumask_set_cpu(cpu, rapl_pmus->cpumask); rapl_pmu->cpu = cpu; return 0; } @@ -710,6 +710,9 @@ static int __init init_rapl_pmus(void) rapl_pmus = kzalloc(struct_size(rapl_pmus, rapl_pmu, nr_rapl_pmu), GFP_KERNEL); if (!rapl_pmus) return -ENOMEM; + + if (!alloc_cpumask_var(&rapl_pmus->cpumask, GFP_KERNEL)) + return -ENOMEM; rapl_pmus->nr_rapl_pmu = nr_rapl_pmu; rapl_pmus->pmu.attr_groups = rapl_attr_groups; From patchwork Thu Jul 11 10:24:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812433 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) (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 05CC814D44F; Thu, 11 Jul 2024 10:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693776; cv=fail; b=NKRUWZTA9jz/giqtb9KSAJ5pbgGJ2NVSNknNeRCNqdN5H30+lOzmwAPm9Qp+uNPfDP7RlUNSr8aCaeMQVHlzH/QB4l5DIccapSwy3/HyMC/RyiZfyvBDu8oYqqRM35S9mjrs/HMw4A7fpwqvsVBbJprAbGnisq1bTYjWwAd/inU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693776; c=relaxed/simple; bh=omifWwMgL75tly7bRNMfyrMsb2mGwm57uU9jhd6MT+I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kk4n85qQH3TQsyr8E98d7M8oVt15ub/aAdAYNao/3gR+vASBgKCwrrvQPh3ya84kBUF1H/3qKe8r5lENn5+ptlGxpYG655em6Kc5dVvS0WgdhIgsM7rHO1/vMvxnck1Y8cJHPDmS6CS8sRzQaSIIcKjR/hJMUBAQT3TGGPgAGOQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=fhxHwBvR; arc=fail smtp.client-ip=40.107.92.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="fhxHwBvR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JQHUJi83apgWv3+YU9HxhWrML+nfsbIxXNETVoNPLDyP/8HQgPLWo3n7aIxWoUVt1Q0Zj+FYwHnF1XaJS+7xqReub0X5UMajjGON16xEictIpet6k1sSuCqEnexervyKdnfwKmeJMrseXE5IlR9DG5q7dyH5kRdEzS5teW2/OvgyFpESjtZEdDV6uNP9HtdygHsUEvvcY6czzPuYZMTjxbYjgL61jwICCIxvkadArf4WYcHf9NmnWPB+r09+YsZcU9eD3QNqhYGWY76AuKcPF6BTyV43EHPwM5hWBSQeV80zALKgmXB+xbk5vhJngLMwvT8kSjsGeLnTzOMik7Wcog== 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=V2o5vVrSzegCXlx7d4sKaxeoqAOh8OXb8m9Fv7s/wTQ=; b=UWnzPVzF3T1yKIciACp3mEyD0PE1yVlofuRNS2Rh1JcglGZdbAiZicTvA7UE8coQNRxMTxYf+l6+4E+MngXXZbJ1hrOE4Sh9gN3gP8Y4mU4tUa/ELmahbapPCFJC7xD6TBeglXiFen258OJByqJ3ueMkt61U3bw943M9GWL2xiYzgYlcAaW4FaoJPP7pVXy+aD9ODkeleTR6s6zGgkjffmJq5qMA0DoPfTs5fAAJQVrj3UqljvZUS/1SFxW7TIeCni/U9CVw0+RaVW/vLyklFJnVWE2yG9zmMJx63Z63/gdzBW9CmONQueYf4K0mYk2OJ9yJBjdbF63Tnc6fK+Rbow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V2o5vVrSzegCXlx7d4sKaxeoqAOh8OXb8m9Fv7s/wTQ=; b=fhxHwBvR9++kDYlOZA0vAc7QA4ujn/U1y8QU9T79pXtLVhJ3mUSNjraOlx0mEPgiIkNvnsl16LFCf81LN8a2+Lrw0sZhpHNdrBU3Wd1Qcu3fU+RULlPre6yoGAEC67V8rj74vPCgpF0uHGYbqpr1kio2GyvwEA6hshnFpb6bz7k= Received: from SN6PR2101CA0005.namprd21.prod.outlook.com (2603:10b6:805:106::15) by LV2PR12MB6013.namprd12.prod.outlook.com (2603:10b6:408:171::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36; Thu, 11 Jul 2024 10:29:32 +0000 Received: from SA2PEPF00003AEA.namprd02.prod.outlook.com (2603:10b6:805:106:cafe::f5) by SN6PR2101CA0005.outlook.office365.com (2603:10b6:805:106::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.12 via Frontend Transport; Thu, 11 Jul 2024 10:29:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AEA.mail.protection.outlook.com (10.167.248.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:29:31 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:29:22 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 06/11] perf/x86/rapl: Add wrapper for online/offline functions Date: Thu, 11 Jul 2024 10:24:34 +0000 Message-ID: <20240711102436.4432-7-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AEA:EE_|LV2PR12MB6013:EE_ X-MS-Office365-Filtering-Correlation-Id: f7521a8c-a939-495a-fb8c-08dca1945a26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: f0pAssa8JLXYAC30q0eSNp1QgUC45+vuPhUc4YtF6o84t9EUeAMIvwzzoNKs9y5kBnEhqaUHKC0xsnlaqoX/Lqhs5Pib38IXivjoEk6Bpp2QYAt+2JtZbMcQ4l25Y9ItU8ZKcFUTN34FoPYIhdAuhosvIiCl9Cuyh2R4M7NYFSUSRUvQwJzOH+bYvIiHqB9RzrZl5Ypls60q9N3+DAQ8ifJ1WP+vmRrjpZ0Qb1fBiTLvo+eNUlQyLvuUi1g3ZoKCxUtnvEisfeSQBC76ZRlx97NgFn40XJLpEqJ180rda6pl7JvGUna7RZQ1qqJQwNhC3APlKdX+QUDgtMCsFgnEUt3zPfpcTPOIHBqcsa/GuttZrFQXUIHUCSnc8VWK7fEZJb4idtjZKotOQAzTGxVA1IxD2xTnGsM483XOfC0Y2wnIabQwKAJBbZAhO3TsxcQGxE+w1eTmbgx8jkFhsPcI/PCBia74NBZSw2ytJwu8n62Qt3znzvex9Kd6woEy38YflmqpZMVZDx+fJmMKscDGVaZHRBLOs6iTUm6VCgs7HWzLvOGdg0ht1vUUaDP7rmn2g+6BfsjEq09m1f3LvgycUriaFnZXR7Dg+TmkShGWPes5EMIg0jONzECyIyyGf9BRZCCUhifAZVT/kKMgj5QN736UN7/u5hDspVniGyleZ/JcSKSwWa6ldlE3zrzXfiXJoAA4xreV5btCmYi2ThLoIkz6le6NGjNMaJYfGs7i96RNCm558IcSHYypRJ6cmhU83NF0D8gf9ijNEeDAg788tovWelbToJFGfj6qe8iayMRHPk3UCxydnc+Tl2cwm0jrc39OqWDsUoHnHKwJSYrwEtfN/M1byMpGx2JnTcuLQSBbaW+w4d29p7hoHivZeFXcU77WzZeKJzMyC9V/y6tYogbHaAmUSfc23zOq2gbzcnDwk9NwPWiKJBCvB964Dzziito2caRQ15/8m05K15p7QrCRQy9aliv1MG7CO8v9m9weOkZGWl1yFSy+l+qOU9LHHKLIKW70km3e8xPkcEz942ze0UsODJcPBWpsy0RN2vwHO8086rH5y3plwymo9dyTyb3mMKccK6SKi9mB2sLQpOBEYo0l8jRPX7n4ZHJZ1qm5QDZzdnQ/NJOHaAnGXzqO6hhVAF0SXfZxUj506O2bpJ+MdcPs8DXWkJC2GxCRsr4uwA0gvnjq/PlUxx7acMoqu4O+x6t3iF6ZBlV9Vp8NyQHZOA0SyvvRIvFeuXoZMfTpEa3M7lnRBuUCiKiTgZhCEK14HXF4Hh8yRPh+4wbQeYtDb6h27Z2ch+drWzs5YKxWPYBXWRcEjL11pHl8BBYETgb4oyOj0CHximpV/2LmmAMguxuT+zNV03k3fVHGx/oU9nvTCWFLcIl82htJRtb+LnfwEkco7S+yDIiPaaCOnyXRB4bbAcucq4kPLLVKJlNjLWLuH5wB8CDwKYVvLpPG/kiK7Jef1S81FxtwVWru6Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:29:31.7003 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7521a8c-a939-495a-fb8c-08dca1945a26 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AEA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB6013 This is in preparation for the addition of per-core RAPL counter support for AMD CPUs. The CPU online and offline functions will need to handle the setting up and migration of the new per-core PMU as well. The wrapper functions added below will make it easier to pass the corresponding args for both the PMUs. No functional change. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- arch/x86/events/rapl.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index e3d0a82e12b9..1d36565d0cb9 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -565,10 +565,10 @@ static struct perf_msr amd_rapl_msrs[] = { [PERF_RAPL_PSYS] = { 0, &rapl_events_psys_group, NULL, false, 0 }, }; -static int rapl_cpu_offline(unsigned int cpu) +static int __rapl_cpu_offline(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu_idx, + const struct cpumask *event_cpumask, unsigned int cpu) { - const struct cpumask *rapl_pmu_cpumask = get_rapl_pmu_cpumask(cpu); - struct rapl_pmu *rapl_pmu = cpu_to_rapl_pmu(cpu); + struct rapl_pmu *rapl_pmu = rapl_pmus->rapl_pmu[rapl_pmu_idx]; int target; /* Check if exiting cpu is used for collecting rapl events */ @@ -577,7 +577,7 @@ static int rapl_cpu_offline(unsigned int cpu) rapl_pmu->cpu = -1; /* Find a new cpu to collect rapl events */ - target = cpumask_any_but(rapl_pmu_cpumask, cpu); + target = cpumask_any_but(event_cpumask, cpu); /* Migrate rapl events to the new target */ if (target < nr_cpu_ids) { @@ -588,11 +588,16 @@ static int rapl_cpu_offline(unsigned int cpu) return 0; } -static int rapl_cpu_online(unsigned int cpu) +static int rapl_cpu_offline(unsigned int cpu) { - unsigned int rapl_pmu_idx = get_rapl_pmu_idx(cpu); - const struct cpumask *rapl_pmu_cpumask = get_rapl_pmu_cpumask(cpu); - struct rapl_pmu *rapl_pmu = cpu_to_rapl_pmu(cpu); + return __rapl_cpu_offline(rapl_pmus, get_rapl_pmu_idx(cpu), + get_rapl_pmu_cpumask(cpu), cpu); +} + +static int __rapl_cpu_online(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu_idx, + const struct cpumask *event_cpumask, unsigned int cpu) +{ + struct rapl_pmu *rapl_pmu = rapl_pmus->rapl_pmu[rapl_pmu_idx]; int target; if (!rapl_pmu) { @@ -613,7 +618,7 @@ static int rapl_cpu_online(unsigned int cpu) * Check if there is an online cpu in the package which collects rapl * events already. */ - target = cpumask_any_and(rapl_pmus->cpumask, rapl_pmu_cpumask); + target = cpumask_any_and(rapl_pmus->cpumask, event_cpumask); if (target < nr_cpu_ids) return 0; @@ -622,6 +627,13 @@ static int rapl_cpu_online(unsigned int cpu) return 0; } +static int rapl_cpu_online(unsigned int cpu) +{ + return __rapl_cpu_online(rapl_pmus, get_rapl_pmu_idx(cpu), + get_rapl_pmu_cpumask(cpu), cpu); +} + + static int rapl_check_hw_unit(void) { u64 msr_rapl_power_unit_bits; From patchwork Thu Jul 11 10:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812189 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 9C52F14D44F; Thu, 11 Jul 2024 10:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693797; cv=fail; b=ZRsvuwWRw5kagttn9d2Hh4rql0DK4MCpxDI0X2jPLKKGYeQAmzM/PNK08wG1sQfZLagoP9PJt3vSniKdwszHMwT9qOX25t8MQWw0lQnTqCsbVwwtqqzP5zKMag0ZLqRhjkwA9hWHeD33C/2ByGeWqnAvMi1E/HAwZUV77RQuiCA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693797; c=relaxed/simple; bh=D+gLgTvQgEN5lztrVYIjZ2UW4DehNy3FMRMtdl6ZsR8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tNxU78AH6d0n9JU84onlMIw2GmXmnatjrqwd/05ky9oSGgizJjZQDn/L/YFQ8cITyvl/2jYcccdnozAD/nY/5vvuyXRFOikpGaeZG8E3COj4p1r9ZKzN/nNNtl65K1BZknQU0mbyq+JDfXsoJMDnU+PoPJI49JlG6N6MgGM8P0Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=SlMhc0f+; arc=fail smtp.client-ip=40.107.237.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="SlMhc0f+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k9t1JrWXldSTvp3ke1paBiDljp0ZnQ//xmd0/ir/3ZApAuyhqqcPgfaiLVLWs6OPXuPNR49XErbEdYbTbq273ZPtRLxAj6nq/mo981cU8ZOsQEiUMpfMcaObdu/sl1HzjNSH2f2Q3pT0tSMGMhmsRLwVxomLKLID7dVJ6VPTH3KkQkz2lyUzdhlFFg32ky9xb8UdT9WrYxjtAlBXze+/wX5mtUvvIwNM1SPRibtMXoCYI6OZCNP8Y8mUweJaHa8ITHJOCsz2nHoDoPDyGXbI63zQKsKi2Ly9Rg+0Eb+IEftVAqZcDmqB6dvr+rMg01h+BMYD3VMhnkgIHo9CLSbQWg== 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=7QETpHWz7mQm/u1yCrpkg7I/uOwOXgKiBOV6erzVswI=; b=TpUc+tY2g9w0Yovq1qI2dHLeMOc+XxXcRPA++VTAxTbqrEFZqx1jAECv9PhzUM0hpxUYzjt7CXQLGNfUDZOfkG5FOUG8Bn7avDDIEZ2Of05j6tnodH/soKACNBc8smvO2lYqv2ejMwingGNFUj14toiZtCbotZLTvqXAlUdrIxWHmt5fS8MJ5iMYSxNrh/a3li8kt3VOVTI4NYfTptVaJEgfSW2PTphzS8vvJQjziGYVFxLwu20S3mO/WzG4dAFT2JUHnudSGlNLPVTXYW6si4+pr46ZEoj7abKvdLA5nExLl6kvtWZnkKjuFDKR+bBc9pJAzz2ZJCS0mHiFpER+jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7QETpHWz7mQm/u1yCrpkg7I/uOwOXgKiBOV6erzVswI=; b=SlMhc0f+IpydG+AOiETeCVsd6bMCkBOyixxpqR1k8NZRfMrj0FvsNU4ulS06dRXnXv/+h2IFHC2zd8wfflSpy6nmwmswMJpZkL6+MkgO1Oz+8dFJejehX3sqxKF6UB2XOl1HHWSFEhd62eVlYZV8LburuTQq9Cj4a+PtYCiHVO0= Received: from SA0PR11CA0167.namprd11.prod.outlook.com (2603:10b6:806:1bb::22) by SA1PR12MB7341.namprd12.prod.outlook.com (2603:10b6:806:2ba::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Thu, 11 Jul 2024 10:29:52 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:1bb:cafe::dc) by SA0PR11CA0167.outlook.office365.com (2603:10b6:806:1bb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Thu, 11 Jul 2024 10:29:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:29:51 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:29:43 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 07/11] perf/x86/rapl: Add an argument to the cleanup and init functions Date: Thu, 11 Jul 2024 10:24:35 +0000 Message-ID: <20240711102436.4432-8-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE6:EE_|SA1PR12MB7341:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a6f62be-a69e-46f6-fdf4-08dca1946636 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|7416014|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: QlgJscLsHAwugKOtgX07GpfXVj9oYbNwH3OE3eeC5FzkISTDJ+nLQ3v2JQlp+Bmd6k+EXD6k4NlVb+S/EpcMKLLB1+h8+lvvIlPnWITMNZs/6hIK2RMX9jfq4M5YvV9UdhZC0R/KoIOx0rEe5bVkFyP5xunZGvzFwAxQKesYhICQ7b7d6r1Cgs/CdkL9xpRPfasNAGuY/ubRJGw0tam2U3wH9dN0CqriREYh01138WaLryMlVPM7b4uyqOchJkFL5xeig5wLNrObLKmmHXJK7f8lA2/b96PF1sUoON0I5c66PZQtKVd2Wmnb/U80Zk8FrXqwQcHhBGY+lp8Jp7uCxoyTrE5vfeGxlKYW10dG7dEEDeJHjbqDAA+IRhyrEWoDx/d0fHi2iG4Zn/KkTLXUT2fnQh90ll48jxDR0PuTVPEpPaAv7TBLdjc00pu/nYzMJS4EPXdCTuPMJwf5Ip6iMf5dOGEkXCydsUuXQNw+P2kBtJ11+DOzQzLTryBhVIxpUDZyV/gqm1HZoN+wfBtQtjjUnkAYL/vsoy0ib5goM3ilm+EgQWxvfyDzRSkkSgCZu0nBTFZIf0tMHvAl/DC8a7qMJq89dV+zCKqY7lG8loUI386g5JnQC7tGVHwd+Z3oPnwhuruHmp05qs73Y3zIoF5At4N0clw4i9cDqSisBlPiX5kBpUJxqPb2zPaVTV/DIwAr9qcw7zm+v3WyOlMxX4OiQUMwxFveWf2e+k+RKdowmeG7n3O3eOtIS6kbE570MlEA2b+BIPkNXwZ9DFYEEUkeARVSxvagzGO7OAlfCwA0AnFdv3kWjyT4BcmM0Jeg2r18q3BRf7r+odQQroKizg50hvsMEe6/M8+Fs5z3SEbvQnkrXVEcHeEo8SlIv7FOJK6onjJ0WvyylAAQRvKBLicG48PEVFIA6x2MJW/k10mYwll8nsOteQdxKNnDHaKGMzPyWTEdMaX+EPqc/jnpW1rgahMtnb+cGmHRahZeQLR7+hb/Ka5hYq0jvaUri0gJEhvvJmI1gBMm3Y9qHoQscwfma4Vxf5IywdFoEg0dbcZ1+I8velbsHIcfnzZpQV9DIEY5Wd8LyUSuWfD7H8TQ/aCihag9APDvrUVgBAHTylYDz2waTeVm8vrepbY4p0BhiG7O7x28cfTFNAMxHsESkSYOIyuly3+TK4pekla84W9lvXth/a6xPJz2NYhzkOv6J5klnX397KEh772vWCzhum0pnfHR21ijvRJciSD3LvyRAfX66Asr8kOlPqoxPT3t87nfPkCH7/I5H3UHtLMidHjYmW85Vut+EHq+auw+fWErpRsZkBV5tuiV0W80dkKx6DeTdZ+rAuEF/7AIQdbMLbQgi5zpyVeSk5+WHcwlDvEbr4RRIIyH3gystGmqXLzSfg5DrN/PGxY9DIXuwhL9FVdqeN6x1drd6T3jqUV52JF0EhQxQWbKvKc3Kf0TRQRL X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:29:51.9379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a6f62be-a69e-46f6-fdf4-08dca1946636 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7341 Prep for per-core RAPL PMU addition. No functional change. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- arch/x86/events/rapl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 1d36565d0cb9..362e82284ccb 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -694,7 +694,7 @@ static void __init rapl_advertise(void) } } -static void cleanup_rapl_pmus(void) +static void cleanup_rapl_pmus(struct rapl_pmus *rapl_pmus) { int i; @@ -712,9 +712,10 @@ static const struct attribute_group *rapl_attr_update[] = { NULL, }; -static int __init init_rapl_pmus(void) +static int __init init_rapl_pmus(struct rapl_pmus **rapl_pmus_ptr) { int nr_rapl_pmu = topology_max_packages(); + struct rapl_pmus *rapl_pmus; if (!rapl_pmu_is_pkg_scope()) nr_rapl_pmu *= topology_max_dies_per_package(); @@ -738,6 +739,9 @@ static int __init init_rapl_pmus(void) rapl_pmus->pmu.read = rapl_pmu_event_read; rapl_pmus->pmu.module = THIS_MODULE; rapl_pmus->pmu.capabilities = PERF_PMU_CAP_NO_EXCLUDE; + + *rapl_pmus_ptr = rapl_pmus; + return 0; } @@ -879,7 +883,7 @@ static int __init rapl_pmu_init(void) if (ret) return ret; - ret = init_rapl_pmus(); + ret = init_rapl_pmus(&rapl_pmus); if (ret) return ret; @@ -903,7 +907,7 @@ static int __init rapl_pmu_init(void) cpuhp_remove_state(CPUHP_AP_PERF_X86_RAPL_ONLINE); out: pr_warn("Initialization failed (%d), disabled\n", ret); - cleanup_rapl_pmus(); + cleanup_rapl_pmus(rapl_pmus); return ret; } module_init(rapl_pmu_init); @@ -912,6 +916,6 @@ static void __exit intel_rapl_exit(void) { cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_RAPL_ONLINE); perf_pmu_unregister(&rapl_pmus->pmu); - cleanup_rapl_pmus(); + cleanup_rapl_pmus(rapl_pmus); } module_exit(intel_rapl_exit); From patchwork Thu Jul 11 10:24:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812432 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) (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 D5AFF131E4B; Thu, 11 Jul 2024 10:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693816; cv=fail; b=XHCTb04sQ/B2oXtZFJhKGT28HN27yVyM++nAM0rOWKhOk17kJh01wqWTgcs64IBTYE32RU7r8G80kBVbrwckmnrPjbmSsNdKl9kBjAXiMRpg4SZZFlPa0SPKbZ3Cgsk2ghiDnY718UzNBcV6IS71NbEq6hQ3Bs4SAUysr9We+Cg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693816; c=relaxed/simple; bh=ZpRCKV8MG0bncltBs7V3NJHKn1BUdctRTQT+cMT+zz0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D2Awzxi9l6zcrFdUvqGqvJlrlqvHvuJqXTVmCyy0QjVfe6UNKJ/r/L4xBuUgQDeUUeXHzTNCtXtqDn+7txkRTjPwF6tWKZKnNPBxy6UP6rbNN63KXCfwb0g+oSIVlXvxis2q3GmoH84oCQ+P4V9OBVltd3e1mKGH6aQU6dTFJPs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=dHZswyEp; arc=fail smtp.client-ip=40.107.93.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="dHZswyEp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aFuFxQdS2eZXUfmAe+O55NfWTkOiYol0InAPqoUriXjVKKN1rskmZlgT9vPeBYCgU+BagmgNLA1i/N3hZc0sX6OdFwEmSmfEre88JSfvPlyxhY9JB6MXXc7Uk566vSDMZ3Og4f0VQnJ4PEXPzmGx4HHBHIN4Z+THb7HYKRHfmVOlHVkWSRNY8SrgbVb85lXdNxZm4YW4CfYTOdWIMwi6R+ZrtklJ03lygaxF2t1oi9qR+F5WuvfG0g9hn/9LVyr8WushnnvAwUk484Y4CU5mmp70LEXGLnWq7X4ncJxSpIXYaRRwPJc234upavIdDXkrMb0RpEQ6BoRZjVB1I/u15w== 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=/EaiiKZrvUTa7Sb8zAt01g0JRnZEzeikAgGFVLnd2yk=; b=zKafuefe+Jm5ROPPrlJnUTAAxJwYcSyIJCZdK5BjfW1wxhJ0zFWnejha3t8EAX5tpK4WOt6cWMk/HW7CS+W0a75jBAzV3f5F517OFsVbx7KnScZ1beR1sBE5CEV7sjbQYSamnGe9mV2/BCJLOPHF+JAYlzfmjL4NNOZbur0aWLZlAxhsb2gxhftp9NQbpufZbErVrFFaqw62rU709/PykUr11qVENNx3IZhPA1XUN5LxqOWyKhQmfa9JpuU3Ofd6lmigx87M1Veoy8eqSm7bvAOjAaX3DOtj67rcgPpmOuqKxYC0z1OCEikrP9sBhSMfgiKZWrHtKmnC4hVVJmDIFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/EaiiKZrvUTa7Sb8zAt01g0JRnZEzeikAgGFVLnd2yk=; b=dHZswyEpqMO5wMLxs5j/pxmlyJSXM1Nbw1PiKRudc5dLhSPgNj1Z1v5FrcHQ/uvH/QaHfI5NwjIKp+jXSXgEJht+jntIFUgU4JQ1Lxae5yzXx7tPHWVDt2j8XkJGvPnBiYkc7OTYT/CgpoxLnB/vyxkNR92+wVup6axfnH6+xHo= Received: from SN6PR2101CA0016.namprd21.prod.outlook.com (2603:10b6:805:106::26) by DS0PR12MB7656.namprd12.prod.outlook.com (2603:10b6:8:11f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Thu, 11 Jul 2024 10:30:11 +0000 Received: from SA2PEPF00003AEA.namprd02.prod.outlook.com (2603:10b6:805:106:cafe::97) by SN6PR2101CA0016.outlook.office365.com (2603:10b6:805:106::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.12 via Frontend Transport; Thu, 11 Jul 2024 10:30:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AEA.mail.protection.outlook.com (10.167.248.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:30:11 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:30:03 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 08/11] perf/x86/rapl: Modify the generic variable names to *_pkg* Date: Thu, 11 Jul 2024 10:24:36 +0000 Message-ID: <20240711102436.4432-9-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AEA:EE_|DS0PR12MB7656:EE_ X-MS-Office365-Filtering-Correlation-Id: 8277208f-dc54-4c05-934b-08dca19471df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: 4I6/6fMjuD8361AZaeDTsSxTtBut36AO+NLhbMHboy4HSYhftI2U3hbjg+N+37kZGSGl+skCOQGdTTGFsGxQ6swxVAOMhAet/38egpoHTE3fmaAXphVR/dJi4ULWms2sdATtiHqXa85dQPa8x7QkBQ4wddyT9ZmGWO2MQ7FRDBbgHraPWSiNHUD+Hu/xGN7E1Ki+AdEOU7EhdFXSlclG1c3j7TczbtRJrKtrzox2O2HsNDafmA+LbvPvEnw3Q4hnIqiXv80SIZboOaR8fHUOTAnv4loJTDegN2HwZCc3ON/PrNK3ogMZfQCSMmuMrnnltV7OobvFXRnu32JXWAwGwWeJoEYLexSqy/f7mv8uuIeCxBG+ewUS560omNi9OHORC8kB2FQpe0idJf8NK3X88OiLZuaIkG6D8dhnil/a3ZVGQNTcYWKC1XGit9oiZ6P/e6M+bp64Uc+pLG89HJ+uj/wX+ZwpA3TjuE96NV5yfP/+kzJUcwoQos5DtPXTLif3gGHHMSr44dwKUd5TjyW5j060gmbuOhT1IvrevVysa0xrCW3jBhnQeezmXxakPGTBI+8yjNcV/vJo1/V2s15oL7UjesD0hqnZR15+Ywlivb8ecV8so3mYI6BUfYwNcWB0MHuEVqAB/OaypWdYiFglmLhmg2H8rTRAYo9ukcBZy5MfCh/+OqKogaFlo+idminTIY7ErTW6UxssFkydrTHkQ65a8xQZsPGRiD2EKxpwj3KuFUkI3ZGei6Yt3i/SIddOT6b/Oay48Mrdlhlo/snUUiwWRQbPWmkJ1JGWTVaRS7fjMU8OuoF/nMh86FeH8Ce9oKT0mOnmk8QU8G3wClPS0qvrmbYvOWCmYPcxh/rYb8X1dVpHHBjXBra/IvRAxABetSWqJ/BfmMQqu8LqsuXkHj/NczhtoOfgJ6Q8yot2+KS3RyDyNzzym/SIiGFqGQvAzDduLx69Uyp5vokyS8B/W29hQZMdP+4nw/UqU6ZBoLm8YD1o8veNJFuBQBz5R0qhDXZXIZCF8kHR84IitfbwT/wQmDbHwGhw0iCdJ04kq+Nc0fccddCJQPr5/iJy72Sx0qeTBgL3V2r6IhYbQH1oFZcYdn83g3YfqVcfhu3j2SS7K+mtopPd4htWCGYMBVYdppSdWHEMFIGudLexgqJSsJ5QBHqRfpbZr3YU34WnMsl3TrXTjseooXth29JxSazw4RVNyq7BmZM2yneC82msIyBRghtgFkNvB+b9klnQuBQ+yo9357ifsd7cVtw9eCgAklSUonrCo8M+QmS3KUW/RaqyCEkkP/feJFL5hgJNrBabSWEa/BsHv9U1NNM25bLsYU/nx+11o2bocuzoR7hAoDJjVHBoS2W0ijmYDcB72rV6SAMn97G4FFTCg7PxuWu3PQ5/wSc4fjTtxTjTH+oeaVOOHBaogh6CfWSaJRD/qE6K1Z61mjl0OJd7mNeQFsdfwLu0gUUa+d1gvRyI9EpisQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(7416014)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:30:11.6070 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8277208f-dc54-4c05-934b-08dca19471df X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AEA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7656 Prep for addition of power_per_core PMU to handle core scope energy consumption for AMD CPUs. Replace the generic names with *_pkg*, to differentiate between the scopes of the two different PMUs and their variables. No functional change. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- Changes in v4: * Move some renaming code from patch 10 to here (Rui) --- arch/x86/events/rapl.c | 113 +++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 362e82284ccb..9beded3d4a14 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -70,18 +70,18 @@ MODULE_LICENSE("GPL"); /* * RAPL energy status counters */ -enum perf_rapl_events { +enum perf_rapl_pkg_events { PERF_RAPL_PP0 = 0, /* all cores */ PERF_RAPL_PKG, /* entire package */ PERF_RAPL_RAM, /* DRAM */ PERF_RAPL_PP1, /* gpu */ PERF_RAPL_PSYS, /* psys */ - PERF_RAPL_MAX, - NR_RAPL_DOMAINS = PERF_RAPL_MAX, + PERF_RAPL_PKG_EVENTS_MAX, + NR_RAPL_PKG_DOMAINS = PERF_RAPL_PKG_EVENTS_MAX, }; -static const char *const rapl_domain_names[NR_RAPL_DOMAINS] __initconst = { +static const char *const rapl_pkg_domain_names[NR_RAPL_PKG_DOMAINS] __initconst = { "pp0-core", "package", "dram", @@ -134,16 +134,16 @@ enum rapl_unit_quirk { }; struct rapl_model { - struct perf_msr *rapl_msrs; - unsigned long events; + struct perf_msr *rapl_pkg_msrs; + unsigned long pkg_events; unsigned int msr_power_unit; enum rapl_unit_quirk unit_quirk; }; /* 1/2^hw_unit Joule */ -static int rapl_hw_unit[NR_RAPL_DOMAINS] __read_mostly; -static struct rapl_pmus *rapl_pmus; -static unsigned int rapl_cntr_mask; +static int rapl_pkg_hw_unit[NR_RAPL_PKG_DOMAINS] __read_mostly; +static struct rapl_pmus *rapl_pmus_pkg; +static unsigned int rapl_pkg_cntr_mask; static u64 rapl_timer_ms; static struct perf_msr *rapl_msrs; static struct rapl_model *rapl_model; @@ -172,7 +172,8 @@ static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu) * The unsigned check also catches the '-1' return value for non * existent mappings in the topology map. */ - return rapl_pmu_idx < rapl_pmus->nr_rapl_pmu ? rapl_pmus->rapl_pmu[rapl_pmu_idx] : NULL; + return rapl_pmu_idx < rapl_pmus_pkg->nr_rapl_pmu ? + rapl_pmus_pkg->rapl_pmu[rapl_pmu_idx] : NULL; } static inline u64 rapl_read_counter(struct perf_event *event) @@ -184,7 +185,7 @@ static inline u64 rapl_read_counter(struct perf_event *event) static inline u64 rapl_scale(u64 v, int cfg) { - if (cfg > NR_RAPL_DOMAINS) { + if (cfg > NR_RAPL_PKG_DOMAINS) { pr_warn("Invalid domain %d, failed to scale data\n", cfg); return v; } @@ -194,7 +195,7 @@ static inline u64 rapl_scale(u64 v, int cfg) * or use ldexp(count, -32). * Watts = Joules/Time delta */ - return v << (32 - rapl_hw_unit[cfg - 1]); + return v << (32 - rapl_pkg_hw_unit[cfg - 1]); } static u64 rapl_event_update(struct perf_event *event) @@ -354,7 +355,7 @@ static int rapl_pmu_event_init(struct perf_event *event) struct rapl_pmu *rapl_pmu; /* only look at RAPL events */ - if (event->attr.type != rapl_pmus->pmu.type) + if (event->attr.type != rapl_pmus_pkg->pmu.type) return -ENOENT; /* check only supported bits are set */ @@ -366,14 +367,14 @@ static int rapl_pmu_event_init(struct perf_event *event) event->event_caps |= PERF_EV_CAP_READ_ACTIVE_PKG; - if (!cfg || cfg >= NR_RAPL_DOMAINS + 1) + if (!cfg || cfg >= NR_RAPL_PKG_DOMAINS + 1) return -EINVAL; - cfg = array_index_nospec((long)cfg, NR_RAPL_DOMAINS + 1); + cfg = array_index_nospec((long)cfg, NR_RAPL_PKG_DOMAINS + 1); bit = cfg - 1; /* check event supported */ - if (!(rapl_cntr_mask & (1 << bit))) + if (!(rapl_pkg_cntr_mask & (1 << bit))) return -EINVAL; /* unsupported modes and filters */ @@ -401,7 +402,7 @@ static void rapl_pmu_event_read(struct perf_event *event) static ssize_t rapl_get_attr_cpumask(struct device *dev, struct device_attribute *attr, char *buf) { - return cpumap_print_to_pagebuf(true, buf, rapl_pmus->cpumask); + return cpumap_print_to_pagebuf(true, buf, rapl_pmus_pkg->cpumask); } static DEVICE_ATTR(cpumask, S_IRUGO, rapl_get_attr_cpumask, NULL); @@ -553,11 +554,11 @@ static struct perf_msr intel_rapl_spr_msrs[] = { }; /* - * Force to PERF_RAPL_MAX size due to: - * - perf_msr_probe(PERF_RAPL_MAX) + * Force to PERF_RAPL_PKG_EVENTS_MAX size due to: + * - perf_msr_probe(PERF_RAPL_PKG_EVENTS_MAX) * - want to use same event codes across both architectures */ -static struct perf_msr amd_rapl_msrs[] = { +static struct perf_msr amd_rapl_pkg_msrs[] = { [PERF_RAPL_PP0] = { 0, &rapl_events_cores_group, NULL, false, 0 }, [PERF_RAPL_PKG] = { MSR_AMD_PKG_ENERGY_STATUS, &rapl_events_pkg_group, test_msr, false, RAPL_MSR_MASK }, [PERF_RAPL_RAM] = { 0, &rapl_events_ram_group, NULL, false, 0 }, @@ -590,7 +591,7 @@ static int __rapl_cpu_offline(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu static int rapl_cpu_offline(unsigned int cpu) { - return __rapl_cpu_offline(rapl_pmus, get_rapl_pmu_idx(cpu), + return __rapl_cpu_offline(rapl_pmus_pkg, get_rapl_pmu_idx(cpu), get_rapl_pmu_cpumask(cpu), cpu); } @@ -629,7 +630,7 @@ static int __rapl_cpu_online(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu_ static int rapl_cpu_online(unsigned int cpu) { - return __rapl_cpu_online(rapl_pmus, get_rapl_pmu_idx(cpu), + return __rapl_cpu_online(rapl_pmus_pkg, get_rapl_pmu_idx(cpu), get_rapl_pmu_cpumask(cpu), cpu); } @@ -642,8 +643,8 @@ static int rapl_check_hw_unit(void) /* protect rdmsrl() to handle virtualization */ if (rdmsrl_safe(rapl_model->msr_power_unit, &msr_rapl_power_unit_bits)) return -1; - for (i = 0; i < NR_RAPL_DOMAINS; i++) - rapl_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; + for (i = 0; i < NR_RAPL_PKG_DOMAINS; i++) + rapl_pkg_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; switch (rapl_model->unit_quirk) { /* @@ -653,11 +654,11 @@ static int rapl_check_hw_unit(void) * of 2. Datasheet, September 2014, Reference Number: 330784-001 " */ case RAPL_UNIT_QUIRK_INTEL_HSW: - rapl_hw_unit[PERF_RAPL_RAM] = 16; + rapl_pkg_hw_unit[PERF_RAPL_RAM] = 16; break; /* SPR uses a fixed energy unit for Psys domain. */ case RAPL_UNIT_QUIRK_INTEL_SPR: - rapl_hw_unit[PERF_RAPL_PSYS] = 0; + rapl_pkg_hw_unit[PERF_RAPL_PSYS] = 0; break; default: break; @@ -672,9 +673,9 @@ static int rapl_check_hw_unit(void) * if hw unit is 32, then we use 2 ms 1/200/2 */ rapl_timer_ms = 2; - if (rapl_hw_unit[0] < 32) { + if (rapl_pkg_hw_unit[0] < 32) { rapl_timer_ms = (1000 / (2 * 100)); - rapl_timer_ms *= (1ULL << (32 - rapl_hw_unit[0] - 1)); + rapl_timer_ms *= (1ULL << (32 - rapl_pkg_hw_unit[0] - 1)); } return 0; } @@ -684,12 +685,12 @@ static void __init rapl_advertise(void) int i; pr_info("API unit is 2^-32 Joules, %d fixed counters, %llu ms ovfl timer\n", - hweight32(rapl_cntr_mask), rapl_timer_ms); + hweight32(rapl_pkg_cntr_mask), rapl_timer_ms); - for (i = 0; i < NR_RAPL_DOMAINS; i++) { - if (rapl_cntr_mask & (1 << i)) { + for (i = 0; i < NR_RAPL_PKG_DOMAINS; i++) { + if (rapl_pkg_cntr_mask & (1 << i)) { pr_info("hw unit of domain %s 2^-%d Joules\n", - rapl_domain_names[i], rapl_hw_unit[i]); + rapl_pkg_domain_names[i], rapl_pkg_hw_unit[i]); } } } @@ -746,71 +747,71 @@ static int __init init_rapl_pmus(struct rapl_pmus **rapl_pmus_ptr) } static struct rapl_model model_snb = { - .events = BIT(PERF_RAPL_PP0) | + .pkg_events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_PP1), .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_msrs, + .rapl_pkg_msrs = intel_rapl_msrs, }; static struct rapl_model model_snbep = { - .events = BIT(PERF_RAPL_PP0) | + .pkg_events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_msrs, + .rapl_pkg_msrs = intel_rapl_msrs, }; static struct rapl_model model_hsw = { - .events = BIT(PERF_RAPL_PP0) | + .pkg_events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM) | BIT(PERF_RAPL_PP1), .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_msrs, + .rapl_pkg_msrs = intel_rapl_msrs, }; static struct rapl_model model_hsx = { - .events = BIT(PERF_RAPL_PP0) | + .pkg_events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_msrs, + .rapl_pkg_msrs = intel_rapl_msrs, }; static struct rapl_model model_knl = { - .events = BIT(PERF_RAPL_PKG) | + .pkg_events = BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM), .unit_quirk = RAPL_UNIT_QUIRK_INTEL_HSW, .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_msrs, + .rapl_pkg_msrs = intel_rapl_msrs, }; static struct rapl_model model_skl = { - .events = BIT(PERF_RAPL_PP0) | + .pkg_events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM) | BIT(PERF_RAPL_PP1) | BIT(PERF_RAPL_PSYS), .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_msrs, + .rapl_pkg_msrs = intel_rapl_msrs, }; static struct rapl_model model_spr = { - .events = BIT(PERF_RAPL_PP0) | + .pkg_events = BIT(PERF_RAPL_PP0) | BIT(PERF_RAPL_PKG) | BIT(PERF_RAPL_RAM) | BIT(PERF_RAPL_PSYS), .unit_quirk = RAPL_UNIT_QUIRK_INTEL_SPR, .msr_power_unit = MSR_RAPL_POWER_UNIT, - .rapl_msrs = intel_rapl_spr_msrs, + .rapl_pkg_msrs = intel_rapl_spr_msrs, }; static struct rapl_model model_amd_hygon = { - .events = BIT(PERF_RAPL_PKG), + .pkg_events = BIT(PERF_RAPL_PKG), .msr_power_unit = MSR_AMD_RAPL_POWER_UNIT, - .rapl_msrs = amd_rapl_msrs, + .rapl_pkg_msrs = amd_rapl_pkg_msrs, }; static const struct x86_cpu_id rapl_model_match[] __initconst = { @@ -874,16 +875,16 @@ static int __init rapl_pmu_init(void) rapl_model = (struct rapl_model *) id->driver_data; - rapl_msrs = rapl_model->rapl_msrs; + rapl_msrs = rapl_model->rapl_pkg_msrs; - rapl_cntr_mask = perf_msr_probe(rapl_msrs, PERF_RAPL_MAX, - false, (void *) &rapl_model->events); + rapl_pkg_cntr_mask = perf_msr_probe(rapl_msrs, PERF_RAPL_PKG_EVENTS_MAX, + false, (void *) &rapl_model->pkg_events); ret = rapl_check_hw_unit(); if (ret) return ret; - ret = init_rapl_pmus(&rapl_pmus); + ret = init_rapl_pmus(&rapl_pmus_pkg); if (ret) return ret; @@ -896,7 +897,7 @@ static int __init rapl_pmu_init(void) if (ret) goto out; - ret = perf_pmu_register(&rapl_pmus->pmu, "power", -1); + ret = perf_pmu_register(&rapl_pmus_pkg->pmu, "power", -1); if (ret) goto out1; @@ -907,7 +908,7 @@ static int __init rapl_pmu_init(void) cpuhp_remove_state(CPUHP_AP_PERF_X86_RAPL_ONLINE); out: pr_warn("Initialization failed (%d), disabled\n", ret); - cleanup_rapl_pmus(rapl_pmus); + cleanup_rapl_pmus(rapl_pmus_pkg); return ret; } module_init(rapl_pmu_init); @@ -915,7 +916,7 @@ module_init(rapl_pmu_init); static void __exit intel_rapl_exit(void) { cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_RAPL_ONLINE); - perf_pmu_unregister(&rapl_pmus->pmu); - cleanup_rapl_pmus(rapl_pmus); + perf_pmu_unregister(&rapl_pmus_pkg->pmu); + cleanup_rapl_pmus(rapl_pmus_pkg); } module_exit(intel_rapl_exit); From patchwork Thu Jul 11 10:24:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812188 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) (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 AA476131E4B; Thu, 11 Jul 2024 10:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693838; cv=fail; b=WUs/6tCMhc5fmww3k2x8NKw+hsfN7p9CIvFg/E6MYo7KKmBw2bwqpaGkZnUaSlGMxn8fFo7weSXQHjbzgVkysm+ZDKKEKMNYSC+Hiwo04KXSkTMmSeo79aNt5wOFhwNcLltOee5IUfNTQgfK7JWZxdoDQV61+m69HJqNTSyVpak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693838; c=relaxed/simple; bh=IBH+Xufd3E6IqOS6Hu6xkjZh0Frm+F2pU0RDYfu7xMk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CxPtF9YEGts2vnG3kirMWTTecQC0l9hW0KmLCK0bId/Vp+cGNALslifLFXJ9XzQ6H1TPi3bOClBKdXh0hyCMEtLm9wc+UtXJloLPqZQ6nz28pHQtWdg1aiOcPjHN9UqljUh3CwypJRjj6LK4PIr/C15TrIE0QRQW8SbjuE8RGLs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=evqTExc7; arc=fail smtp.client-ip=40.107.100.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="evqTExc7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MntmCKYdTFtcZrfwHV9KDIHJD1yn0OWjQyjw1h8YTI1x4BZ5lXjQnw/Y13UtMW8uVKVpQln0bjmzo57MLkziU5BHFKRBy+mfuLE9eOJnZHQfaGmwsJ0d7xxkP4hOxuuZGIGXnBDL7tMAdLyOFDRVo+rTcSCoywB+bh1Tm12lizCNJ8PSoBuQYW5TuL1l8il02g1zwpWups4LRHtIpMsSFoF+3wbqyFrniopf6pUt3R9c+KpGGaq6tHka7LUva1YqT+O8AYtDGxNdr273QGdESxi8Ws6K7M3s5+Jj9Ec/pvwFbmg9q+M/BEG0WxJ0A0w3XUl861S2MtQpIa3+HFihPg== 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=tjF1E3UxHyTnhI0xHQ1zPpnsRhf1n+zD5bM302f38tE=; b=ATotB3oirjCi14vWIMbMmBb8U+8upLuPFJ7PqXKcdZQyKNOb8uUXzqK78dIK1WNAfIwasZ5IgA+lqBdTyMXp2deGwg+1/Kej4q2eW3AFuhXibucTJSTL6HB0Qz/t7+DfVeueEKi/ku00/vDLq21gSymieE6qM2mCbt3z6HlkBhKUOdUqzdqZPyEoLCJK60ocDtoo5K/tEnFBp1Rk8aymiC/8esatNWIdCrmS4Kq8XYJZXcjPG41t2npX/hhUPuZXI9qtxW1H0QcM7grrmtwDJXqvw7uqk6IaTUbrxKaK9c1vR6JCL1027M1rCq5YRVbDRl86atoxgMhsb7jKYj6QfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tjF1E3UxHyTnhI0xHQ1zPpnsRhf1n+zD5bM302f38tE=; b=evqTExc74kMNP6YkjXK1NW+qdLQz6r0eXNsHkb3Gfw6RHisf4dj44vjR4vnJpQgpag0nt8kzMqZ++OIABL0Qh4QO+qfqpmHXYXFjfHTygfokRQNikahVj7JzTElsUgPkwcOuLUGet7CR9vvZfcssQyiXvFeDiOf8G6+1eiEMdvU= Received: from SA9PR03CA0001.namprd03.prod.outlook.com (2603:10b6:806:20::6) by PH7PR12MB8121.namprd12.prod.outlook.com (2603:10b6:510:2b5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Thu, 11 Jul 2024 10:30:32 +0000 Received: from SA2PEPF00003AE9.namprd02.prod.outlook.com (2603:10b6:806:20:cafe::4d) by SA9PR03CA0001.outlook.office365.com (2603:10b6:806:20::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Thu, 11 Jul 2024 10:30:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AE9.mail.protection.outlook.com (10.167.248.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:30:32 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:30:24 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 09/11] perf/x86/rapl: Remove the global variable rapl_msrs Date: Thu, 11 Jul 2024 10:24:37 +0000 Message-ID: <20240711102436.4432-10-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE9:EE_|PH7PR12MB8121:EE_ X-MS-Office365-Filtering-Correlation-Id: 90cf81d3-bc14-4b97-c210-08dca1947e55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|7416014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: eE92wSK9BRXkftTZsXd1B9weY+9llApVn/GvzYPRk3iAIhQ9se+l1VDzCcRFfscT3I4gquVun2K5OF/OyodD04Ji8kjjy2dYCVCt5nou6jB2jJCQhM0+2tTlUbBnxflEaPNwjeYyBUkp9CFCqTWOASX822apl5zmxHU6Ugw7VZV7cdcXFlEkW4SyRjE/UdY96Y4rglTFCwd4wjVY7bJ3Yj9g1V+kb2NJGhh1KjA+0NYLeIWk5STqjdiZfv7RGvbU0iDQ+aDKUlZSaPIydX45Rf33Bv1djtP8H+Tf0jrTL74aFFXQBCPD1QDjiof4OJhjtghZaXeLe4YnhwrKq8Ginl9GG/Vm2v9XNjOy6cR2sKMqFRIcFvCYukbqCGw6pohrFkhDSW8xU4N+AUskA6rn+uJpzsXy/qEAwOkwjD9LMlv/nRSyECbYhjHQUMfr7qaMwIKg3lF2zBB58Xh9wOFWI5TxY/wpyijSBM3YPUTtf3kRifE/xJhU9yl1uIoa1kJaCAEmjWRxEhOfQeG9moEQErtJkdgfOIyFwjqai4C9sL4Yf3yNk+vH/KMZ368JOBtXM94R+26CNiDaYqbGH3fyMq61Z/U7UC3ocBAl470n0My28/yXwwMmrJODzACN12UUZqIVsq3P+HdVC97ex7v0ysPfuW4OR4RIGkKV3lswzkS5JeOeVkS4OTSHsUdJq2fgZ9RREhaoQocU4QUpwuaOe9SoRBK6h/ZA60YEkRwIVyzCephyI4qLoNMGr6GGlHZGdhIFN1vSm1lISeg/ZLWM8glPSgxlAv98hWPHBSIdE+Xuk73liK7CbpKnTYTnS89VEqn2wdILUvBi0Zf6WVvX7UGF+5J05LtYZ8br59+1jiQxlVrv6DIX3SN+31IwoCYiHi7bv+wnZDOhyJw6Ic5EoXOTw+BuUN1yXtN+V5Qm4CRwfxSo1C2lBlg+TgGOjakVon4MqJBkpdY8Mym18DQ7HuzTY3k/CgWq8cZeBzthdHHjoimnkuvCHYTBokT9PU7AMOuw/tB9qQjIc2KzE9TkR1gy1gXk9zot/ng4apmDhA9NdJoqPBjE7cqXp2g3fIm1ipoDVTXUizg9BQnAng5qRrCXdHp5KJqwz6+GsFJLudNh8SZSj6uhOBILX+vhQe2YsgK2xhX+IeqZYdem5JPzffTGURlqxb6YCBitjhF6wUlPr3VAMwj4KXN71NL3RFJAsCgUuoZIg4xsjokSvygtuu+7co95OiR89I5O/tVfJ9pBLQMiK/iN3jXt4/GCxIQ0gxAVK21TVcmBcWAEqEfzyyIwnTA3dR1OA4RIhbZTl/ElaJ+rIZcfaqTptqrZTI6ib0lT9CmjwredtyAvxb5m6/jy8WDKO7iNotR7GvsZfs5BHjvNOPdJnCZE78HQOcnEKn6OgAf1jGcbNTljm/gPNXQ+19So32ATlFzijAV+Ko+TwrK6PijdzR7UMWkyY4Hs X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:30:32.4516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90cf81d3-bc14-4b97-c210-08dca1947e55 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8121 After making the rapl_model struct global, the rapl_msrs global variable isn't needed, so remove it. Also it will be cleaner when new per-core scope PMU is added. As we will need to maintain two rapl_msrs array(one for per-core scope and one for package scope PMU), inside the rapl_model struct. Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui --- arch/x86/events/rapl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 9beded3d4a14..7691497042e9 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -145,7 +145,6 @@ static int rapl_pkg_hw_unit[NR_RAPL_PKG_DOMAINS] __read_mostly; static struct rapl_pmus *rapl_pmus_pkg; static unsigned int rapl_pkg_cntr_mask; static u64 rapl_timer_ms; -static struct perf_msr *rapl_msrs; static struct rapl_model *rapl_model; /* @@ -387,7 +386,7 @@ static int rapl_pmu_event_init(struct perf_event *event) return -EINVAL; event->cpu = rapl_pmu->cpu; event->pmu_private = rapl_pmu; - event->hw.event_base = rapl_msrs[bit].msr; + event->hw.event_base = rapl_model->rapl_msrs[bit].msr; event->hw.config = cfg; event->hw.idx = bit; @@ -875,9 +874,7 @@ static int __init rapl_pmu_init(void) rapl_model = (struct rapl_model *) id->driver_data; - rapl_msrs = rapl_model->rapl_pkg_msrs; - - rapl_pkg_cntr_mask = perf_msr_probe(rapl_msrs, PERF_RAPL_PKG_EVENTS_MAX, + rapl_pkg_cntr_mask = perf_msr_probe(rapl_model->rapl_msrs, PERF_RAPL_PKG_EVENTS_MAX, false, (void *) &rapl_model->pkg_events); ret = rapl_check_hw_unit(); From patchwork Thu Jul 11 10:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812431 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2069.outbound.protection.outlook.com [40.107.236.69]) (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 F0EAD1B86F3; Thu, 11 Jul 2024 10:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693860; cv=fail; b=T+6hafPjOxhY1Or9r76ShrlT8UkYMTD29K+b8PBlHz7ceuTk126rnKfipytg4EbaHxZVL1HHO/+7DRKK/SwpG/E3qrataqqQkjJyV+b4LMt7qqrE8hmnKApMTkXIn3Nrutb2mJEWboay3CmDwW1QSCx3SmEVvT4ThWjUZmh+7lc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693860; c=relaxed/simple; bh=VkKMggvbgJsPtH8aezMHKemKAJiVcVD/3cp4cq3ecpI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TqCShjSbnZhcBM0rMgpPw/MInIeJCouS2l9VxX1t0XbR4KNOELP6A1mjLCy7pC7mx+lYag8Lh6+AjFaw2VzzM+Cj07+51RI9PL2xdYo4TC4yucQuWZFjyXoo1VMcnaGlLd2WXdonGoslUcSwL1uvl7RNPL3A/PYXX8/ZVkxqn8I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=qQd8VESk; arc=fail smtp.client-ip=40.107.236.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qQd8VESk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bw6/AXemMApSjoJDDmmGNrOVrEg7VckvCD1pIAV5KfkC3MXZ0bEI1BZ7+3ccp7pCY3+wTpY+y1zPCdAapFZPv3mxuMkRnx7M5h/d5lWroRQiwS6P4XkApdVTmv2H6y6x7IAMSMatRHM9GdcRDoCw6+ajEjjPGRrUP59/ycT+rq5Xcpy7xUqlRxjNmWf2//QRuzsWGArCyil1KsP7qx/1WHstDdcLz97+GzuWbeMMs0iLz57H2vvDeSIM+POOA+Mplxayo+k+fSM2QXYoAXhU2zQ9Y5M8o6s0hdlT69oJ04ASIp/jT0SCBnp+TULgWhGSd5ecIAmSsH6hSfPMN7yYgw== 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=IN387qIp/T5RlCg2qK6ewwsa2aywr2Ta2WftVnHVx0o=; b=YqPS3oRiRNrDpZuv73a/L3GRwNqj1y9yt8vPwWNx4DZxPJxWiqOXoL7uMsNQ5wJNm53rEnhrqtkz53Rb3QJsNCUguD4PJhqG+W2HP3b5cRiPh2t5KrYcVFizEUOZVgjQVopSV4yMm4FoF62PnLhWZOT5RBwsGSxM4uMfmtkIPau7lVdz0jXk4yryR/3mOgG4RrP7n91VSdMtfXOIqivp5+XCYQt1/9ENGnGAVsoeTMhOOHnf45P3nf/029L2JMJjb3MutfeeD26jVPd5VEuyzz7AHsW+yvIdliK22+SmrvjMaNW64+Z7XdjbQkPQfYrScK2DAKMu1Kih9USXegxAXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IN387qIp/T5RlCg2qK6ewwsa2aywr2Ta2WftVnHVx0o=; b=qQd8VESkHtf24rvaRLxSv+slKTMkUqAoas9pVvKdFDVmMsLBCNIwLByIBdwhgNxYjx2Ywp9/eLDq4P+HNQyABVTWcbuafD+4kcNX539vZbbaF3rRFvd5VtR6L5xNPgTB+XXOPfCsg5o6HTw2Yq2cWRoQbQiW0OGWkzssWgxGNz8= Received: from SA9PR13CA0147.namprd13.prod.outlook.com (2603:10b6:806:27::32) by CH0PR12MB8550.namprd12.prod.outlook.com (2603:10b6:610:192::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.19; Thu, 11 Jul 2024 10:30:54 +0000 Received: from SA2PEPF00003AEB.namprd02.prod.outlook.com (2603:10b6:806:27:cafe::6) by SA9PR13CA0147.outlook.office365.com (2603:10b6:806:27::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.22 via Frontend Transport; Thu, 11 Jul 2024 10:30:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AEB.mail.protection.outlook.com (10.167.248.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:30:53 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:30:44 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 10/11] perf/x86/rapl: Add per-core energy counter support for AMD CPUs Date: Thu, 11 Jul 2024 10:24:38 +0000 Message-ID: <20240711102436.4432-11-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AEB:EE_|CH0PR12MB8550:EE_ X-MS-Office365-Filtering-Correlation-Id: 13801b32-cdda-4017-1f4b-08dca1948b22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|7416014|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: HjnwaY/ZuwCsM2e/dsRVelwzeLtyoDum+Xcw/tGb/8ZFrcxHSdMJXFY87PWmzoNIJmQXgqKtq4ri7AIhq38M+Zza75V/FR0KU32cGwl7P2gOaIAIPwyFKsHCYJQhSJ37DVYIFeU3JHRPyAuRAaG4zOCgx/I44eG5gX8VdsvNkcfGAfaCG6hARXmHNMASVQNtz9iKxAZIySftnZCqyW1SOwi5bRn1kvxWBoX4ANkeLt0EZeLpIrpEyaL2RsBgGOk7Qq4JN/FcKxR7eiwGa6jmLJQGhrFMDXFN1e5yxZHJZ9WDm25dlBVjHRnQQkYODVvis8OP3443ugaavvhwl+5q4qik5QXeKpevY0V7vh/olhOSH9hMUmNrOMa+aio5vwRXU2qe7itveqIKrzlgMb6d1s6UcRm3KT1uNo9tLvrseWiCczDen56GnlmUIFXzLzZEnW3LLTLee9idvHOAUmRN6iysvcFkD9f25dpd/PZf4Gx6tpcVB3zBQzxpprnwxF7P6avj9yrTL65JlqyDUsVdNfxEEW45LLcvzHlJxY5kdS8BMFBw+5Vt3oGTgysE2eCp0zXKtr1TJ7C/rAU68gRyYNy5nIGFSsz+3/0Xe2DfgR3KsgilWWERox/fQvr8jMTzouyv4ybxxExbPoTQtfckwbncw+7Mm6CO5hcQj0RUQgArhM6FnAx+pY7Zbe8/ZntSPkgh/zxwfdOXZ9QGwlRVnAqEDBjj/6V8Q7hvoGHboSBVOuqu0nd4tWc1Wl0Wo8lfE1c3Dq17ETCjpD6deHTTjuhceoBOL0jfs6667mu5QQd2YNEWhR1ft7kYZzG0pi+00b0LjfvwJ3ORugb1Sw6J7HnqyQ5E7Wdu7ttSdVreveLRtaAqwsCVwoSSBigIkmBEJh0pYqmRoinFPZhZtAY36d/9Nte1TCByqX/txkeHxPCqi2Hg8B510A6laWOPfYlK6KQNuoBOhPcQ5TiBh+0g+HYH8trdGAWWGacVwRC5Gi1LLgEBZFsAnu+XQBpS2NKwAB7AKthBmKBDGmo1aPS17rDfId9zSnB+QEHZvQuKVHK2ujviNLmpT/1dy5wqERfTeT91yU1elj6CVNOv13HaHtaviM1tWO8JQeQh0EsKuB30dApoNPV+ojkPO8dp0Y/5qo79WRFS7WRBNZFW4wT+mzhoRx9lCOwXizyZVRBk/kY1pGFh49OTrTBf0yKGacUPBTPL3Vkb//2+kYhfBI2o4hOUycjke+GIT7/uEngK2qldlqSA9Mh9prXgTLRCurAchzQroml3xR7ZYXX6XA6DeoBMRSpg7QwN2Pt7V1dEcG4PSUqSe5RyBLyOlOjXIMo9blLuxzVq6Ev/HrrgLKEWUSGdWn/Pd0fCxl9zZ3b9pEucWC7KXOkYlTK27IqqryKITf9qyBNukn8FfDUZfeKAcY6vx/HjR9ezgUUcvxjlCwabEiWwZjA0r2RqzQHl7rcU9f7h55A1TgQa6iaXmCEsxA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:30:53.8767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13801b32-cdda-4017-1f4b-08dca1948b22 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AEB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8550 Add a new "power_per_core" PMU and "energy-per-core" event for monitoring energy consumption by each core. The existing energy-cores event aggregates the energy consumption at the package level. This new event aligns with the AMD's per_core energy counters. Tested the package level and core level PMU counters with workloads pinned to different CPUs. Results with workload pinned to CPU 1 in core 1 on a AMD Zen4 Genoa machine: $ perf stat -a --per-core -e power_per_core/energy-per-core/ sleep 1 Performance counter stats for 'system wide': S0-D0-C0 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C1 1 5.72 Joules power_per_core/energy-per-core/ S0-D0-C2 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C3 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C4 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C5 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C6 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C7 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C8 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C9 1 0.02 Joules power_per_core/energy-per-core/ S0-D0-C10 1 0.02 Joules power_per_core/energy-per-core/ Signed-off-by: Dhananjay Ugwekar --- Changes in v4: * Reorder the cleanup order of per-core and per-pkg PMU (Rui) * Add rapl_core_hw_unit variable to store the per-core PMU unit (Rui) * Use the newly added hw_unit in rapl_scale() and rapl_advertise() functions * Add a new argument in rapl_scale() to differentiate between per-core and per-pkg events. --- arch/x86/events/rapl.c | 190 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 171 insertions(+), 19 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 7691497042e9..91eb9850df9b 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -39,6 +39,10 @@ * event: rapl_energy_psys * perf code: 0x5 * + * per_core counter: consumption of a single physical core + * event: rapl_energy_per_core (power_per_core PMU) + * perf code: 0x1 + * * We manage those counters as free running (read-only). They may be * use simultaneously by other tools, such as turbostat. * @@ -81,6 +85,13 @@ enum perf_rapl_pkg_events { NR_RAPL_PKG_DOMAINS = PERF_RAPL_PKG_EVENTS_MAX, }; +enum perf_rapl_core_events { + PERF_RAPL_PER_CORE = 0, /* per-core */ + + PERF_RAPL_CORE_EVENTS_MAX, + NR_RAPL_CORE_DOMAINS = PERF_RAPL_CORE_EVENTS_MAX, +}; + static const char *const rapl_pkg_domain_names[NR_RAPL_PKG_DOMAINS] __initconst = { "pp0-core", "package", @@ -89,6 +100,10 @@ static const char *const rapl_pkg_domain_names[NR_RAPL_PKG_DOMAINS] __initconst "psys", }; +static const char *const rapl_core_domain_names[NR_RAPL_CORE_DOMAINS] __initconst = { + "per-core", +}; + /* * event code: LSB 8 bits, passed in attr->config * any other bit is reserved @@ -135,15 +150,20 @@ enum rapl_unit_quirk { struct rapl_model { struct perf_msr *rapl_pkg_msrs; + struct perf_msr *rapl_core_msrs; unsigned long pkg_events; + unsigned long core_events; unsigned int msr_power_unit; enum rapl_unit_quirk unit_quirk; }; /* 1/2^hw_unit Joule */ static int rapl_pkg_hw_unit[NR_RAPL_PKG_DOMAINS] __read_mostly; +static int rapl_core_hw_unit __read_mostly; static struct rapl_pmus *rapl_pmus_pkg; +static struct rapl_pmus *rapl_pmus_core; static unsigned int rapl_pkg_cntr_mask; +static unsigned int rapl_core_cntr_mask; static u64 rapl_timer_ms; static struct rapl_model *rapl_model; @@ -182,19 +202,25 @@ static inline u64 rapl_read_counter(struct perf_event *event) return raw; } -static inline u64 rapl_scale(u64 v, int cfg) +static inline u64 rapl_scale(u64 v, int cfg, bool per_core_event) { - if (cfg > NR_RAPL_PKG_DOMAINS) { + if ((!per_core_event && cfg > NR_RAPL_PKG_DOMAINS) || + (per_core_event && cfg > NR_RAPL_CORE_DOMAINS)) { pr_warn("Invalid domain %d, failed to scale data\n", cfg); return v; } + int hw_unit = rapl_pkg_hw_unit[cfg - 1]; + + if (per_core_event) + hw_unit = rapl_core_hw_unit; + /* * scale delta to smallest unit (1/2^32) * users must then scale back: count * 1/(1e9*2^32) to get Joules * or use ldexp(count, -32). * Watts = Joules/Time delta */ - return v << (32 - rapl_pkg_hw_unit[cfg - 1]); + return v << (32 - hw_unit); } static u64 rapl_event_update(struct perf_event *event) @@ -203,6 +229,7 @@ static u64 rapl_event_update(struct perf_event *event) u64 prev_raw_count, new_raw_count; s64 delta, sdelta; int shift = RAPL_CNTR_WIDTH; + struct rapl_pmus *curr_rapl_pmus; prev_raw_count = local64_read(&hwc->prev_count); do { @@ -221,7 +248,12 @@ static u64 rapl_event_update(struct perf_event *event) delta = (new_raw_count << shift) - (prev_raw_count << shift); delta >>= shift; - sdelta = rapl_scale(delta, event->hw.config); + curr_rapl_pmus = container_of(event->pmu, struct rapl_pmus, pmu); + + if (curr_rapl_pmus == rapl_pmus_core) + sdelta = rapl_scale(delta, event->hw.config, true); + else + sdelta = rapl_scale(delta, event->hw.config, false); local64_add(sdelta, &event->count); @@ -352,9 +384,13 @@ static int rapl_pmu_event_init(struct perf_event *event) u64 cfg = event->attr.config & RAPL_EVENT_MASK; int bit, ret = 0; struct rapl_pmu *rapl_pmu; + struct rapl_pmus *curr_rapl_pmus; /* only look at RAPL events */ - if (event->attr.type != rapl_pmus_pkg->pmu.type) + if (event->attr.type == rapl_pmus_pkg->pmu.type || + (rapl_pmus_core && event->attr.type == rapl_pmus_core->pmu.type)) + curr_rapl_pmus = container_of(event->pmu, struct rapl_pmus, pmu); + else return -ENOENT; /* check only supported bits are set */ @@ -364,7 +400,8 @@ static int rapl_pmu_event_init(struct perf_event *event) if (event->cpu < 0) return -EINVAL; - event->event_caps |= PERF_EV_CAP_READ_ACTIVE_PKG; + if (curr_rapl_pmus == rapl_pmus_pkg) + event->event_caps |= PERF_EV_CAP_READ_ACTIVE_PKG; if (!cfg || cfg >= NR_RAPL_PKG_DOMAINS + 1) return -EINVAL; @@ -373,7 +410,8 @@ static int rapl_pmu_event_init(struct perf_event *event) bit = cfg - 1; /* check event supported */ - if (!(rapl_pkg_cntr_mask & (1 << bit))) + if (!(rapl_pkg_cntr_mask & (1 << bit)) && + !(rapl_core_cntr_mask & (1 << bit))) return -EINVAL; /* unsupported modes and filters */ @@ -381,12 +419,18 @@ static int rapl_pmu_event_init(struct perf_event *event) return -EINVAL; /* must be done before validate_group */ - rapl_pmu = cpu_to_rapl_pmu(event->cpu); + if (curr_rapl_pmus == rapl_pmus_core) { + rapl_pmu = curr_rapl_pmus->rapl_pmu[topology_logical_core_id(event->cpu)]; + event->hw.event_base = rapl_model->rapl_core_msrs[bit].msr; + } else { + rapl_pmu = curr_rapl_pmus->rapl_pmu[get_rapl_pmu_idx(event->cpu)]; + event->hw.event_base = rapl_model->rapl_pkg_msrs[bit].msr; + } + if (!rapl_pmu) return -EINVAL; event->cpu = rapl_pmu->cpu; event->pmu_private = rapl_pmu; - event->hw.event_base = rapl_model->rapl_msrs[bit].msr; event->hw.config = cfg; event->hw.idx = bit; @@ -415,17 +459,38 @@ static struct attribute_group rapl_pmu_attr_group = { .attrs = rapl_pmu_attrs, }; +static ssize_t rapl_get_attr_per_core_cpumask(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cpumap_print_to_pagebuf(true, buf, rapl_pmus_core->cpumask); +} + +static struct device_attribute dev_attr_per_core_cpumask = __ATTR(cpumask, 0444, + rapl_get_attr_per_core_cpumask, + NULL); + +static struct attribute *rapl_pmu_per_core_attrs[] = { + &dev_attr_per_core_cpumask.attr, + NULL, +}; + +static struct attribute_group rapl_pmu_per_core_attr_group = { + .attrs = rapl_pmu_per_core_attrs, +}; + RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); RAPL_EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); RAPL_EVENT_ATTR_STR(energy-psys, rapl_psys, "event=0x05"); +RAPL_EVENT_ATTR_STR(energy-per-core, rapl_per_core, "event=0x01"); RAPL_EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); RAPL_EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); RAPL_EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); RAPL_EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); RAPL_EVENT_ATTR_STR(energy-psys.unit, rapl_psys_unit, "Joules"); +RAPL_EVENT_ATTR_STR(energy-per-core.unit, rapl_per_core_unit, "Joules"); /* * we compute in 0.23 nJ increments regardless of MSR @@ -435,6 +500,7 @@ RAPL_EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890 RAPL_EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); RAPL_EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); RAPL_EVENT_ATTR_STR(energy-psys.scale, rapl_psys_scale, "2.3283064365386962890625e-10"); +RAPL_EVENT_ATTR_STR(energy-per-core.scale, rapl_per_core_scale, "2.3283064365386962890625e-10"); /* * There are no default events, but we need to create @@ -468,6 +534,13 @@ static const struct attribute_group *rapl_attr_groups[] = { NULL, }; +static const struct attribute_group *rapl_per_core_attr_groups[] = { + &rapl_pmu_per_core_attr_group, + &rapl_pmu_format_group, + &rapl_pmu_events_group, + NULL, +}; + static struct attribute *rapl_events_cores[] = { EVENT_PTR(rapl_cores), EVENT_PTR(rapl_cores_unit), @@ -528,6 +601,18 @@ static struct attribute_group rapl_events_psys_group = { .attrs = rapl_events_psys, }; +static struct attribute *rapl_events_per_core[] = { + EVENT_PTR(rapl_per_core), + EVENT_PTR(rapl_per_core_unit), + EVENT_PTR(rapl_per_core_scale), + NULL, +}; + +static struct attribute_group rapl_events_per_core_group = { + .name = "events", + .attrs = rapl_events_per_core, +}; + static bool test_msr(int idx, void *data) { return test_bit(idx, (unsigned long *) data); @@ -565,6 +650,11 @@ static struct perf_msr amd_rapl_pkg_msrs[] = { [PERF_RAPL_PSYS] = { 0, &rapl_events_psys_group, NULL, false, 0 }, }; +static struct perf_msr amd_rapl_core_msrs[] = { + [PERF_RAPL_PER_CORE] = { MSR_AMD_CORE_ENERGY_STATUS, &rapl_events_per_core_group, + test_msr, false, RAPL_MSR_MASK }, +}; + static int __rapl_cpu_offline(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu_idx, const struct cpumask *event_cpumask, unsigned int cpu) { @@ -590,8 +680,14 @@ static int __rapl_cpu_offline(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu static int rapl_cpu_offline(unsigned int cpu) { - return __rapl_cpu_offline(rapl_pmus_pkg, get_rapl_pmu_idx(cpu), + int ret = __rapl_cpu_offline(rapl_pmus_pkg, get_rapl_pmu_idx(cpu), get_rapl_pmu_cpumask(cpu), cpu); + + if (ret == 0 && rapl_model->core_events) + ret = __rapl_cpu_offline(rapl_pmus_core, topology_logical_core_id(cpu), + topology_sibling_cpumask(cpu), cpu); + + return ret; } static int __rapl_cpu_online(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu_idx, @@ -629,8 +725,14 @@ static int __rapl_cpu_online(struct rapl_pmus *rapl_pmus, unsigned int rapl_pmu_ static int rapl_cpu_online(unsigned int cpu) { - return __rapl_cpu_online(rapl_pmus_pkg, get_rapl_pmu_idx(cpu), + int ret = __rapl_cpu_online(rapl_pmus_pkg, get_rapl_pmu_idx(cpu), get_rapl_pmu_cpumask(cpu), cpu); + + if (ret == 0 && rapl_model->core_events) + ret = __rapl_cpu_online(rapl_pmus_core, topology_logical_core_id(cpu), + topology_sibling_cpumask(cpu), cpu); + + return ret; } @@ -645,6 +747,8 @@ static int rapl_check_hw_unit(void) for (i = 0; i < NR_RAPL_PKG_DOMAINS; i++) rapl_pkg_hw_unit[i] = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; + rapl_core_hw_unit = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; + switch (rapl_model->unit_quirk) { /* * DRAM domain on HSW server and KNL has fixed energy unit which can be @@ -684,7 +788,7 @@ static void __init rapl_advertise(void) int i; pr_info("API unit is 2^-32 Joules, %d fixed counters, %llu ms ovfl timer\n", - hweight32(rapl_pkg_cntr_mask), rapl_timer_ms); + hweight32(rapl_pkg_cntr_mask) + hweight32(rapl_core_cntr_mask), rapl_timer_ms); for (i = 0; i < NR_RAPL_PKG_DOMAINS; i++) { if (rapl_pkg_cntr_mask & (1 << i)) { @@ -692,6 +796,10 @@ static void __init rapl_advertise(void) rapl_pkg_domain_names[i], rapl_pkg_hw_unit[i]); } } + + if (rapl_core_cntr_mask & (1 << PERF_RAPL_PER_CORE)) + pr_info("hw unit of domain %s 2^-%d Joules\n", + rapl_core_domain_names[PERF_RAPL_PER_CORE], rapl_core_hw_unit); } static void cleanup_rapl_pmus(struct rapl_pmus *rapl_pmus) @@ -712,14 +820,16 @@ static const struct attribute_group *rapl_attr_update[] = { NULL, }; -static int __init init_rapl_pmus(struct rapl_pmus **rapl_pmus_ptr) +static const struct attribute_group *rapl_per_core_attr_update[] = { + &rapl_events_per_core_group, +}; + +static int __init init_rapl_pmus(struct rapl_pmus **rapl_pmus_ptr, int nr_rapl_pmu, + const struct attribute_group **rapl_attr_groups, + const struct attribute_group **rapl_attr_update) { - int nr_rapl_pmu = topology_max_packages(); struct rapl_pmus *rapl_pmus; - if (!rapl_pmu_is_pkg_scope()) - nr_rapl_pmu *= topology_max_dies_per_package(); - rapl_pmus = kzalloc(struct_size(rapl_pmus, rapl_pmu, nr_rapl_pmu), GFP_KERNEL); if (!rapl_pmus) return -ENOMEM; @@ -809,8 +919,10 @@ static struct rapl_model model_spr = { static struct rapl_model model_amd_hygon = { .pkg_events = BIT(PERF_RAPL_PKG), + .core_events = BIT(PERF_RAPL_PER_CORE), .msr_power_unit = MSR_AMD_RAPL_POWER_UNIT, .rapl_pkg_msrs = amd_rapl_pkg_msrs, + .rapl_core_msrs = amd_rapl_core_msrs, }; static const struct x86_cpu_id rapl_model_match[] __initconst = { @@ -867,6 +979,11 @@ static int __init rapl_pmu_init(void) { const struct x86_cpu_id *id; int ret; + int nr_rapl_pmu = topology_max_packages() * topology_max_dies_per_package(); + int nr_cores = topology_max_packages() * topology_num_cores_per_package(); + + if (rapl_pmu_is_pkg_scope()) + nr_rapl_pmu = topology_max_packages(); id = x86_match_cpu(rapl_model_match); if (!id) @@ -874,17 +991,34 @@ static int __init rapl_pmu_init(void) rapl_model = (struct rapl_model *) id->driver_data; - rapl_pkg_cntr_mask = perf_msr_probe(rapl_model->rapl_msrs, PERF_RAPL_PKG_EVENTS_MAX, + rapl_pkg_cntr_mask = perf_msr_probe(rapl_model->rapl_pkg_msrs, PERF_RAPL_PKG_EVENTS_MAX, false, (void *) &rapl_model->pkg_events); ret = rapl_check_hw_unit(); if (ret) return ret; - ret = init_rapl_pmus(&rapl_pmus_pkg); + ret = init_rapl_pmus(&rapl_pmus_pkg, nr_rapl_pmu, rapl_attr_groups, rapl_attr_update); if (ret) return ret; + if (rapl_model->core_events) { + rapl_core_cntr_mask = perf_msr_probe(rapl_model->rapl_core_msrs, + PERF_RAPL_CORE_EVENTS_MAX, false, + (void *) &rapl_model->core_events); + + ret = init_rapl_pmus(&rapl_pmus_core, nr_cores, + rapl_per_core_attr_groups, rapl_per_core_attr_update); + if (ret) { + /* + * If initialization of per_core PMU fails, reset per_core + * flag, and continue with power PMU initialization. + */ + pr_warn("Per-core PMU initialization failed (%d)\n", ret); + rapl_model->core_events = 0UL; + } + } + /* * Install callbacks. Core will call them for each online cpu. */ @@ -898,6 +1032,20 @@ static int __init rapl_pmu_init(void) if (ret) goto out1; + if (rapl_model->core_events) { + ret = perf_pmu_register(&rapl_pmus_core->pmu, "power_per_core", -1); + if (ret) { + /* + * If registration of per_core PMU fails, cleanup per_core PMU + * variables, reset the per_core flag and keep the + * power PMU untouched. + */ + pr_warn("Per-core PMU registration failed (%d)\n", ret); + cleanup_rapl_pmus(rapl_pmus_core); + rapl_model->core_events = 0UL; + } + } + rapl_advertise(); return 0; @@ -915,5 +1063,9 @@ static void __exit intel_rapl_exit(void) cpuhp_remove_state_nocalls(CPUHP_AP_PERF_X86_RAPL_ONLINE); + if (rapl_model->core_events) { + perf_pmu_unregister(&rapl_pmus_core->pmu); + cleanup_rapl_pmus(rapl_pmus_core); + } perf_pmu_unregister(&rapl_pmus_pkg->pmu); cleanup_rapl_pmus(rapl_pmus_pkg); } module_exit(intel_rapl_exit); From patchwork Thu Jul 11 10:24:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 812187 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2050.outbound.protection.outlook.com [40.107.102.50]) (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 B6C6415748F; Thu, 11 Jul 2024 10:31:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693881; cv=fail; b=XXgyy/0DdXeUqMDRbPgfJ00WXRIeqgtVNUmsDHPt/beoaklM7+f/OJ5i7XlnRv+QWuxnnmNvNxrdXvvv3pPTrDuJK9rcv6r/lPmEdg2aURPUTU0KlR8ny4HZ9VOE9HRMJX8u70BryZe9eBbKrTg/I3b4qEvpw6M8DxbHemnoD6c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720693881; c=relaxed/simple; bh=F2OuO5/pQYkhNLRUyk5L2tLI11gXz926ZzKgLJ7z+s8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TAyog4rtGXJFEn6OQYtl8uSkd2zmquHId30HbdYJXYpF+hf42hk2PEmtVGd+fnfNoiZ7xy8BnpNwYiGsvVgG14q7GscXklTAnAtGr0tJQpRBQipTiiBcDp6XA8noQ95oB5w/3nlZSeKr+4S/4ZILU5aN+2n2c1LvX8MDtn4FgNg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=qIYpM3pV; arc=fail smtp.client-ip=40.107.102.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qIYpM3pV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v8jUzWUaySCQiacklhAzcdMPcegH+wlLg0pVp5rN2uV+zq4Pmwecjn0AJlsffLgmW2vK6N2s/R6oAcyzqYQbvaAy6NngPal16IvHT1RdpeHm5acepPre5TTC3SgrEHA4aASy/BwbvKK251K1UtbWZG0kdTUaWvOZYRui7zc3V9J0o1efTjUjm8tUwdoalqQbqk4As1aVnV6/u0iAplGeHmTfM667xXqHxT4qsuHzBh/oj5MCQr45RYJrReSsBrRsYb3UP3g6FZQJIPoWSENqspll6QzVhyuf+/DNHFVQDmnj42DJYXZKWlPRMD0P1p0k3RCXh27BT80y2cl94rVTxQ== 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=UEo0HnXMWIwqRGr+UtqPMK5iAVHuDsC0gEq8KcRO6nw=; b=ZR4Z5x9qaCzWfXGtvBGlTQG5QvFUMp+NAgpOhC0RJJ/P4SjjQQtleMRkQX8Dbu/6xN5WZTxW++tTu31vtU/KyCQOC+B+aGUlfhNcubDxsbaRxJEAMhYazL9vAYAmaLog9L+hXGIFX3FS3QOjXjEWnYwk8dUVJRk3IIBFy9VQrmRTO6NcVyPGwb29rpf1/ukGAvO5E849nUWFj/5Y3NMq7zblCszv1DiOZWn4LFWXA8uaaUgXRrc6jdR0PWLSJ1NOFBcSJCSFLUSDfLhNXGDcRfiXNEtZUmpWZzz5Gj4Sa/KXmSeogTQvd/od2qH5eHNNDw3u8E9qTITT4yqc4mFyRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UEo0HnXMWIwqRGr+UtqPMK5iAVHuDsC0gEq8KcRO6nw=; b=qIYpM3pVLv3djrPdRdaTrthtivNQvMJCFIjm1V4cK3+j8MuYjSn9Kwk9Kk1kpOvqH9ABqP3B3pIb0RDsWVOGT+qxm9jbwwWgO1UCDGmXLJ2fKTDHmu8KgHS4jJxOu0p0iHoUDvUjBRwXmQh3ytRIS5wNOzQU0an6rP76tKPDiX0= Received: from SN7PR04CA0162.namprd04.prod.outlook.com (2603:10b6:806:125::17) by LV2PR12MB5725.namprd12.prod.outlook.com (2603:10b6:408:14c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.29; Thu, 11 Jul 2024 10:31:15 +0000 Received: from SA2PEPF00003AE7.namprd02.prod.outlook.com (2603:10b6:806:125:cafe::34) by SN7PR04CA0162.outlook.office365.com (2603:10b6:806:125::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23 via Frontend Transport; Thu, 11 Jul 2024 10:31:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00003AE7.mail.protection.outlook.com (10.167.248.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Thu, 11 Jul 2024 10:31:14 +0000 Received: from shatadru.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 05:31:05 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH v4 11/11] perf/x86/rapl: Remove the unused function cpu_to_rapl_pmu Date: Thu, 11 Jul 2024 10:24:39 +0000 Message-ID: <20240711102436.4432-12-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> References: <20240711102436.4432-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003AE7:EE_|LV2PR12MB5725:EE_ X-MS-Office365-Filtering-Correlation-Id: 58a7c42b-efc8-4fa9-85c1-08dca194978a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|82310400026|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: jJdqflXFTiiXRuHZw/AZO6UoF56pN5M4Ao79goOR/M1B/3nN53E/qabsApS0Z5JcPTyoGvQjnJJ345lqpv+ePfldFl2BUnU84d4vMWfTWlPoMw+80oSZ78m7ldsVpYS+A6shkof3jizNw9c0vbvxADc6tR39JXn2F4TsRl8Gt7fbhRbt5G9B90941o+kfUiaq+NtRPI/HgAZYocEhTysDiQarM3HJpMh2dxJBOt4GJ8iI7OrHT0nBd1JiGwI28Uv1tS+WmEQClNqpG9jpLjH8d2Gtrvd1hoF5AeRMMl+8rdIomOH7H2Xg+SFdoixW/YthMizQZq0aSRBPmj32O/nt0JUHWuxUAwKgRcEiH0pq6xvoapXLE/B3zRwsIJtmEErqjRSsCd4HOUseF0XiiQUXU+eDj6UIpGYcIEgHqBG1xKcH1dDrjJV16gsE9E+S4ZioiIW5Q6NkIMB3r9/FJXfyi5QKT2X/rqPQ179Gi+qwqN20wLJ+0VTPYxGO6ZJDUjSF++BhdzDFFa4oztbi99VtKpB8ne+S7GW0KPSxAniXq2gImIvdcofqkaSM1VrXMAEHfQh1qRM9rJ9CtkAvNfbBgk5FPTCVSzPoGTjt16ZFiSjEbvzRivHLy4ArhxsLmB+LoVWVliEQCboUcVP8Ll73H2KBiVbMMOQ7qc9PDLUsKAzb9+0+WWqqqk/IMoWtfSc1MG0Wi2z30MA/FBmyKDDUhPFpcn3gc921dttvoo6bN16lSJ4Rmjo+KzqS7uXroFhbU3c54jeawCvOZLPc7wbKvNTmSeY7ABAhWoGwolC6161Sk+pJMvEqkmaqwsSiF7QWrncnTaZNj2MWKNWLcPHsdgRCVHGthHbp1rkSZjzveIWzJwTpncIZC66/SyRGNdjmPGXMJfApRZNPIpKXoVn8i1dwn3ddgCepDv3OA6x7bReIYwMH4fCniggWEF/CxsXl+KtJ6TDJAiMq/ED2auZWi+pO6GF0NMWNHmzwVNMZYVVaEaVKDcoyjItGRDbcnMbkg4ghSBWIsO8LI1751Pq5vi92AHdaIRpMYUyFImWzhfNKh7yd16m8RN3d24+pE7+fCfXtztcJuYGMMK9tdgNP+YsWyqK9TdGMjKPKxnVZpaqLqn9OczjXOWw7dxx0wc/XBwDx1CQKAtI+gOft+bqH43Lm62kwqdPuL6Gd31FEoUByYUSjda35ADFNFszLlrkPyw8NZiFCxT4K16m6zcNeaBQYA654EMQ/aBrkqLiJPgyDN0u9riy8lue5nR2XF2H21eG63BwzVqj8k/5KmBeV+Ht2UNW8ZSyN6Zikq0mlMv6rph1cPELgu3wy6wFwXUz5uyXyWPM4rYL1jj20egzbdgG3zr2anNvSP5UULxoHCQ2e8XU9HqKE8vBHDtDnN8sXpYfpeVmRU+KeegYTeE5Y4TbQ6DfHYP+ZmONfu5Bblk/nPXGHsqab1b3a3jGfng4unO8KCBzqbMM41BFObKZxg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 10:31:14.6781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58a7c42b-efc8-4fa9-85c1-08dca194978a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003AE7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5725 After the addition of per-core counters support, this function does not work as the same CPU can be mapped to multiple rapl_pmu structs (package or per-core). So, remove it. Signed-off-by: Dhananjay Ugwekar --- arch/x86/events/rapl.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 91eb9850df9b..6edbf798a1a0 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -183,18 +183,6 @@ static inline const struct cpumask *get_rapl_pmu_cpumask(int cpu) topology_die_cpumask(cpu); } -static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu) -{ - unsigned int rapl_pmu_idx = get_rapl_pmu_idx(cpu); - - /* - * The unsigned check also catches the '-1' return value for non - * existent mappings in the topology map. - */ - return rapl_pmu_idx < rapl_pmus_pkg->nr_rapl_pmu ? - rapl_pmus_pkg->rapl_pmu[rapl_pmu_idx] : NULL; -} - static inline u64 rapl_read_counter(struct perf_event *event) { u64 raw;