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 12CC2459C6; Wed, 18 Sep 2024 10:10:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D947642EC1; Wed, 18 Sep 2024 10:10:42 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2065.outbound.protection.outlook.com [40.107.22.65]) by mails.dpdk.org (Postfix) with ESMTP id 0BDDA42E6F for ; Wed, 18 Sep 2024 10:10:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hvy1e03slyK77Yz9fC7nNuD4/R3xO9bTxxSXuVyi2p3uO15/N5V5a/9tAojyGbdJdEtk8VtiXJ18YE09Y7qIA4ra6GPhNIdhAFt/UX4obuLRMnj0AGhGnfnPQUHDdVDn18+E4qscLwLaK1M0uaJ+RCEBdzTk9NHt57tH77w08ruHNM+X0cN5x/dYhELZr97f+aXLFrIG60vcwYAUdzJDFBA+ViuQBu/e2Eqc6vy049IYEzcV360SghZGi2aIBD+uTM4ckVnLxoddH3ZxeeJ/9Zjek/D4sFGtDMs9wWiPVKehUmisBOtAjZGRvjGA2dmV9ed7Szn9J3+CTfkFT2+aqg== 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=vEJ0G4UwfbnJ5Bzgc+2TVtniDjz7GrvnfbaeuM+WtHU=; b=OlXKpFEpBpyN0hnidzKLQs06uyNTFzeFTrS6AtwTfZoCzZJnmZb6ZjZ+SK70uXY/IGU1gEcNpOIWGh1f5pnlkcB/ZeXFRI7q4/16aO+mgBzxxC6rXUDLc8rOp4w2M9FtlzGELx+8rcWTOcaQ6x1ex5NsjXZkPEF/E+95DbTaEkB2heDkzWAyBRXWBCTl9oOGu0O3RCPqLa6Z/D/h56RjWMcG0dJTCh3akGcMES0WZ1lOAqqOC3Bueh04rufKz80oYrHaVm5dG7zw+kNjeX8BV3FqNmmVf33eGgw3dk9HUHpdlI5seNQlpBrKhcWWgwfOU+Q44cNoyhwD13pZpD+GJA== 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=vEJ0G4UwfbnJ5Bzgc+2TVtniDjz7GrvnfbaeuM+WtHU=; b=qaIE8B+Hh9jUKh+NaHUi97Mgvbh16TsMlwLGbHk9V1T5DqpdPP5pFdQMHeqBhFBIRey8S+egNzCGZVK5tPjXaFIaSN2YDU8sVMI5GgHn0uPKnet+M9hqgUelBOJS4CcPLt86cjL5KI0cIt9IssV2Dkk1t7qmSUs5KhVhJVxK3LBVHEbbN0sW1TTBfGYMgSZkcDuII5xzL00/Ot7xmey7cAHdp49zmOEewLhEboWoADkIn2eSrFiH2zGDzLekvLf6443ZxspSaY48Zq57v5O8+jFONsQpI0nCKSrnFTUaQBZjWpAMM4RlbJqJP/iO6UB9R8DS8UYMTiuPKUyu/6sRiQ== Received: from AS9P194CA0025.EURP194.PROD.OUTLOOK.COM (2603:10a6:20b:46d::15) by PR3PR07MB8162.eurprd07.prod.outlook.com (2603:10a6:102:175::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Wed, 18 Sep 2024 08:10:37 +0000 Received: from AMS0EPF00000197.eurprd05.prod.outlook.com (2603:10a6:20b:46d:cafe::94) by AS9P194CA0025.outlook.office365.com (2603:10a6:20b:46d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.25 via Frontend Transport; Wed, 18 Sep 2024 08:10:37 +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 AMS0EPF00000197.mail.protection.outlook.com (10.167.16.219) 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, 18 Sep 2024 08:10:36 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.67) with Microsoft SMTP Server id 15.2.1544.11; Wed, 18 Sep 2024 10:10:36 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 4A1481C006B; Wed, 18 Sep 2024 10:10:36 +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?= , Konstantin Ananyev Subject: [PATCH v6 5/7] power: keep per-lcore state in lcore variable Date: Wed, 18 Sep 2024 10:00:52 +0200 Message-ID: <20240918080054.725164-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918080054.725164-1-mattias.ronnblom@ericsson.com> References: <20240917143239.724069-2-mattias.ronnblom@ericsson.com> <20240918080054.725164-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: AMS0EPF00000197:EE_|PR3PR07MB8162:EE_ X-MS-Office365-Filtering-Correlation-Id: 12dca1bb-749d-44fe-f281-08dcd7b9608a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aUorVW5hUkhwSUpRa0xRdCtLMkUrVG9TQktnT1BxUHdMZmFubVdPTkZ2ZTVz?= =?utf-8?B?Mnp5bkN4VmNjbzFqaDI4dFhSUmprb3VoUTBOKzQ2dUZJNHVPT29OckQ2SmdF?= =?utf-8?B?MWdlSG9vY1NvY0QwcEJRakpJbXJLYjlJTjdMM3Y3amN0WTF0VUpaaUdYTFEw?= =?utf-8?B?dGMxTE5QU3FZN0VCLzFSQUw5YmtCZUhzTUE1aGlUQ2ptOUgxejBMSFo5TFJ6?= =?utf-8?B?RG1YaDEreUVjRGQ3clU3WGFiaG55L2NXcmdMWGd5SFNMUW1OVm1pL2Y4U3dT?= =?utf-8?B?ZEJQVGxWMDZOYTg5ME92VDlpOTJ4U0NSK2ZMREgyTURYWVhnS1lPVmQwS3ZC?= =?utf-8?B?cU5lc0dnN3hNd0hUQk1RRUZIdWRvelRtT1g4YTE1UXkwRDZOc3pvYVJ2YUFZ?= =?utf-8?B?Yk41bGd5L3U1VENGc2JWT25PcEtjUmdmMnllZWl0QTdiUUZGTnlhRXNza1ZJ?= =?utf-8?B?WURUUzBEWitqRzNOakVveEFyT2JuVkdrWUhXdGpsNlBQYTNDeVRLSXBYSE9n?= =?utf-8?B?VndpNzA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FVmNnpx?= =?utf-8?B?bi9peit1cVNrcFVrRE95QlBGZ29oVEJZOXpBNkhJcnYxKzRMRkRyakNhSHNJ?= =?utf-8?B?elZxRlNERzllUnBXS2ZmRWFaVHBMQ3NTMFg1Ry9Ydzk2THE0emNNaU5HbGE0?= =?utf-8?B?R3dzc2dMakRkTGZzdVlKcjI1dnR4bjNxZnpDS05zZW5NeThHNFRTNHgvYm9a?= =?utf-8?B?N2YxSmV1S2kwaW82QzVvOURaWVRZNlFWd0g1aGhKZjdXcG51b0RxYTlQc3Vi?= =?utf-8?B?TEt6bW5RckRBU2luenJGTTJQbkhJUElMYjA3RmRCclFDWjlUdHA2bE9Sanc5?= =?utf-8?B?WndnbjVubHdEcDFNV1RFN29PUFhxTEV0OURhblJ5YkUvcjlHWDN6b04zVllM?= =?utf-8?B?Qm5hK3NzTURlY01BcU9ocW5lY1orZE9jNksxbk9sYXBJMnZkYXQ5RlhGZ3Vo?= =?utf-8?Q?trtddpOqZQU5/?= 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)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 08:10:36.7939 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12dca1bb-749d-44fe-f281-08dcd7b9608a 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: AMS0EPF00000197.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB8162 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 -- 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 b1c18a5f56..a981db4b39 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,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_VALUE(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.34.1