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 B1C7645B04; Thu, 10 Oct 2024 16:31:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A21E2402ED; Thu, 10 Oct 2024 16:31:16 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2069.outbound.protection.outlook.com [40.107.20.69]) by mails.dpdk.org (Postfix) with ESMTP id 34EE54028C for ; Thu, 10 Oct 2024 16:31:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P1w8jSwaPG4Fstm2zgRzKhfLw9pJjeiCT/ybfgHHcl5A93o78wH+XSmlnIIHrU6DvpwRHQ168OPROJIwCDQj5NnJMXcRIiQjRhFb4mZh+7CARYg0yXLclDQbdz3nOorXjQpz2rD/3HNmypaDV3eu9p1oAtk0IyC1H9wMKMMR6mtNk4xIQRUrPPPEUhjgpgfadfM0FZKnkFbdOCOM1p3f3uAeTI8/sXHdYSTRW0qNkz3WR7vjUZ2z758ljsiKJRS97qpQIGHi0JmeqjQYujv3rG2rP2sxIml5UxdVA914ptqdlV+QPIibxJURZzmhTkaceoqbmIPrYDln5fCUWSIl2Q== 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=BqPcb0CZHAMsN7CS7hVMSqhGJidwIIpSIHOdrawrTEM=; b=exRi6Hzb/TTtWii+tCEkDNlNOq+kFfN31v3L8/BUI0bb1TMdmGHIO/fDxedHcQuamBQkZmZXEGB6gqElBA6oiqa6Yexs8dw+Z27umJFgqr7dHRvxTMpZbgc9r3Bv6m/scoTci2ulUDOmq54v75pjYcKteGBr2sN2rwh5ZEDIa4rloPMqkSXh3ppWyK41iDvprja437IrxYB/hksTUmfG5NpIpeAYfKSK5VqZSTfuHrF5dZ3ogS+w5rh7pAu3MzBSghmzCS1+xoGxqyTcSdwdPxEgJOHkVvCCoEk+BUrLiBhbj57vQkObpIOGQkYdtpyFUc4luv/f7BUtjOUnp0drKQ== 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=BqPcb0CZHAMsN7CS7hVMSqhGJidwIIpSIHOdrawrTEM=; b=lRMrTi9t0ShSSoX/T/KLxgc4dWW8uDTEUxL1U+BjggK67nhI0R6Qytt2I1EYLW6AvzvvE3oChr6wU1xNTIbBkK+ZK1guC+QQKdp1KclB/B+j11OHydDXZgknMMB3fXuP0KZaUoWBOyoZCcKEKxH/ZEMeyo+DcViTkehiu6AaAHPByg8myss12u9TQk3ewDbrlrXKt2ewulHzGiUOmbNRdy2IP6JnlsZxxBfGdHV0RD7yYbEwYV+56JdrmYm5voWmHmgLbCDKx6iCjEHQT11MPlZyJGuXxCWo6LMFJkJ4M+G5J5e6k+yealfzcIOy+2oxbFSv0XSarYVJNT5CnZT2rw== Received: from DU2PR04CA0069.eurprd04.prod.outlook.com (2603:10a6:10:232::14) by AS1PR07MB8830.eurprd07.prod.outlook.com (2603:10a6:20b:47d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 14:31:13 +0000 Received: from DU2PEPF00028D00.eurprd03.prod.outlook.com (2603:10a6:10:232:cafe::16) by DU2PR04CA0069.outlook.office365.com (2603:10a6:10:232::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Thu, 10 Oct 2024 14:31:13 +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 DU2PEPF00028D00.mail.protection.outlook.com (10.167.242.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.11 via Frontend Transport; Thu, 10 Oct 2024 14:31:13 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.66) with Microsoft SMTP Server id 15.2.1544.11; Thu, 10 Oct 2024 16:31:12 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 3C7C038007D; Thu, 10 Oct 2024 16:31:12 +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 v9 5/7] power: keep per-lcore state in lcore variable Date: Thu, 10 Oct 2024 16:22:03 +0200 Message-ID: <20241010142205.813134-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010142205.813134-1-mattias.ronnblom@ericsson.com> References: <20241010141349.813088-2-mattias.ronnblom@ericsson.com> <20241010142205.813134-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: DU2PEPF00028D00:EE_|AS1PR07MB8830:EE_ X-MS-Office365-Filtering-Correlation-Id: 1874552e-6706-48ed-8bb7-08dce9383128 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?L1ZOaXFCdVl4eisrZC9OYTc1bVJhdzBJMkpXZE53N2JtRk10dTRaT29PR1Q5?= =?utf-8?B?RHYwNlBVTThmckxITGhDaXIzTC9hMUpZV2Q1Mmk0U3RhNFBIQnVjS3hvQjcx?= =?utf-8?B?SjYxTUkyK2s0MWVKU2NOUDd0aHh1MWZILzBUNnFjcWU3MlVaSk1ZNHBXa0s5?= =?utf-8?B?bFMrSG1GaDc0SjNuTVBiUDd0djZ1bHVoL0grVFIvOFU5aDBaUllFYTliNTZW?= =?utf-8?B?RGFUSm1MTEkwdXkxYytjTytpOTNNYzJKZkxIcEpBWjYvOWNLaDFyQ3F3eC9N?= =?utf-8?B?aGZKa2NObWNOa0ptVm1Db0xDN3J5Q0RMYUhRajZLS3psZm5BMWhkZEkrNHJa?= =?utf-8?B?Y3p4anQzN28zY0E2aWNVN0txYXdjQmJpUk9LcWh1TmtHMlVpdUJGZzR2NkZF?= =?utf-8?B?cWwwWDJmZWtUODM1dTV1VnlFaXM0bzZ5OFdRekh6Q3JjR1NwSUZHV3Z4VXhG?= =?utf-8?B?UEtrWDJMWDFEQm5CSSt2akg3YktKdFBvdndISjNqQUhSZk9IUG0rbkNvYXhZ?= =?utf-8?B?anFDSFpaTVBqV3pPMC9yRTVLaEV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g3STI1RkZHaTVNYkdBR0tWdzNpaWkrZ0hzK2tn?= =?utf-8?B?b1NaMFZNRGYyVExtYWFuQ2l4K0tRZUY5Z3FRVFcwVkI3ZmNURDRMRmQwb3pp?= =?utf-8?B?dEphdDM5VWFLaExWbGxUMVAyM1JLTTNQOHprek9vb2p6dFZkNjJrM1hEZmxQ?= =?utf-8?B?MkNPYmhJUmwxVFl3NUZ6S2VaRjNIQXo3djQ5Ty9FN1JkQmdYMGJRdnJUaFN0?= =?utf-8?B?QmxBd3ltQ0wwL1NoNXg2VWlFNnFhdGt6bXdGSFVKNHJNS0hIRGQ0ZnpoWUFj?= =?utf-8?B?WEN5OSs2TkdRVElTdFVxU3RobFJkU21KZXBkcGJGZ0xXS3hIck5qKzNjOHho?= =?utf-8?B?aGJIU3RnQVdRV1RhVVZIdlE4b01CRE1FWTkvZ0VLSjhjbWRzNXhJUWZPYWdm?= =?utf-8?Q?hm96CYZYCSxrp?= 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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 14:31:13.1167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1874552e-6706-48ed-8bb7-08dce9383128 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: DU2PEPF00028D00.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR07MB8830 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 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.43.0