From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB267456A1; Wed, 24 Jul 2024 15:04:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D1CE40E3E; Wed, 24 Jul 2024 15:04:00 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2077.outbound.protection.outlook.com [40.107.220.77]) by mails.dpdk.org (Postfix) with ESMTP id 4F74F40B97 for ; Wed, 24 Jul 2024 15:03:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hfl4ipBKe1wMdG4djO6emcx5rA6OnjevQgyHZylrTbLk7uK168mtl8kL9mNF97HoDwCNKCggWGni4GZuwvu9dLaCu42zrorv4PYPGf0ZTdSuONQ7J98qQ9gMRvc3uXMs9BBgCES4SobB0J+f6nX8bzkwnBPdWDTRC2vrd9L7XthCoF8nid6BEjJSSis97eJJPLi8QkOQ50W760raRb52y0cyhy7kAYm5xu9vaMTHgfD8YDcfpiYwwnpgv0gkiGgNlTA/1wN8+L0LDmGqAPmVCg01CotBO9zd8/Ryzq27ynm3En3RJfi6Xs5a/NFPBjXpMuamTLdPmG3Tse438d6UKQ== 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=KRebbDUgDQPRq2tG7NMVhjIQhKjwyaNd5UviuckB54g=; b=P6IgjVBqNrw4FVGOSbKBBVk852dZgxU0mXXf7rdeGag+nN/bosBf+D/IwwYdlVVctInHK/ftpCbMgKkYHquCKV+dplvkSIoqxs+he8dhdA5IvexMiHTYzoImSIYKgYnMk8Svi8hDoWNM4CQbFIxUXvsZiZm0Ousklj+UICwt+TDdRAO8P+YpPNLiCV1CJma8EmL/9RMmFG05ZS1HPioTRE6uiz5rsggNH4IRiZZGmYfzoYjJ1M4ME1t14t9n6RGXDoqQUo2px0IXRzk4uy+wTzkpDG+Os3+0fjOSVEqD/UG0tDa29T2ssCE3ylfMNeo2dAXHuKT6vpUiwKgoO5c3CQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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=KRebbDUgDQPRq2tG7NMVhjIQhKjwyaNd5UviuckB54g=; b=U+414dWZcXYZoT4PGmro2GKExQ9NMVWM9O1og3OVklpMklT/X43Aq7S9IeQj8IlpLc8BA7rvY0j6jzg7Eu5PYB+iqDWZ6p8blO84EZm6XJvLCSQYb3obFdyaRq4ZdMdljsZXdWzii6l50X4t5+VBkKbDfgtyuh2x33SfPYEa364= Received: from SN7PR04CA0077.namprd04.prod.outlook.com (2603:10b6:806:121::22) by DS0PR12MB6558.namprd12.prod.outlook.com (2603:10b6:8:d2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Wed, 24 Jul 2024 13:03:56 +0000 Received: from SN1PEPF00036F42.namprd05.prod.outlook.com (2603:10b6:806:121:cafe::1c) by SN7PR04CA0077.outlook.office365.com (2603:10b6:806:121::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20 via Frontend Transport; Wed, 24 Jul 2024 13:03:56 +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 SN1PEPF00036F42.mail.protection.outlook.com (10.167.248.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Wed, 24 Jul 2024 13:03:55 +0000 Received: from jfw9ny3-os.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; Wed, 24 Jul 2024 08:03:51 -0500 From: Sivaprasad Tummala To: , , , , CC: Subject: [RFC PATCH 1/2] power: fix power library with --lcores Date: Wed, 24 Jul 2024 13:03:35 +0000 Message-ID: <20240724130336.1076462-1-sivaprasad.tummala@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F42:EE_|DS0PR12MB6558:EE_ X-MS-Office365-Filtering-Correlation-Id: 16babd87-6524-4734-5ddc-08dcabe11324 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?tZKCTGXUsMDfjuVs3ya+DAI7qDx5QDnzYw3hyY6VSyjc2ewNeWKq7El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5Em1fytM/j5pji8ezh6XkdG8Xo?= =?us-ascii?Q?oztqIMMgcAdYt4RxUrpeH9/IE5s4ye1X3qUe9WE1nA+BqWjQn1GUtzSBvBOH?= =?us-ascii?Q?7dFxFN0xYs77cw68OC+8DKoeHwnskImFGSMZZCFe41Gkq5Yg75nbII5+ZGeV?= =?us-ascii?Q?AEn14cw3rcI9UPhHyabwxDrwOQKKnNqFHsycK9eqYSBL6WvqY74GiZg867np?= =?us-ascii?Q?dVfE4FEwCI3IlJtmovCMka5JbCtIg9vB2A64UBKfkNkZBe4aYEXZDJK6aiok?= =?us-ascii?Q?AYqGERuNFoH7O9U5sNaDNwS0hjcIYSFDsQO4Lt/KhIsPiDwsLB4qICT2mmlJ?= =?us-ascii?Q?sq9U5dv+vCwshvF0rTVM/2iXW8QtOnyL8MEGykUJ4VRXD5aa216yw4f7Ya+7?= =?us-ascii?Q?gMID8mYMBGytwJ4R8fVFj99LWK7p7VhW7C9wdIzu/mZspEjFA8dUg4CYpWsh?= =?us-ascii?Q?C+gIDeCsVtWl4SCGwg0Oc4nYnUC04oOGFttoeCwIU4/fZqvF2ys7xmDfuGqu?= =?us-ascii?Q?WNm4wpvkDzlimZFJGMHa8w9goEDtMzNX?= 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)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2024 13:03:55.4878 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16babd87-6524-4734-5ddc-08dcabe11324 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: SN1PEPF00036F42.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6558 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This commit fixes an issue in the power library related to using lcores mapped to different physical cores (--lcores option in EAL). Previously, the power library incorrectly accessed CPU sysfs attributes for power management, treating lcore IDs as CPU IDs. e.g. with --lcores '1@128', lcore_id '1' was interpreted as CPU_id instead of '128'. This patch corrects the cpu_id based on lcore and CPU mappings. It also constraints power management support for lcores mapped to multiple physical cores/threads. When multiple lcores are mapped to the same physical core, invoking frequency scaling APIs on any lcore will apply the changes effectively. Signed-off-by: Sivaprasad Tummala --- lib/power/power_acpi_cpufreq.c | 16 ++++++++++++++-- lib/power/power_amd_pstate_cpufreq.c | 16 ++++++++++++++-- lib/power/power_cppc_cpufreq.c | 16 ++++++++++++++-- lib/power/power_pstate_cpufreq.c | 16 ++++++++++++++-- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c index 81996e1c13..97a27e09a0 100644 --- a/lib/power/power_acpi_cpufreq.c +++ b/lib/power/power_acpi_cpufreq.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "power_acpi_cpufreq.h" #include "power_common.h" @@ -234,7 +235,8 @@ int power_acpi_cpufreq_init(unsigned int lcore_id) { struct acpi_power_info *pi; - uint32_t exp_state; + uint32_t exp_state, cpu; + rte_cpuset_t lcore_cpus; if (lcore_id >= RTE_MAX_LCORE) { POWER_LOG(ERR, "Lcore id %u can not exceeds %u", @@ -258,7 +260,17 @@ power_acpi_cpufreq_init(unsigned int lcore_id) return -1; } - pi->lcore_id = lcore_id; + lcore_cpus = rte_lcore_cpuset(lcore_id); + if (CPU_COUNT(&lcore_cpus) != 1) { + POWER_LOG(ERR, "Power library doesn't support lcore %u mapping " + "to %u cpus", lcore_id, CPU_COUNT(&lcore_cpus)); + return -1; + } + for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { + if (CPU_ISSET(cpu, &lcore_cpus)) + break; + } + pi->lcore_id = cpu; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { POWER_LOG(ERR, "Cannot set governor of lcore %u to " diff --git a/lib/power/power_amd_pstate_cpufreq.c b/lib/power/power_amd_pstate_cpufreq.c index 090a0d96cb..8a3930eac7 100644 --- a/lib/power/power_amd_pstate_cpufreq.c +++ b/lib/power/power_amd_pstate_cpufreq.c @@ -8,6 +8,7 @@ #include #include +#include #include "power_amd_pstate_cpufreq.h" #include "power_common.h" @@ -352,7 +353,8 @@ int power_amd_pstate_cpufreq_init(unsigned int lcore_id) { struct amd_pstate_power_info *pi; - uint32_t exp_state; + uint32_t exp_state, cpu; + rte_cpuset_t lcore_cpus; if (lcore_id >= RTE_MAX_LCORE) { POWER_LOG(ERR, "Lcore id %u can not exceeds %u", @@ -376,7 +378,17 @@ power_amd_pstate_cpufreq_init(unsigned int lcore_id) return -1; } - pi->lcore_id = lcore_id; + lcore_cpus = rte_lcore_cpuset(lcore_id); + if (CPU_COUNT(&lcore_cpus) != 1) { + POWER_LOG(ERR, "Power library doesn't support lcore %u mapping " + "to %u cpus", lcore_id, CPU_COUNT(&lcore_cpus)); + return -1; + } + for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { + if (CPU_ISSET(cpu, &lcore_cpus)) + break; + } + pi->lcore_id = cpu; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { POWER_LOG(ERR, "Cannot set governor of lcore %u to " diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c index 32aaacb948..d51118820b 100644 --- a/lib/power/power_cppc_cpufreq.c +++ b/lib/power/power_cppc_cpufreq.c @@ -7,6 +7,7 @@ #include #include +#include #include "power_cppc_cpufreq.h" #include "power_common.h" @@ -338,7 +339,8 @@ int power_cppc_cpufreq_init(unsigned int lcore_id) { struct cppc_power_info *pi; - uint32_t exp_state; + uint32_t exp_state, cpu; + rte_cpuset_t lcore_cpus; if (lcore_id >= RTE_MAX_LCORE) { POWER_LOG(ERR, "Lcore id %u can not exceeds %u", @@ -362,7 +364,17 @@ power_cppc_cpufreq_init(unsigned int lcore_id) return -1; } - pi->lcore_id = lcore_id; + lcore_cpus = rte_lcore_cpuset(lcore_id); + if (CPU_COUNT(&lcore_cpus) != 1) { + POWER_LOG(ERR, "Power library doesn't support lcore %u mapping " + "to %u cpus", lcore_id, CPU_COUNT(&lcore_cpus)); + return -1; + } + for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { + if (CPU_ISSET(cpu, &lcore_cpus)) + break; + } + pi->lcore_id = cpu; /* Check and set the governor */ if (power_set_governor_userspace(pi) < 0) { POWER_LOG(ERR, "Cannot set governor of lcore %u to " diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c index 2343121621..cd7dfb5468 100644 --- a/lib/power/power_pstate_cpufreq.c +++ b/lib/power/power_pstate_cpufreq.c @@ -13,6 +13,7 @@ #include #include +#include #include "rte_power_pmd_mgmt.h" #include "power_pstate_cpufreq.h" @@ -540,7 +541,8 @@ int power_pstate_cpufreq_init(unsigned int lcore_id) { struct pstate_power_info *pi; - uint32_t exp_state; + uint32_t exp_state, cpu; + rte_cpuset_t lcore_cpus; if (lcore_id >= RTE_MAX_LCORE) { POWER_LOG(ERR, "Lcore id %u can not exceed %u", @@ -564,7 +566,17 @@ power_pstate_cpufreq_init(unsigned int lcore_id) return -1; } - pi->lcore_id = lcore_id; + lcore_cpus = rte_lcore_cpuset(lcore_id); + if (CPU_COUNT(&lcore_cpus) != 1) { + POWER_LOG(ERR, "Power library doesn't support lcore %u mapping " + "to %u cpus", lcore_id, CPU_COUNT(&lcore_cpus)); + return -1; + } + for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { + if (CPU_ISSET(cpu, &lcore_cpus)) + break; + } + pi->lcore_id = cpu; /* Check and set the governor */ if (power_set_governor_performance(pi) < 0) { POWER_LOG(ERR, "Cannot set governor of lcore %u to " -- 2.34.1