From patchwork Mon May 6 08:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 139878 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0B4943FC4; Mon, 6 May 2024 10:39:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D7634068A; Mon, 6 May 2024 10:38:35 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2080.outbound.protection.outlook.com [40.107.13.80]) by mails.dpdk.org (Postfix) with ESMTP id DF67E402DE for ; Mon, 6 May 2024 10:38:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTJKZiZfz46RD2yPKUMHcWCvu10VUQErMKridACMChFQVa4MY/QqGPAed/rrFGAlnlx2LzT5UD2E9YMRYIG8aCQx9z1lw6EFVWlPqW26xoFOxA5oOGKnCTpiYdhFmuYvv9dZGnSiATgyplQar5FRVRquL7lvrneVsTTbdQNDl2GN6OONUXrH+2FsUnwQPKnSYRS8/81eIKLeBxyC8Y0z5NUgcocYL7yTr4Vkgmb+Ee1yh2rxACxnlWCR++HVynoym3gipSn6CngNGM95o9NV5xSop1yQnsMfjp5Qf1po3jAiCtmzBgSxl3fScureZL4Fu0pREv0jSiV5jRrT8LPvrA== 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=UAPG5IrKv36TlW4hfjOUZ0AP0ETcFjlN5y7QwuYr6i8=; b=Bh8sqDo/gpMqc5kNvSzMEdecAhXpFYJ4ypepDnjO7bWUOsGlJbryNAfxPh6+OT57Sx8Nw5ySh1cwTS1BhbIioazv2SVIESky79GfJjMY1RzNgStAuixOxSGno0eif+9p1VWMCT4c9D/PTMSo3/mPkTPuusKSujuozCRx4NvAzTt5Mg21ITYRBXcQPxKuUY3hxy6i5MgtS3sJ56lj5BiExqzpIzXcMZf/CIilCo3pIGTXwIqXorYpsIceWMO+Hh0PzCDR/3ksoyBayjj1EWe7VWMQTbrQYk4MLoaPE0C/YfKEg3HXY43Bw1mFI1zxPxxb+OaMa6HfpCkEImlI5wXHuA== 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=UAPG5IrKv36TlW4hfjOUZ0AP0ETcFjlN5y7QwuYr6i8=; b=WNpYou7kzk4+XoWP20xAAuQL2alsjw5NI3K17lvn7uHcR0hl20AAWMlmmyBob1ohgnjD1WXJyUGlxWN/Re04dPUwZio88aySa2SKbLes+EqBW1JiYi81pk8XPbde8bisMKVtBKkxsUj9VouJfSb0SatAf7oLpOs6EFD07Ij+XjIgKX12r1Nm2bIPQJ/sm7SxTLGgDTuvsdHfYejZn4kEwCaPLRQ1JsvHYVM4+rwKtcq4DSB2JKUqqi5Trb0Uti5avZ3V0k2ScllYVjD25lr2q+mO8gtIckIIxiCkZnjdIYni/mk1f7SqCXG5dxWjubpEh8PUAxSq6fx6xOEqs9ERCw== Received: from DU6P191CA0028.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53f::14) by AM9PR07MB7057.eurprd07.prod.outlook.com (2603:10a6:20b:2c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 08:38:25 +0000 Received: from DU2PEPF00028D04.eurprd03.prod.outlook.com (2603:10a6:10:53f:cafe::4) by DU6P191CA0028.outlook.office365.com (2603:10a6:10:53f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41 via Frontend Transport; Mon, 6 May 2024 08:38:23 +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 DU2PEPF00028D04.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Mon, 6 May 2024 08:38:23 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.61) with Microsoft SMTP Server id 15.2.1544.9; Mon, 6 May 2024 10:38:23 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 234B71C006A; Mon, 6 May 2024 10:38:23 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , =?utf-8?q?Mattias_R?= =?utf-8?q?=C3=B6nnblom?= Subject: [RFC v6 4/6] power: keep per-lcore state in lcore variable Date: Mon, 6 May 2024 10:27:19 +0200 Message-ID: <20240506082721.120666-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506082721.120666-1-mattias.ronnblom@ericsson.com> References: <20240228100928.524277-2-mattias.ronnblom@ericsson.com> <20240506082721.120666-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D04:EE_|AM9PR07MB7057:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ae2840b-7287-4ce6-3694-08dc6da7e461 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Fp1Nh8gM7X2EiWT22mYZbmiCc1und0E?= =?utf-8?q?R0taRyAt7hHhBJkDVy84+i61uaMV/XpIRrW4JK6txepp01sIvNQS8v89kkmnJ/YZL?= =?utf-8?q?m6UdkrVq4CbPmBqVehckND4j33fK4Cf0pElAd41rffHV+OcVO1ydNPlIkHHB8VtWt?= =?utf-8?q?00txKQXfiLqYplbUncf5dLgfeNr8EdVI1IoH3HuCHs9CFlzHD9uv6fTd2HQz33NPs?= =?utf-8?q?XoiCzecCpwZQ3ucEy+aRH3VNpfQq4oGi1GsaFTqOeNcozwWxAwt0MugTfKbRDmPif?= =?utf-8?q?S4NDg2PFGDKx73tKKxf+Mhd2ZXafMZT9YexPWPiixhj4Gqp9Ug9Hhsffwz4wiEVGm?= =?utf-8?q?pirhbNWiAIjL/eGhzQOSmYv6TOG3mMErYruCXbeuLB7c5nWLeqbVynP30MW72ub+y?= =?utf-8?q?GB6FrK39+9j9Q+YwCoLoPMJ1PxBf2CcU/2ZtT3wU0c+AsEnhWPQvFsWQS+I9z2/Ne?= =?utf-8?q?1D0W3Na1ua0r6zOJXfVBW9bRU6qf9OYejV0Yyio1jDbOXmlp88WJV1gT8GfOv+bpf?= =?utf-8?q?INnmQt5a3eogztzkM/nVRNwfOUfK20d13ipoThzs++LoNVsS4rDBUVdhDbbLv3k15?= =?utf-8?q?F1E3Gik+QvA65LUHarxOt6cMj46t5juwUdlhIQy8cTxRL94qCaW2sENg4Gwmgr2z7?= =?utf-8?q?HnbclRGgFis0ug30D2zb88HPTwXT+kCw7Fsi5uox8m1CXZPvtSijCFV+BnKWvv6zw?= =?utf-8?q?NlcFmfqxR7ctBGeDdjdZyV4xgvciqk+Udj3LulpvH/czEF2ZB+589++4Lq269zTXC?= =?utf-8?q?h2UV5ZODqJpMRMO+6BmzRLHTS/IVJnxR+uYiORFSkQV7ADOxu28AngBD7A5d/sNzy?= =?utf-8?q?PHJqX/Tta9yBtEy+d112NXBgfdwTqKzx8h1PzDTifjpyYULlMFJ3ICozKrKoOKKTW?= =?utf-8?q?fx0GRpwyCsByAjzTBT4ThWChdB5Ufa/gQY79uQA2DmGa3w2avcRxuFFuWv6ztl2LM?= =?utf-8?q?PgniIPLF/HGztXAm657zngU/8BqTl9xQgKBD/5egyqpXXraQ+tTNNMMaGnttMcXdO?= =?utf-8?q?8cz4lF4LDsSNo3MHEkc7BVsfkhVUoM4G0oHYGTkz7S5I1ebA1V4E2ZjZg/+TfmqCV?= =?utf-8?q?xAe5mLKWY7mhI3WJ6L+xThzG3TDOJOzjJEiv0gI1B+e+YEXFKCslCWKoLepw8WgNg?= =?utf-8?q?hZQN/twVNudz37fiopxO1m948c10B+F2bz8I/kgokuLDUiXimRS14wmus3eE7cEv4?= =?utf-8?q?SXVRcAjs9gsAZMNc7Fh0hSYj8DTEhuSsXiTA/X5jFxtFh+RhuChfQGMFDto8n+nus?= =?utf-8?q?tcjjODpqm/Y4yrDLhLU/O/wLz448dDLThFY3Nth/pztglg7iFaqxu93A=3D?= 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:(13230031)(1800799015)(82310400017)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 08:38:23.7060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ae2840b-7287-4ce6-3694-08dc6da7e461 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: DU2PEPF00028D04.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR07MB7057 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. RFC v3: * Replace for loop with FOREACH macro. Signed-off-by: Mattias Rönnblom Acked-by: Morten Brørup --- lib/power/rte_power_pmd_mgmt.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index b1c18a5f56..a5139dd4f7 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_VALUE(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_VALUE(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_VALUE(lcore_cfgs); struct queue_list_entry *queue_conf = arg; if (likely(!empty)) { @@ -518,7 +516,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_VALUE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -619,7 +617,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_VALUE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -769,21 +767,21 @@ rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore) } RTE_INIT(rte_power_ethdev_pmgmt_init) { - size_t i; - int j; + 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_VALUE(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; } }