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 C0CE045B50; Wed, 16 Oct 2024 15:28:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 618A44064E; Wed, 16 Oct 2024 15:28:31 +0200 (CEST) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2058.outbound.protection.outlook.com [40.107.103.58]) by mails.dpdk.org (Postfix) with ESMTP id 544914029C for ; Wed, 16 Oct 2024 15:28:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HMBkyGt4UlMAKcJLS2rI5pdvmnUBZlupjkFn93a69ZovTHdD2d+RQdDIEl0T1zYEcMBVQNkX3BhI0Rdnc6fkQoICeGIUmCiT+VRFTeitVJs0PUTA6vhR8K29JQPWdPKFgI8UK9kQult8551BXsCL119CvzZX/Kx63pFH+Yr0wWM4DRugKEUN/1294ELMJcLZ6OcqpUsLTszcCQZvqRiEBB3f2qoGB0X8yYpu4auQ6Kf0mPyGAXebL378Dd39fMkMOYHZ+KuLrjjNelvZA4HqW93/E0jJAmaY8qvQcu3dPIhtWc937wNWm1pUTBFZGlFhtHxII7yNdqKHrltMytZFOw== 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=fgGvEdU4oP2VvxxJBFw7rocIdfPCeSVcgUr69sGrc+Y=; b=Iy1FnPkWDh/ys0XP/DqSOdlj5eCGi0pPt5fR5HWED/RQj19FsEK5tHMEFwNaZHDzIzJZ9XNWK1lzG79GGgMGT3eu9UHhhuFutwdsiDoBfJEE55YEW3KD5ukm/gXY22OR9EaqtTuH35Nx9Eg2NoAJKQYZpasZBU5Z39G6gAA9UxnjyfDQ9BnQjkEGkcE1qg8wwq9YI6zhW211SGVjd/9uU8cYONzVfwcGuTMUfC6rlVIYeimlhk7e0fbuIN7t28uSZRaCAaWNqVmQIgRkQobTJ1N/tJQtos/kAB5TMiNpZifpVLR1Hz+8389BbCoYu4f2pYNpQUOnsiuedmm/hBs+Aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fgGvEdU4oP2VvxxJBFw7rocIdfPCeSVcgUr69sGrc+Y=; b=HAOk0yy0YzzKL1lZacbj7a9T4aA05OSKB0Alag09wiHyXlrCuRLba0shAxaK6n7nsfI/GEhJa6q212EtblZnQi/qe97n6vFmoNG3fBULnnp0mLPK/oKv9/Q3uSAFsvxm0jZa1N+/UEdhjQKhp5n/90lnDGuOJAV/yDVEEeHhVutnB3AK88TlKGWgp6+0K9CwSsoaUAD+aoAzJX1m/qHrpXfwX2jkmFEnE09/i3e8dqrrOZlI017U8XEOepqmntvwPf7zJLcBcfphHydQPZ1Mm2MmE1iXMygTVrnAA2YB2w97l5f0uZH2CsRdRrsxdSjMjtm0oWhtbB6My/SaLffvAg== Received: from AM0PR04CA0135.eurprd04.prod.outlook.com (2603:10a6:208:55::40) by AS5PR07MB9894.eurprd07.prod.outlook.com (2603:10a6:20b:683::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 13:28:22 +0000 Received: from AM4PEPF00027A6B.eurprd04.prod.outlook.com (2603:10a6:208:55:cafe::d) by AM0PR04CA0135.outlook.office365.com (2603:10a6:208:55::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Wed, 16 Oct 2024 13:28:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by AM4PEPF00027A6B.mail.protection.outlook.com (10.167.16.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Wed, 16 Oct 2024 13:28:21 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.68) with Microsoft SMTP Server id 15.2.1544.11; Wed, 16 Oct 2024 15:28:21 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id F00CC1C0073; Wed, 16 Oct 2024 15:28:20 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , David Marchand , Jerin Jacob , Luka Jankovic , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v14 5/7] power: keep per-lcore state in lcore variable Date: Wed, 16 Oct 2024 15:19:14 +0200 Message-ID: <20241016131916.827788-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241016131916.827788-1-mattias.ronnblom@ericsson.com> References: <20241015093344.824073-2-mattias.ronnblom@ericsson.com> <20241016131916.827788-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00027A6B:EE_|AS5PR07MB9894:EE_ X-MS-Office365-Filtering-Correlation-Id: e55de3c1-3807-48a1-b5c1-08dcede66799 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bkNmdUh5ZmR2blgzZDkxaWNnL2xOai9hb2J2cVNZRytQVVpxQkVVNUE3SUtJ?= =?utf-8?B?WEZmS2FLNU4wU3JWUmhtdExUblpqNXZaNUQ0OU4zbHFHVEtqZVNuWTVmR09q?= =?utf-8?B?UmFrNzdpVXU0c3BidVd6TEt3ZFRjOThId2w1aVVaYW12ZG1jSlhneDV4SERQ?= =?utf-8?B?WkJmUHlnT1ltVjFQYWtUYm1CY0JrcU5vTlB1Nkdnck1wT3pFUm1KcWlvb1B2?= =?utf-8?B?V0E4QWtneVVkNHd0WnhpdEZWRjg0eWZUbU9oMnJQcTJSNmtDdHZ4cElucjIz?= =?utf-8?B?V2JseWNHMzQyTUwzKy8vZ2JyOVJVTUE5NmNaRlRySW9YOGcxem5vclB3N2Qr?= =?utf-8?B?dFdtb2dVOVg0M1pCdTNWZVgyWjdEMDhKWXFsdEdvYXN4Z0tBUlJxakNWQVhO?= =?utf-8?B?OFpMR1BXUHJ4SHAzS2JReStwWTkxOUordUtkRDMva3dUL1BVRE9lQThLdlZL?= =?utf-8?B?a3hnZi9JRHhxSnZGV2Z4bFBJSWRLZGNNSFhLTjVRUFpQZ3RmdkJKR0YwWTRX?= =?utf-8?B?MGpiSEh3UjN3L3BEb1Jwei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?QUZZMFY5ODRITUUwMzFVeXFXQ2tmQWYvNXcwSjdtL2Vua1pBMml4L1dnczlt?= =?utf-8?B?a2Rkdm0wbzVobStzeTZySkpqNFgzR0xCRWxwalBrYlcxZmw4bzg4QWl6Sllz?= =?utf-8?B?N0RFVGw2L04zT0c1ZXYvOUZsRGNpQWRjVjMzSGtFb0UyckFIOGpIQ2I5bC9h?= =?utf-8?B?Tk55L3NYcGRvNmhtL1h1dlplejl6ellmZ1F3K3RMWVJxcVIvMEk2UFpOa0M3?= =?utf-8?B?SkNid2RNMFI3TWJUOVJ5R2szSFpQcElpL1FLdFltQjhubXcvSG43MWlyQ0h2?= =?utf-8?B?dCtablFGVGNtSUhpdTQwYi80VVJ4eHg2aU55ZTNHblNjRC94cGw4NXV2SzV5?= =?utf-8?B?SFFaK3hHV2NvWW1FVytFNDJHTTMrQ29KcGU5TTIwV0RzclhnZTZxSGkySmZH?= =?utf-8?Q?tCvg8i0SjFtyG?= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 13:28:21.5374 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e55de3c1-3807-48a1-b5c1-08dcede66799 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00027A6B.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR07MB9894 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 Replace static array of cache-aligned structs with an lcore variable, to slightly benefit code simplicity and performance. Signed-off-by: Mattias Rönnblom Acked-by: Morten Brørup Acked-by: Konstantin Ananyev Acked-by: Chengwen Feng Acked-by: Stephen Hemminger -- PATCH v6: * Update FOREACH invocation to match new API. RFC v3: * Replace for loop with FOREACH macro. --- lib/power/rte_power_pmd_mgmt.c | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index 830a6c7a97..4bab2d5108 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -69,7 +70,7 @@ struct __rte_cache_aligned pmd_core_cfg { uint64_t sleep_target; /**< Prevent a queue from triggering sleep multiple times */ }; -static struct pmd_core_cfg lcore_cfgs[RTE_MAX_LCORE]; +static RTE_LCORE_VAR_HANDLE(struct pmd_core_cfg, lcore_cfgs); static inline bool queue_equal(const union queue *l, const union queue *r) @@ -252,12 +253,11 @@ clb_multiwait(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx, uint16_t max_pkts __rte_unused, void *arg) { - const unsigned int lcore = rte_lcore_id(); struct queue_list_entry *queue_conf = arg; struct pmd_core_cfg *lcore_conf; const bool empty = nb_rx == 0; - lcore_conf = &lcore_cfgs[lcore]; + lcore_conf = RTE_LCORE_VAR(lcore_cfgs); /* early exit */ if (likely(!empty)) @@ -317,13 +317,12 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx, uint16_t max_pkts __rte_unused, void *arg) { - const unsigned int lcore = rte_lcore_id(); struct queue_list_entry *queue_conf = arg; struct pmd_core_cfg *lcore_conf; const bool empty = nb_rx == 0; uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration(); - lcore_conf = &lcore_cfgs[lcore]; + lcore_conf = RTE_LCORE_VAR(lcore_cfgs); if (likely(!empty)) /* early exit */ @@ -358,9 +357,8 @@ clb_scale_freq(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx, uint16_t max_pkts __rte_unused, void *arg) { - const unsigned int lcore = rte_lcore_id(); const bool empty = nb_rx == 0; - struct pmd_core_cfg *lcore_conf = &lcore_cfgs[lcore]; + struct pmd_core_cfg *lcore_conf = RTE_LCORE_VAR(lcore_cfgs); struct queue_list_entry *queue_conf = arg; if (likely(!empty)) { @@ -519,7 +517,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, goto end; } - lcore_cfg = &lcore_cfgs[lcore_id]; + lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -620,7 +618,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id, } /* no need to check queue id as wrong queue id would not be enabled */ - lcore_cfg = &lcore_cfgs[lcore_id]; + lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -770,21 +768,22 @@ rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore) } RTE_INIT(rte_power_ethdev_pmgmt_init) { - size_t i; - int j; + unsigned int lcore_id; + struct pmd_core_cfg *lcore_cfg; + int i; + + RTE_LCORE_VAR_ALLOC(lcore_cfgs); /* initialize all tailqs */ - for (i = 0; i < RTE_DIM(lcore_cfgs); i++) { - struct pmd_core_cfg *cfg = &lcore_cfgs[i]; - TAILQ_INIT(&cfg->head); - } + RTE_LCORE_VAR_FOREACH(lcore_id, lcore_cfg, lcore_cfgs) + TAILQ_INIT(&lcore_cfg->head); /* initialize config defaults */ emptypoll_max = 512; pause_duration = 1; /* scaling defaults out of range to ensure not used unless set by user or app */ - for (j = 0; j < RTE_MAX_LCORE; j++) { - scale_freq_min[j] = 0; - scale_freq_max[j] = UINT32_MAX; + for (i = 0; i < RTE_MAX_LCORE; i++) { + scale_freq_min[i] = 0; + scale_freq_max[i] = UINT32_MAX; } } -- 2.43.0