From patchwork Mon Jun 24 05:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 807174 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.72]) (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 5B26D2564; Mon, 24 Jun 2024 06:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208825; cv=fail; b=Ts2ByaLESiEmaEVVih9icXO64uQz5BvIi5X2sX+hN3gZsn6eNge9za4EomRU+jNHw/4l6ysl0kSkFrHXuTomHd0Irn4tqb6zTRlx69KfHydrvBK5TzF55yNrtpCZWDx3ORNx45vTKgX7LaClnuG2KvK9EXKwO/fZGwpedablq+c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208825; c=relaxed/simple; bh=trjQ08VS9nqaEk4bElC0BEHF4z+L0KraXrOCGGgynmY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=emx+R/eyqmiJqOv6icd3szsQhHpMCC+b3+u2BOK43iuziFS76VG87DfxvBj2drSzt4N8Yunj29T5TAFAUMCxb2rJ57mZtQoE2I+qvoIb0bRL3e3LAmpBakXFdf4ZSaTKCLexcT/BvTXhXQiOROK3VvjhzJ3vgjLsw6jqA86fZI8= 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=BcSBpC3r; arc=fail smtp.client-ip=40.107.236.72 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="BcSBpC3r" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DpButckLIkYdmBXhLdGOPJPxU6wEg05fQnn3UmNMDMPzuElfq3rmnSgGjjiuZNS/6vPxDirDnxxWnj9KM4A3cChl8p/S3yyyQZkqidPbC4OSSItDm4vQcp2C0cfgkYYe/1mboW2G8rSzc6wBGb1TmLLgNbqhyVbH2EwnTcubizxb+j6mARq1zOfXiwuTRPcuMnFTap56WwKeqUGgo0uaHr4BKlPZ8mSwEMRq3u4AAEv2CFiNOfIU3zYMRzNvNujiLGG8gZ8VdWJ4u4z9FM+V/oXV1qImh6tJoAGMUq9fpo6lDy1k0WknFXXW7qWTdetJR3Xe94WFTrQl38SHdhjOaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=nig0DHr8BLxwu+43onKPqrDar4BGIuSM21jlS50W734=; b=JtacrWEbMYimqUG+3jSBio+IWyVvyxVBePuXnnsR4hXGRe84/4EInIm7ODt2POVkNHa4VA4bSr6Hxwd22ccNvG0zaNbD9QrV8ueJG2/pV1nzEbe6CTfwYOoyJzZC6Y+O1yF2JbqlKL5SpQwODKX2mpJaE2IEkJ9LEtkRa/pn58JT+eTLD6gflehXXRpLye4sqKUktIcSgxqGUhbHd6uB8jB+ts3IbS0wTljP+YP4JEkz1IVTisOg5pe+z0pU8ZNbTEDHeN23X25mGGXojJMkdJ93sMBwSZIgrdlQpTAtTeW7YuGX7kPEf3wX7Bh639+3TT6pIZCsUAPbzQBX5qSDKg== 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=nig0DHr8BLxwu+43onKPqrDar4BGIuSM21jlS50W734=; b=BcSBpC3rijFstV41o5mM+yLfzZjnKEgnaCUNRUxl0BJeIpnhyvEw/j4jocIIsDX/ibmruNSuF4qTT+JxVezAODEAqnzO87sjOi4sooSOzqyghohPhywd/YZ6idXv0aJIjRp/EAa59X6uZB2Sn9o8JhxXGJ6WxfL3xHx2ESkNM9o= Received: from BL1PR13CA0384.namprd13.prod.outlook.com (2603:10b6:208:2c0::29) by CY5PR12MB6057.namprd12.prod.outlook.com (2603:10b6:930:2e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.25; Mon, 24 Jun 2024 06:00:20 +0000 Received: from BN2PEPF000055E1.namprd21.prod.outlook.com (2603:10b6:208:2c0:cafe::c4) by BL1PR13CA0384.outlook.office365.com (2603:10b6:208:2c0::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.18 via Frontend Transport; Mon, 24 Jun 2024 06:00:20 +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 BN2PEPF000055E1.mail.protection.outlook.com (10.167.245.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.0 via Frontend Transport; Mon, 24 Jun 2024 06:00:19 +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; Mon, 24 Jun 2024 01:00:11 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Dhananjay Ugwekar Subject: [PATCH v3 01/10] x86/topology: Introduce topology_logical_core_id() Date: Mon, 24 Jun 2024 05:58:58 +0000 Message-ID: <20240624055907.7720-2-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624055907.7720-1-Dhananjay.Ugwekar@amd.com> References: <20240624055907.7720-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: BN2PEPF000055E1:EE_|CY5PR12MB6057:EE_ X-MS-Office365-Filtering-Correlation-Id: dcbcc1c6-c167-43f0-bca6-08dc9412ed89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|7416011|376011|36860700010|1800799021|82310400023|921017; X-Microsoft-Antispam-Message-Info: HyZjlKT9HI3b+fT1Sg2lXAN6RQyS8j8LWyZ6GdPsl8V6kBSleT3sQCVzFjlgqAItNohOj8u+Vwz0/1Qdl83QyJj2PCSTDEwNjdKatp9dsDuNQ01jPn6oBqf1k1GJ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W2tDQvoxtIL3/jeOtKSeAakXDI6utKO3kNXT13W/relrKzxMwNML9KQQIKytqeH5QApOt0U1+JklNVIWAzPch1D5WmIVR1B5VljXoFeHFp6E3xYu1XcbUP4/alzT3ZCMLIh6R3lhGSU5raDvyZvedkM53v/uwahzuUZvyuMVrJRGr4iwEHtZz5aGDWa08MZC/AdbMx2wMCRzyJ7HAlwiolvfW0CkiNoQ3XGHEZYFQEazMggxguMOHWg= 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:(13230037)(7416011)(376011)(36860700010)(1800799021)(82310400023)(921017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 06:00:19.4691 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dcbcc1c6-c167-43f0-bca6-08dc9412ed89 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: BN2PEPF000055E1.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6057 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 4fd3364dbc73..e1eeb42edeaf 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 Mon Jun 24 05:59:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 807173 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) (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 DCB342564; Mon, 24 Jun 2024 06:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208883; cv=fail; b=MRDiZVBYHZ0K6jI7EvxcZJtdXG+P+Pr8cg8liu6uOKajektBU488ozs/lFHUzXgVVCkMWaF6GOqIyVmQBULn5ZIsWfPFk7mAnRKUv8Lidf9vfCiRdk6pB/iEwpbBSVJet3ygpgXZvsrdiwrT00fYE/bKL3tqDdgDmTtvzr1hlyY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208883; c=relaxed/simple; bh=bdHqtKQgt7guqR41b+qTLiClw9pcS6FtJ1Uis4RlDfw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Aq4MHLnO/pd+jxD66NAJ41mvxicLLATAvWgNdGsxTjerj23urJ3aFLSxdw+hi+r9CHFWr2Xznv4HfHVJ3W+e7LugHHJsMqEhgvwWMMT5sGnKty4/rDRTDzibhlRIiDQbnLwHDbCnEK+1q0i2TkzWH8HQ59ChMMJlO9UivfNa/sI= 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=SV5h/ffx; arc=fail smtp.client-ip=40.107.220.82 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="SV5h/ffx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N6rj1EOU2plF/Yjx/iGdWsnsbDq5UOtSyaOr9SOlc2gfnmCfDXVN6b9ZnHpuYBWGrf6YGNp5Nu58kIWPnDsTJoFf4+XdXS2JJ6kKp7RweS5Bblh8nBo0/GlXKjoIHvOCpUS2FsZs7bspsRp+rQAEybdYBMgn4EeGQTgcNlsQzpZTokKJznEwYOOB1KWsl940qeQDYKnCNcsk7DuMdzgc1VbbEWT2xWJ7lPIEMoaiLTW5f3l5gMd53HAdlbSIzr5h3ZWBObmuVrgnKB41j3Vhj7Nv9WNb+uH1J7N7pC48hB2QR+q6bYiWfBAk8/tjcZara4CTBpkof76gmvnKyT+5jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=8NbjBZFGLCOQPKlMZfmrhLpqA0S8CIGooxpyooHDAQo=; b=XnOMQCxf+Mp6u16chhh1NApl+43C9alP458YEwAVbwaYD5X3xZTwdpd8RS7lSzxsZrZ9qaXIyYsDfapbgu11+OlSY9QRwPj3kmWAcCTmAzrL9v0U0SZWARxEr1w6sgre7o1PDhyxXFLD5seZZSA6/ybag14Lxkvt4ao7VYAGgAQqS2CPQ0+cfdoUmjydzt5Wh6FgtYAJJcIXM7rtIk7FZD5SH1Mr/1loOZ1T8mMqUDGve4YG/haqzG5ByDOIfooCdSACjZeWF4xw7EQnvoDTztcAVcjrB9bXC7pEK8Vkxx9Co2cdY3+C/DO6VBr0DY8sGe+lSfdAq11stukn0f+9QQ== 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=8NbjBZFGLCOQPKlMZfmrhLpqA0S8CIGooxpyooHDAQo=; b=SV5h/ffx1iK4Ll+/aVqudI3Ma8Kw0pVcgSEQribCUFD6Yi/41jyrOeO8J+nBJuiWj3/TVUWhKzMDYE2bm7CoxAkP5BjZcHnXQ/IQYes3kPrXH64Qym4RGHRrqM3xddb0us5TZuYSr+YRtVViO7pQpawChqcF/7tlQFa4698yvj4= Received: from CH2PR15CA0030.namprd15.prod.outlook.com (2603:10b6:610:51::40) by MN0PR12MB6200.namprd12.prod.outlook.com (2603:10b6:208:3c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.26; Mon, 24 Jun 2024 06:01:18 +0000 Received: from CH3PEPF0000000B.namprd04.prod.outlook.com (2603:10b6:610:51:cafe::19) by CH2PR15CA0030.outlook.office365.com (2603:10b6:610:51::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Mon, 24 Jun 2024 06:01:18 +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 CH3PEPF0000000B.mail.protection.outlook.com (10.167.244.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Mon, 24 Jun 2024 06:01:18 +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; Mon, 24 Jun 2024 01:01:10 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Dhananjay Ugwekar Subject: [PATCH v3 03/10] perf/x86/rapl: Rename rapl_pmu variables Date: Mon, 24 Jun 2024 05:59:00 +0000 Message-ID: <20240624055907.7720-4-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624055907.7720-1-Dhananjay.Ugwekar@amd.com> References: <20240624055907.7720-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: CH3PEPF0000000B:EE_|MN0PR12MB6200:EE_ X-MS-Office365-Filtering-Correlation-Id: b37d6e51-21d0-4470-dab6-08dc9413107e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|36860700010|376011|7416011|82310400023|1800799021|921017; X-Microsoft-Antispam-Message-Info: 2QWBAiabiSrmGg+H09U76gb+F6TqNKwJqUccVc10bONbaPETT4lUz+r0Qt+vIBSmThdjAZ3QmSBPPu+secxdzHekMKXOT24ibEA3ms6tmfJsEP1dz7//yBeMBF8rO9IwRlJqxxFBc5xYl956qn9pnrq/DSEyxwlSr1FfGgghHoHPqf5d3Ho1H734jYP0x7DQsVaydFFirUBAPNnmAQIiLIN0xkE2A/a4+R2McRTEjbgAuQXJ7+UvzuXOElQmNmCQQz0qKV02Kwdd5NVR0wYlNiYfWwN98qs4gElzDxUTqTsiCzraNwlNriTm9en/2wwt+tfGSlVwbz2/8uy44BweKHMGdLBePXdRGfwWPypl7gbLrnOaQJFFCg8Xtc4fCkzb1E0CxKXmHOsUJWfL1VaggUFTQCi7p9/IuuDV3C4SKWHVET0ON/5mQiz0+d1c/zGaUk7vOxq9QlDAiorqITZYmbghV+wok4aN0XwNgAF4RuRL9gIQpKjgUvZ2uFC33viDil6SCTlBlpgb2EOuvRqLG9LMybEt8WheccRFEXPk53pQZKH9OTwsr+REaotviY4OM+WXtZwR6EuxjA4kYxCnvjr6ljqnr8L2jChUbBFTWn0HiUrNJ55x6DAWTK+quGCcSKlE9iWwzajagrUsx1FBcOmwtuZEe/jfYWNCETQJv1QUAvY4g2i7P6G7MZYXveVD2ewEEwHcoj7lXa1LBf9eJHO3l4tlDpAkULe+j73jP8MpLvpUEgHXoLxcX8BPEsmWnAjYYs+VnyreKXbof58QR8KlHTxtqxibav/O/Nh6E/rZnAUyZcy4nt0JVZACE19Si+BgcBf1jegTlkVllANFo5hNsHOssh4tB1eTsk50mAASP+gFIx/UQzFgLhleOJXLPZ/gQubBDnkwVL3gE6GX2scz+xIS9FVUzZYhQoPiRGWnlqmvaycbHAWMq/7j5NGw7NIAd4mrmuTjF5eaPE2xWutxs/rCr23W+8tth86o9F/kbFVq4VB4Ks7YV1oMjDWx2xAcDkfYMLQh8CBi5Rl7WoICKdPEw6Gsg5jGe2Gr4X90z/JiXli4PlUw3zmI3jr43lxxE6ws+/mAcLRJcLF42RffOlhb2Si2PY0ifuTtLjmXRXFDLLzT9NcFZUcGhWKYCYIUhwVE12GqZk+SURXqqr3mUvo+qAi/XowsohU0GMqXm9brCGFXcewSmh88evTpuCvAZRrPFETaIKNNTCJ8SEIbSPr6rkLHMq/cFOu1xk3nwZQjiRTttqGDL+cgV1YNYzWdysHKCM8JTWpVEoGhHNXKhTxTVhiO3vqd1vaFj46GHfs5gkAadgFVmJlFBWdLllGX/We4efIxS+EXkKXAEe257oc7ZpzUwGAECugBLhuPafQNIWJnKDtEqTAi0P5unl0Hn0dUy4xDM2EQK38lDe33flzwunJuI4cMWmUpTAw= 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:(13230037)(36860700010)(376011)(7416011)(82310400023)(1800799021)(921017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 06:01:18.1024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b37d6e51-21d0-4470-dab6-08dc9413107e 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: CH3PEPF0000000B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6200 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 --- 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 73be25e1f4b4..b4e2073a178e 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -120,7 +120,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 { @@ -164,7 +164,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) @@ -228,34 +228,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))) @@ -263,39 +263,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); @@ -313,23 +313,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; } @@ -343,7 +343,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) @@ -373,11 +373,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; @@ -560,22 +560,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; } @@ -584,21 +584,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; } /* @@ -610,7 +610,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; } @@ -679,7 +679,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); } @@ -699,7 +699,7 @@ static int __init init_rapl_pmus(void) if (rapl_pmu_is_pkg_scope()) nr_rapl_pmu = topology_max_packages(); - 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 Mon Jun 24 05:59:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 807172 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2061.outbound.protection.outlook.com [40.107.243.61]) (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 21D2A18044; Mon, 24 Jun 2024 06:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208921; cv=fail; b=SJU8CYkQhupgZb0tYOoV/EXBYpE7dI0lFBk7i/+75rGG6ZaZmv8kC7zafgIG9z6m1EARXJLODzAPo0Ec9hzRsn2Gzmx5kMB8wx67xVcuiMqGR4ft1CNPU5BU0uACUju/AcGov3K6k4Vnt8gyDT3nemqssSpGa2kTrnYof2gvzFM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208921; c=relaxed/simple; bh=FbVldJAzwBUz/OiIKlBv24FGlyQJ3s39q84DqVs7d1o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OlrBjP+0FJn+kI6FEZoOdJ5BL17rrajO4Lcm1U3a64s7HN7THSBveOKObq+i9+/YzxjDX4yjUXvB/s8KFr8z2rGqmw/NbWh8CrvZJIe7lg+pujukqT/i092aicKu4b0FbzkmN/r0uasEewpnARMCLoXbhQ9YW0pTRaBTA04unxo= 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=Zp3HENd6; arc=fail smtp.client-ip=40.107.243.61 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="Zp3HENd6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fZiyru3BzUJYX3oCVBDZqZ1afOmqXPxrGAdEph1B36vLMVnrLl+nk+0KpcHJi0hfK7wDnPdPt21FvJ1N+hKsNFDYjXVWPMAd+nZ7A6+A316iYQuCsIA9hVC+g5Qs/FJefVwVNQxLx1i8AhtpqmSxrP9gFpDazejhp6AHEnIkPAU0MLxavo+MCR5ffOyjMfZToyIdt+RGo/lhFkO7l8X2+OFXLPxRCThFNhrgGEVlBS1wz3QRfPH3ons3iv+b+4h5328A3CUOgUP/orFs0LMFFx88Mtg1gFmSiXZ/5MlFfQ7efmBHKXnr3aVWpWAqayxi9plPVq1FuVkxaGACk+xJAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=3WSqqtWS5pLK7gm63CqzM301h8Bv9ShBNsN1dNvF7Fg=; b=WcugYVsyclc3hXdjRjVYn1QII0sEs/hWnkzMzAi5XREkyPpeBgPSnrC8VP4+oAd3g0gZGQROziT1F3LcGOVH7WuO5hbYusJw1XtQnZPiiSUiYMGgys/aciD3EI6cMj+YjPFHIPdvaOoZVLZhAYBeYLOXqMyLatT1QI3xpGk5zFR+BnNLEyM2aFXrLKvAhhSfJJwxHU9Pg5nPOHnbkqZmuHsLI1dYNmJ6Nedb8d2DXN3FhWA/ZYGs37dfzG/2xPE0dSoqObhXqJm8bu8UCVtgTVVonW13QqGxEuORWIkHYPlI7AgKpfd0R/4MpDLHpd3WiodFPjzInWzK1q91Smqgeg== 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=3WSqqtWS5pLK7gm63CqzM301h8Bv9ShBNsN1dNvF7Fg=; b=Zp3HENd6GwxzqXpmwtl/JXzkDIV9TnDUpGajhla6zJVVFVmbOnfF4cYpfMcQkFATOMXrHep2yeQ9qfIEt2EpU0EeW8MVXMN31uVmY6MXsrXTLXfavhUkNEw3sZtezOHswSsjicqZAxUaqc4Ek9UkoiPvdogem33iSIi5SRMW49I= Received: from BN9PR03CA0534.namprd03.prod.outlook.com (2603:10b6:408:131::29) by MN0PR12MB5763.namprd12.prod.outlook.com (2603:10b6:208:376::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.26; Mon, 24 Jun 2024 06:01:57 +0000 Received: from BN2PEPF000055DA.namprd21.prod.outlook.com (2603:10b6:408:131:cafe::96) by BN9PR03CA0534.outlook.office365.com (2603:10b6:408:131::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Mon, 24 Jun 2024 06:01:57 +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 BN2PEPF000055DA.mail.protection.outlook.com (10.167.245.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.0 via Frontend Transport; Mon, 24 Jun 2024 06:01:56 +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; Mon, 24 Jun 2024 01:01:49 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Dhananjay Ugwekar Subject: [PATCH v3 05/10] perf/x86/rapl: Move cpumask variable to rapl_pmus struct Date: Mon, 24 Jun 2024 05:59:02 +0000 Message-ID: <20240624055907.7720-6-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624055907.7720-1-Dhananjay.Ugwekar@amd.com> References: <20240624055907.7720-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: BN2PEPF000055DA:EE_|MN0PR12MB5763:EE_ X-MS-Office365-Filtering-Correlation-Id: fed71c6d-256d-4dd4-d5b7-08dc94132792 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|36860700010|376011|7416011|1800799021|82310400023|921017; X-Microsoft-Antispam-Message-Info: Xe9OQM1AQpoxmqln90bQLVzFQGu7H4k7P6Qs+L4MW3zDp1RwNQMQv+eZt55I72h1dHPuAzjC3aKpDRitcy+evd8PYR8p7cYRDfvzxsdI3z2XrdV5v6uRFkgnYsxrgVyQPTnKLwIBWDGPux5M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xiiUYZ2YCAWFiu6rPLQZz7xmLHXk0/keNmY/IkUhvyG99Chv1IvJHUe1e8iQFhpAsm+YN4FOPu6ezlwmk7SccIdzs1Bf8ZLla3aLXW+U5SZWpxRNAaXUwWMkE/Wm2uUPOtsSfVeYrVvgVaYkxn++2hbQgf2yHYqxCjAZBW743hJHfodwfKzYrlL3cS4SbZnCSOD3Wb0R7xMeQQk7YlHXWLMk8TmLH0= 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:(13230037)(36860700010)(376011)(7416011)(1800799021)(82310400023)(921017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 06:01:56.8366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fed71c6d-256d-4dd4-d5b7-08dc94132792 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: BN2PEPF000055DA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5763 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 --- arch/x86/events/rapl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index e5e878146542..be139e9f9ee0 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -119,6 +119,7 @@ struct rapl_pmu { struct rapl_pmus { struct pmu pmu; + cpumask_t cpumask; unsigned int nr_rapl_pmu; struct rapl_pmu *rapl_pmu[] __counted_by(nr_rapl_pmu); }; @@ -139,7 +140,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; @@ -394,7 +394,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); @@ -565,7 +565,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; @@ -574,7 +574,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); } @@ -606,11 +606,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; } From patchwork Mon Jun 24 05:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 807171 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) (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 D58021C695; Mon, 24 Jun 2024 06:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208961; cv=fail; b=fwEJALt2BI1SKYfyXbp7wCMUSrSR0nY1LW2+XBLuR905Jezkii+8aj11M1/FfEX0H16YVtDJmujnbjUJRqVYgLSzpqk/C/hxNmlh1/EYhxkEo1S+gD6bO3YUlAC8IMXVOgZZzw/TnP3zWPQ3CxJcCaGnjfIMKJm+Jx9U6heYu44= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719208961; c=relaxed/simple; bh=SevruLCexV627iM6Dl8XSaoopRtrEYLT3wp2+/RPnLw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nUqgCyhinf4EaZE1MXKGKVgs3DQgjjEmu4hTmvTVSGcZBjdaZONDmKe8cIEYhihg4hlBa/W32xWfipdqrhsbQwoyV1bQ1pP8y2m/vPUN5snzHdRmXipvThoHD+FsRQYWjqAxvW/S+/gvZzf1PyUsH2SiXbJ7/fCsTzmM3WzzYpA= 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=kghfV2KW; arc=fail smtp.client-ip=40.107.92.40 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="kghfV2KW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jbFtKq67JlJ3act7Bxowf0UK1jIN8Hbk3dqX2Jw3MK/Bg1ljO8W6qQaTLLmoeX0jU1/IU/oWT20ArGAncHAyzvLq3Jlkg435pb2xU4BusRnaBEVoNCuioTCy8bxHrVEAJ2A3tNhjlxtSZn76vej7krBMRdhzTMoWFK15LS/NGp9bKt4UT0yCvLDAGnCyYCgYDVheJtAFTZutU9dTjzDi5XTsVG+ZHUOqFz1qQdR2rzNnQu55+6jwPJjfX2t3deJWAI/UCsYO90O2mLssBrdDeYT0A8u+uTAWSA5Te4jep/fNu1A4cZRR3x14RgqAO8HV4SEKnBlvNdy3e6PPeqmrPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ecZ6mfsQyMQekhKSwNggBHbozRpNVr37hIhIwLMyQH0=; b=oAiJwpAQ6VVSAhd7qnR/hKjyMNjorlr1qgB5xG9dOWEC25WNLq8vCjhvt2H7OF+wI6Zn48DliNUaHhvv+NWNvm6mj4/D4HPRLaiWxpF6txmjU1RMyNa9rQ3jYKPtM5/pAAmmXyNAgIAvRYdDJDzlEwYpcQR6WdAHYJ2PfaXxjdg217IEo8/o1SegH2aZymtrFf1mXjC6edHR2SJe4PO2dDxJf61cLMR8VR+TH1U6na1/8Tq6mNH8cRZ0rB/q/XBVfqVqor1Ytb4OyHC/UVhIKtssSQwYyFngDv5YJNLNbDUIueXLt6mXNzUvp73wUcs34s7/vTHWeSImwU7ZaWmgSw== 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=ecZ6mfsQyMQekhKSwNggBHbozRpNVr37hIhIwLMyQH0=; b=kghfV2KWFFFuNtLGGghqyptJhsavmq1sDbWQdQIQkUvWb1ihRrt98/51u2ubNawHKtHBBxtub4CBNJynifNUGaUn5ln/jZw0NPBIJ58VWjm36Z9pIHT3ecUs+w9ePd4oOtYb7c5N1HRar7mGXWVR3uPKAJgStUXgb1jmOdNIe4E= Received: from BN1PR10CA0003.namprd10.prod.outlook.com (2603:10b6:408:e0::8) by SN7PR12MB7980.namprd12.prod.outlook.com (2603:10b6:806:341::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.28; Mon, 24 Jun 2024 06:02:37 +0000 Received: from BN2PEPF000055DE.namprd21.prod.outlook.com (2603:10b6:408:e0:cafe::a8) by BN1PR10CA0003.outlook.office365.com (2603:10b6:408:e0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Mon, 24 Jun 2024 06:02:36 +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 BN2PEPF000055DE.mail.protection.outlook.com (10.167.245.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.0 via Frontend Transport; Mon, 24 Jun 2024 06:02:36 +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; Mon, 24 Jun 2024 01:02:29 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Dhananjay Ugwekar Subject: [PATCH v3 07/10] perf/x86/rapl: Add an argument to the cleanup and init functions Date: Mon, 24 Jun 2024 05:59:04 +0000 Message-ID: <20240624055907.7720-8-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624055907.7720-1-Dhananjay.Ugwekar@amd.com> References: <20240624055907.7720-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: BN2PEPF000055DE:EE_|SN7PR12MB7980:EE_ X-MS-Office365-Filtering-Correlation-Id: ee6d0b4a-9821-40bf-a6de-08dc94133f6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|7416011|376011|36860700010|82310400023|1800799021|921017; X-Microsoft-Antispam-Message-Info: C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AKi5aXkHqgyxQ2KYR7LHKhJ9zriyn+65FoBCOGC3za/vffEJHGP9FEAOoZz9zLfOp+dzn7dYQNwNAJtj5uZtrRViID4iu/CpN0OUFYmggyeCDn8gpd74Zt6xfU8KHHAgKfxsh/djpeFjmeCXSqIsgeMUmh65B17EZrMbpVw3B8ZYtENcdyBD0PcBYIIk0Iu9lXzJE4rnd7SO4nQygYCrw2Uu8STfCpWz2u3P0bk5SSTgSvwO6UU3m3fvt4ri+8HDSte+ZVk8LrVoFNDUYVMYewom/rguwllqhpOxUE1JH0f76pUuKi+Sc6PdluLZ5hpSvRaIxpUKZPLTE11TuuxU7o2S2bF0wgsPA5x/pdh2v93Wfgg= 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:(13230037)(7416011)(376011)(36860700010)(82310400023)(1800799021)(921017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 06:02:36.8295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee6d0b4a-9821-40bf-a6de-08dc94133f6b 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: BN2PEPF000055DE.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7980 Prep for per-core RAPL PMU addition. No functional change. Signed-off-by: Dhananjay Ugwekar --- arch/x86/events/rapl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 70c7b35fb4d2..f815c60ec551 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -687,7 +687,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; @@ -705,8 +705,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) { + struct rapl_pmus *rapl_pmus; + int nr_rapl_pmu = topology_max_packages() * topology_max_dies_per_package(); if (rapl_pmu_is_pkg_scope()) @@ -728,6 +730,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; } @@ -869,7 +874,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; @@ -893,7 +898,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); @@ -902,6 +907,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 Mon Jun 24 05:59:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dhananjay Ugwekar X-Patchwork-Id: 807170 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.49]) (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 A7BB11C695; Mon, 24 Jun 2024 06:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719209001; cv=fail; b=MXIoj39+G+3unQmm0eEGI2poMOXUUy7FfY/vXoPEhMdbFuZ/L1nrLluzLYvqoY0rb1UWtuz7CXZarktFGmeTsOyD00qmsOdStmbCQ2QiflhTLke12NXhvU7c5SjOjX87cC3ECX3rfci5uYg0wmFSuyriTC63+0hwYn8kebEUPic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719209001; c=relaxed/simple; bh=r3KZn4cY29i3ZVT8o0x7Etz+i2GyJ3TuDpeR2bPZpxY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q0dbyDMyIFIvh/k+rzZhKI/2cSFRrmp/q5HZc/yrIoXuOrAYyMmGkuKGMRCxdACfMgcX3CHoUI7jrn/AM/VC0HmulDyU9x26w0EhuJGL2Tiqu3mumWxkKRpTdUqVTx5nMqyOlxKkEJMNZUNPKICre/kXtL/NjFgs0Vieqxroxg4= 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=atsNQm54; arc=fail smtp.client-ip=40.107.236.49 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="atsNQm54" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G0sGoIYjYuEx307MArEB+TTdu78FOeNWLW2gZFYMhNaRxDaN+I3n3g+Qa+y5CcL4ZL/AutNNM1vLZzUYFuSMBJ20m/n15ZRV1sWJJVETlG9wNwOPA5YrJtuglK3LidlmnHFyHG/7C4kMvdmuwY1Z8xV/lqoO5MmB3VWE72hm2xxIa9CsUq0KL1eSbhBdgjbzGAy/48TDTM9uULRtadJGtkYtJyuWOS2Q40tcXtwRYltGYpQrpwkfqlACfbaTtumQoTg/vrSlzWz4GEZL7x4Qmph8jcbc38NYzFXJMiSgJlcUuwhOxeOtW1Fneox4EwIu//ezSQVkxllOXXvsk8CSLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=EJw2vpL4ySk0o0rEFGGvb5MNBmpk6BRClOy53vqQOIY=; b=fYNFrvc8QEkaCZJl+sajQrWUcGuIueqIcXv9ZMbOgZXig22X4Iej/YVbcnrmylGxuAqo4vUtg5qBBVx3f5Qz8dcrAHkyQE0aBENmitgjBMNsapjA2Y7DTKYxV8VnVLmSDc+ofX7BC0S3WrBr8XMiiWDuFmpeJ19c6VXfuWm7fvrmIaYRQGzVR56qALV0AkDZutanl4S7Bre3wl7l15Xwme2uNmHjc+IhVmm9YHpL1iHdZYJFNS/s21H6tGziDxczMeQgkQDFNcY4+RkUSyXw+eXA/l1wFxNumPUgLHXRtVO1NxpaZQKAWg5CGO3zlrqJ6EwPV35JA6UF2v+QzKtLLQ== 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=EJw2vpL4ySk0o0rEFGGvb5MNBmpk6BRClOy53vqQOIY=; b=atsNQm54cRZaa9ITFxuILApOiCq9sSrwe8qxv8XX9SQ3xibgNMMtc+FDTey7GSCUVauieNaxyGuLYyPmDOrVzWhVGSgN2DV8pmtyCEXrUuDSu61w89DyjRZeDreEfM5SmGjuWxb/6oeS3x2UL7hfOp71XVxV/ID++DUzPoTSqJk= Received: from BN0PR04CA0162.namprd04.prod.outlook.com (2603:10b6:408:eb::17) by DS7PR12MB5981.namprd12.prod.outlook.com (2603:10b6:8:7c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Mon, 24 Jun 2024 06:03:16 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:408:eb:cafe::a6) by BN0PR04CA0162.outlook.office365.com (2603:10b6:408:eb::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.38 via Frontend Transport; Mon, 24 Jun 2024 06:03:16 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7741.0 via Frontend Transport; Mon, 24 Jun 2024 06:03:16 +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; Mon, 24 Jun 2024 01:03:08 -0500 From: Dhananjay Ugwekar To: , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Dhananjay Ugwekar Subject: [PATCH v3 09/10] perf/x86/rapl: Remove the global variable rapl_msrs Date: Mon, 24 Jun 2024 05:59:06 +0000 Message-ID: <20240624055907.7720-10-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240624055907.7720-1-Dhananjay.Ugwekar@amd.com> References: <20240624055907.7720-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: BN2PEPF000055DF:EE_|DS7PR12MB5981:EE_ X-MS-Office365-Filtering-Correlation-Id: 90176e88-f801-4d61-6aa0-08dc94135704 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|1800799021|36860700010|7416011|376011|82310400023|921017; X-Microsoft-Antispam-Message-Info: pVazGTeTPOiF/h9MpX4+vvb4mUq1wKSssS0x1vzglxxIM2JiMA2zKPlAASChu4PiIe+1p+ekHarCpgNetosJ+daK8oPcTK7Xq2g1MkYMOGKazjqWtrLbTyWEnTYTbBHdcaoRvQw7NhqOpMc736TXzQafXmRqTCOHTQEinlaLlfvQqIjOuYeleCoSja9naGB94T5DBNZ1VPxZJ4epNRexaVpFHMI6FNTl8S92AF2KV/nmKnLUqh7K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i92sbgQhkEfJmPAmCWRF1xiqhmzdx/G8PBcpKhQkhP/yIA9fWHffJXcBAm4/uFDTqtpM/dhwnPPRyITbcvLAAxkmKHWPfTm64PgbRbGQ/X+GmA8mzyk= 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:(13230037)(1800799021)(36860700010)(7416011)(376011)(82310400023)(921017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 06:03:16.4183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90176e88-f801-4d61-6aa0-08dc94135704 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5981 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 --- 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 b03b044a390f..e962209e9e4d 100644 --- a/arch/x86/events/rapl.c +++ b/arch/x86/events/rapl.c @@ -142,7 +142,6 @@ static int rapl_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; static inline unsigned int get_rapl_pmu_idx(int cpu) @@ -380,7 +379,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; @@ -866,9 +865,7 @@ static int __init rapl_pmu_init(void) rapl_model = (struct rapl_model *) id->driver_data; - rapl_msrs = rapl_model->rapl_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();