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 E7FC245962; Wed, 11 Sep 2024 19:14:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 779F842FAF; Wed, 11 Sep 2024 19:13:59 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2048.outbound.protection.outlook.com [40.107.249.48]) by mails.dpdk.org (Postfix) with ESMTP id AE23642EB0 for ; Wed, 11 Sep 2024 19:13:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JKmJJZv/zeDpjpi+OylUQhFKo2KaFw2H9UVe8NMtqZqCbubci1l0+jTfCirpRCm8jYddoONVWSfogwrvTvZwk8F82Y9pKIpGU3VKb7NRDoDWI0SAs0Bc5FRLCsPvDBPsfQ3VT2ACED+mTKqFMEpsxcmcGCZjBYwYTKqdhf/f6qaRyZmeOXFxBRGCMY8esDHYxz8NThV+DcU33TB4beaVYD2Djr2oI36pKMNutKVzPaMDsMhmva46d3mKgS9l80nd0AJR2+94LKuoHJSmZV/XnpidSwNzXl3sRQkNiYy98bG8HehVBQ3R3IQI7bUYFxUTBtdhc7tNYob3c6i6ZXlF+g== 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=kBpxqgX85DWxmyTJGvSPz7yoWBkPj6gMBWw5io8Onaw=; b=VpLDwTIhh6953/lUWweNOKI3ggU/hDTRuz0wutGSfZqMBxhHWH6T2MxCW/brOQBJ3L1Y1Dnvag5IJ5dTABFMAEUszb9v3YNO+U8VLHZJ+FnZDdKSqZpdgJs7vIv26J+B+eBZpc4QVLMykBrWGeqh2ePmWBIg0j9qVQTTjPI0xU0NGBRJc0P7Ch5HbJgKeKDx103iKadQZgX/zJU8r+6zz7aNDEI7oFGzaBMNfo0JI93U7Fz1Bp6V6Of5gg7sFHF5RLULDcP+AmE/w1jTfV3INvcoVZ05exnyp2KyqKla5+vHc+izM0Cy4ozqUGbsP3gA/YKgAhzDESA2ShS6ZlitbA== 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=kBpxqgX85DWxmyTJGvSPz7yoWBkPj6gMBWw5io8Onaw=; b=vmg06ZKNV30kHfnl5jI5fA52mktBCpUsw2l+74VeYTKs0ToUf1P7ammYk9WXeKBlq902sJk/aRH2sX2XuCflHDcaGnhQDL6U3DvxbmCFpFkJ83N/3OsvuoIjBfW/Ac2hLImeSya+h7RVXfRdHByaykb77wt1cM6b7usBmWTr9BhIqMRJ9xxZ1qmrQwo5YH9nYrBRXanUo0lVfUPHEtQSD4HOXnujYLuXqO7OQ8woaUWJcMFvvZwa3ViCTzgUsiAlEIHTpbNoEYCkAzUa7xEWIxaToi8q0kqkO3J0CuxtFqin70rovACrZ0gfms/rF+6VfzIe7edcARD7BFJwl9fV/w== Received: from AS4P251CA0002.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::8) by AM7PR07MB6804.eurprd07.prod.outlook.com (2603:10a6:20b:1b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Wed, 11 Sep 2024 17:13:51 +0000 Received: from AM4PEPF00027A65.eurprd04.prod.outlook.com (2603:10a6:20b:5d2:cafe::80) by AS4P251CA0002.outlook.office365.com (2603:10a6:20b:5d2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Wed, 11 Sep 2024 17:13:51 +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 AM4PEPF00027A65.mail.protection.outlook.com (10.167.16.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 17:13:51 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.62) with Microsoft SMTP Server id 15.2.1544.11; Wed, 11 Sep 2024 19:13:50 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id A049338007D; Wed, 11 Sep 2024 19:13:50 +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 , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v2 4/6] power: keep per-lcore state in lcore variable Date: Wed, 11 Sep 2024 19:04:28 +0200 Message-ID: <20240911170430.701685-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911170430.701685-1-mattias.ronnblom@ericsson.com> References: <20240910070344.699183-2-mattias.ronnblom@ericsson.com> <20240911170430.701685-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: AM4PEPF00027A65:EE_|AM7PR07MB6804:EE_ X-MS-Office365-Filtering-Correlation-Id: e151d909-f423-4fab-7e99-08dcd2851b9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?Y2VjcWFSVGRBcGpIZGpwOUdPVzNPWWlObWUzWmE2NFZnQ2lIYmhqTnplT2Fv?= =?utf-8?B?VTVPM2tYRlZtMm05YURVN2lOU0hpYWNWU2NxdVV2NXp3SU5kdy9nZUJha1pt?= =?utf-8?B?VVAySHhXSmYyVm55c2M4VDN0KytXQjJqWHlSdiswbXFjcjgwcnZtL3ZTTDB1?= =?utf-8?B?MmVzZkJXWGhKM2Q0ekJQUTY2UU8zVzN2aER1b3ZhdDl5ejRoOFc5VkJLb2pJ?= =?utf-8?B?cXVrall4V1dlU2gvdVErcHpYZlkzS0lKQkEzSGVHbTNBVzFvSUpUSm05bU9r?= =?utf-8?B?aXIrRE1VdGtQWDczd2ZFOGt0NkIrcHZySlVNd1lPMGNyTVFqSWRnVmhHMUtw?= =?utf-8?B?M0c1TDJOYkFyaStUS2kwaCtsSTRGZVVtcWpzbTRaNzdpN2JsZmUzUURWK3lT?= =?utf-8?B?U2p6Z3pTUE5heDJwaU1LbTJ5ZlBZcytkSlZDNjFTc2I1S2tNckRlV1R1bDdF?= =?utf-8?B?aVNWb2duQVNlLzJxbjQzOGhXdXM3ZTlmZEkrNys5U2VZMm5Eb1hEd2ZoT05a?= =?utf-8?B?SXJJeGFwa0tIazd2YjljR2pNQXhGRWJGY1lTeHhrQUN4WjF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RMVzQ4dmZmTlVSR1pOYk5i?= =?utf-8?B?RWRNU3ZMdUg5M0V1Y3hKTllHOTJ5RE5iOHhXWnRkamhHM2JaNHl4UExETHdY?= =?utf-8?B?blo0R2E4RDFQV3BraWRUOHc4MVd5bm5LQXUvaGtQZksxOTVRRGJQY1ExbWpT?= =?utf-8?B?a0VNMTRTQzBsWWtEdHY4U1RkYk5WdzBiVmhOTnBRWVdHVW5JRjR3eGpqM2NP?= =?utf-8?B?Szh4Zm9rWDBIOGRPenlJY25sNmlGeHNkd2k4Rk1ueVdCRUFaZTA2TjJha3Iv?= =?utf-8?B?eHJYR1FWWUVBUEFvYXN5NzYzbmg3cTBzWGxkSmJxcmZHRHRHa1RBUG16T1BL?= =?utf-8?B?aHVTakxxcWZxNGdxS1VqSVZDUk94djU2TDNlcjBORktWUVdXTitteDU5Vm9X?= =?utf-8?B?YS9qNHVOWWJNd1lTR1NHQ0VmVTdOQ1B1UkNjWm9MVEVMZnJaR0xGSWVCU2ta?= =?utf-8?Q?Uwj8oxmoRbkHdJps50QRnrxSNedat2XS?= 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)(376014)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 17:13:51.4998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e151d909-f423-4fab-7e99-08dcd2851b9e 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: AM4PEPF00027A65.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR07MB6804 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 -- RFC v3: * Replace for loop with FOREACH macro. --- 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; } } -- 2.34.1