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 EA59B4596C; Thu, 12 Sep 2024 10:54:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2368C427B8; Thu, 12 Sep 2024 10:54:27 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by mails.dpdk.org (Postfix) with ESMTP id A2BA7427A6 for ; Thu, 12 Sep 2024 10:54:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D1DWSpiVqlK6OK65xkRVAd7kPdKxsbULIgvaWQdLu+NCpfFimpDq1Z94M7vW6qtISKxTilGvExFnqahZRd/ctiIHGBuX74PSHVHPcEouGGCbD8L3kZ1mTZ3Jm0gBwkTBJHQKMWqa0ioNhOipgpLO1SHxUZVJpsVmwqtOQOn7YKqdwrMAkFwyVLgOwYrUZ9keqywpMn+gu4Hs3SH0lfeibMTmFCW7yBi/2FdbLEJiv5eXrFI+3b/x0eprQFT8UX46QR3/kom0hkk0kMEDJtTP3DFcUxsXrTOXQwypex9PDceCbG2Gw85jaR9bzkUUfmIp45LePWgu4ElrcNKotxEUHQ== 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=DEenlZ7yVm6+KGTgrBz0EmGytiUURzP29wlzeRMl/SNhsyZbiRdg9KlZL7dY7lCVM3eAVeGNs4PMI7eFN5kRZPdveuzj5EHJbZIFbcntLqfAF+Drn988SrVi4x+Yqa0SrxP51GKg82TOQyaBkJ2sKstun4Q89+6ufcXlLEBFPBls0CDxVjA8HD+P0rpMR4tZhcVekmCJfroDSUp29ytUBDg2sLAhl9nZE62Qju5PgGtzslX5g6+nXeOM3QvQxe5CmyyckIrzIGF6gyL5g7t36+FtSNB3/mQp677G0VO1NZPTvImW2EZpEyKByecVrCgBccd77Y97ZtGZ2VtUhuQU4A== 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=JoRBT7xilUHKdCNVNmeHjl27IUDZdndCbL4byRAnjbLDdH4K6VNuNHEuNVTvQeaHNKg/rLvC+YGEEudEQO/RXlLzlwOlMfbVOhRblxhVOm5Qe+KhGiIXXNTIuO9U1hOE6lNG9MEs3FSdjrl3a7wr0O8PSoAcm/DMLaOnugcwxTnwNAgebnVr+jfd5mNquShn7olMGgOl9gkt8twv+kq8fzeEXbZwxhbEPGpL5Gl4OjHJLYWXgFl73+38PRz7RZ4ldPFYdMGULApRAWWiRIJ6wxtS+X8xW17DjkTOLIUF8Dh+59MMiP8oEvUrj5cNMcqOuzSXDLehuwqMDi2KSgAoMw== Received: from AS4P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::9) by AS5PR07MB9915.eurprd07.prod.outlook.com (2603:10a6:20b:682::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Thu, 12 Sep 2024 08:54:23 +0000 Received: from AM3PEPF0000A797.eurprd04.prod.outlook.com (2603:10a6:20b:5db:cafe::d1) by AS4P189CA0020.outlook.office365.com (2603:10a6:20b:5db::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Thu, 12 Sep 2024 08:54: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 AM3PEPF0000A797.mail.protection.outlook.com (10.167.16.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Thu, 12 Sep 2024 08:54:23 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.60) with Microsoft SMTP Server id 15.2.1544.11; Thu, 12 Sep 2024 10:53:51 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id A56B738007F; Thu, 12 Sep 2024 10:53:51 +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 , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v3 5/7] power: keep per-lcore state in lcore variable Date: Thu, 12 Sep 2024 10:44:27 +0200 Message-ID: <20240912084429.703405-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240912084429.703405-1-mattias.ronnblom@ericsson.com> References: <20240911170430.701685-2-mattias.ronnblom@ericsson.com> <20240912084429.703405-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: AM3PEPF0000A797:EE_|AS5PR07MB9915:EE_ X-MS-Office365-Filtering-Correlation-Id: 565b4e7d-58ea-4866-ca8b-08dcd3087fb5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ckNpY0VzN3RDWEx2ZlN1elEzbTFkbFhVbnZLakY4NHpBMFZzbWY5S0pkVUd4?= =?utf-8?B?UWlqTzhPMWF3b2Jub3kwTkd5MXVPMUV6NEMycUh3dVM3azVQSlphY2RPaDlW?= =?utf-8?B?TGhoRENIYmo3NE9Pa0pndGlucVIraE05N0ZUSW1HMi9ITTlBcEQ1UEtNdVdB?= =?utf-8?B?UGF5bVRaWXUyUGd2Yk52QnpnUkJudDV3NjBIMGpETTBmcHp2TDBNT1ZTNkVX?= =?utf-8?B?eTArWnpKaXRVa2JlQ3djem44Q3NPQkd4TXgySmtUY0RCSS9oelZVQTE1eHJN?= =?utf-8?B?T052TXR2aU40cUdDQ0QwbmxyL2I4Ukd6TXUxaWJoQ3JsQ3E3K3lYTzlESDJQ?= =?utf-8?B?STVUbW40QTRhd3VpVmlVdnlVenVIcDJ5NEJIalZBOFdsZWNDa0x4bFVpL3Yx?= =?utf-8?B?TVJqQUM4Q2diQ3FNN0djYkREOWpqeWVUSTQxSzZMVDY3RDVLWTRIT0o1bEhH?= =?utf-8?B?RHlacmw5Q1YrUi9DeXpJTVNDRG9PemdVYloxNlNKVXZkellvQ2lmOWhqbE4r?= =?utf-8?B?ZUxQSFJOcWlnQmJNS2lZR3FqTTRpRGF3V0xQNFR3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YzSkRuaW5iKzJTRkJNaEtwR3ZBR3VEV2xrNW5VKys3Wkc1?= =?utf-8?B?YXRzWkx3bUpDU29RaGRLK1FVbWVXNmUyb0ZVUG1XQXRodjJobC9zTHJQSjlO?= =?utf-8?B?aU9wRW10R2xHRWg0WTI0RWtkRXJnU2hnbCs5QzBraTVsK2NTTmVhWjBRVHRm?= =?utf-8?B?QkZJZU1BWTZ6RzFuUUpUS0ZvRWx5NzZnQmFrYW5lb2tGRVg3QzhyZkd6b0FO?= =?utf-8?B?NCtTR25tZkk5QWxPOWQ1S3BoMTlUSTM1eXEwT1ZzdWFNOVYxeTQyeHVDYk1U?= =?utf-8?B?N0Z2UjlMTjl1MlFIVFJKU3g5RERxWklSS3FvWUkzMU5TTUJGRzJEckllSUtS?= =?utf-8?B?N05WNnlaakxXMVZUY3VRSUlQVUVMSVNNcE02akpKM0RBQUFnMUdnU01QN2Np?= =?utf-8?B?ZXVaeFY1SVFjVGFXWGxYUGVhUEJOcWdIWVVCT3BPQzdtNElKem1raHgyTkZn?= =?utf-8?Q?8XHE9j+ZZTHuLyOlypIu2gfwk2v+ebdV?= 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)(36860700013)(82310400026)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2024 08:54:23.5118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 565b4e7d-58ea-4866-ca8b-08dcd3087fb5 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: AM3PEPF0000A797.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR07MB9915 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