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 18CAD459C6; Wed, 18 Sep 2024 10:35:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 455E042EEF; Wed, 18 Sep 2024 10:35:48 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2041.outbound.protection.outlook.com [40.107.21.41]) by mails.dpdk.org (Postfix) with ESMTP id D1C0A40264 for ; Wed, 18 Sep 2024 10:35:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o8z5XzDaD/vUJc3xkFQXH66emfK53KDpWJwSVgjTuHSq1LXDR2GiPDSSCOi58ntDoUF64QRNUIeVxWbBoJPCjTUof5v695olmnP7CE5kJBtHtygfXeKNEzsT5bfY77184fcjo+zxNWGpyGqnxEEWNKjlg8JOkYDpzol050SKFvlBdNLrK5+IqQ3uHZl/+0ukst1ovH3CZu6L4d9DMuWpkjbDXtQfR0pEOnY/jEFuoTYFg833iFoErhbXMiR9emGhFMLOdf7T0u+ya4Gxb9YPcc/KaTN8mtxaV+AexxdTkJN39CDJZEHry5/myPCyGKG/PbTmVlBk+0VXj65G2iwJjA== 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=FVFwoilQt4lMAvcBeQ0s00QurXxelwLR0D5OAe+XbTyazTx8LFsdmh0ECCwKf+lqVTun74YWJ9U87vWcJ3BfrOZJ4chVm1mURiPhyBtVyV+cP7xC6b0u0sBuK3FOHkF60ids0PR/OsNDZ1i1mKhsU1Pa7vgG/mW1PqpVLy0uLchTuUqs2lOzFyhVzskT4s7fsjkHjDJOilNj88V7xlalWqDklrgd8lXe3q4sslGJMea0FK0csuA7Fzk5BDrQv34DAiFyIA1uYdmCfbGwZPL3Bw7fyh/ArSLcL3etwV4zKG717jmuf+gBwR5c7t3atyCulwiuFx72S5QZ85rysfPPCg== 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=D+uS0nvO8zEOTc9u0nRA7YTrtK8xUMmmkwbgsJWnIMMEtLDnCKdDs5H+jtG/Mt9tGheq7WwbGMhi4VCBv5g/C3vVmasN1rev9Jo1rZLK5JSRRUeQuBME/1Mbrp71q5nVlvF+mWMSJ6MQHU10QrTN/OgFuZclG8uPh7Kv/486J0fYEdQCvfXWaT4UpjV1vvh6m0stagz6NeXO563xr5Tui7xGeqByEtIk90tvYSHkh0ggOZnKkz6wluNNM8SFM7juFR08rZ8rpFkwXQrTiA+emtkyK1py7ZJpZvfd2nmR/01tYY9wBWJRgIzE8abnVGoQ8MgkNytydYnd+LSfjVLJ2A== Received: from AS4P189CA0009.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5d7::13) by DB9PR07MB8704.eurprd07.prod.outlook.com (2603:10a6:10:30f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Wed, 18 Sep 2024 08:35:41 +0000 Received: from AM2PEPF0001C70D.eurprd05.prod.outlook.com (2603:10a6:20b:5d7:cafe::15) by AS4P189CA0009.outlook.office365.com (2603:10a6:20b:5d7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Wed, 18 Sep 2024 08:35:41 +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 AM2PEPF0001C70D.mail.protection.outlook.com (10.167.16.201) 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:35:41 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.68) with Microsoft SMTP Server id 15.2.1544.11; Wed, 18 Sep 2024 10:35:40 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 95009380070; Wed, 18 Sep 2024 10:35:40 +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 v7 5/7] power: keep per-lcore state in lcore variable Date: Wed, 18 Sep 2024 10:26:12 +0200 Message-ID: <20240918082614.725220-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918082614.725220-1-mattias.ronnblom@ericsson.com> References: <20240918080054.725164-2-mattias.ronnblom@ericsson.com> <20240918082614.725220-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: AM2PEPF0001C70D:EE_|DB9PR07MB8704:EE_ X-MS-Office365-Filtering-Correlation-Id: 7be18920-92d1-45e5-3005-08dcd7bce133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dVRFNUh1dWFrY01OM2R3NW43ZldvMFFDSHBZd0JwMElDVDNrMDUyT25xb2ZB?= =?utf-8?B?MmJFWGEveEZxUlpWSk0xYUl3ak9XWGt1eWkzb2NwWkptL1IrclEwTnpzcm8z?= =?utf-8?B?UGMwakJOQTRUMlRmaVNQV2NZeFgyc25QOGt1eHNxWElzTkRUVjBDVTlwTTJQ?= =?utf-8?B?KzJkV0MxSEVvQUU3ekVFM3lNMi8wVnVRZDVaL0xlMmNxcTZKdGZXb0VybHMw?= =?utf-8?B?ZUNJUDFzMjY2ZUZ6UVhDUHh4L1R6bUh6M2FjL0wyaVhyQU41TVVIeDBmcGNz?= =?utf-8?B?ZWdCSk9QeGFDemtYV05hRTFvK2ZlS3pLbDBzQ0F2dWN1WkZNbmxVS2ZZRHFw?= =?utf-8?B?TWU5Q2Q1UG9OcmhRZjMzMS96M2FMbk5adU9jMGdDWm5XUkMxc1BnTGE1NHBT?= =?utf-8?B?aUhrQ3JHWnk3eEdpL1k0NzEyVXNxeWxDYkY4YVljQXNMVDVhMlRZR0g2eHNr?= =?utf-8?B?WVg1SjBDOXRQSVAxL1ZRZFFYZi9yaVNVS3g2VzFSTE1VUkR1MTJ1VFZaK3Q2?= =?utf-8?B?azUvTjFLbldXVzdWU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5a1VyWDJYcTZ4RkI4NFFFQ1FBVVM1UG1SMzN0RzdXN0wvUzhyZysz?= =?utf-8?B?M3lhaUs5QjZkYVNuVE5sbDU5cGc5SGhWL2FPQ1VpVTVaMk00dGZUcDdESGt6?= =?utf-8?B?Tk5pQk0vOG9nNFB5YVJMcTB5aXcrZjhvVk0zNUdIUUsvMEVjbEtIbnAwNDlV?= =?utf-8?B?N2pNTDFxUW1kcGNQYnJMQjdpTTVSMFZ0bDA5ZktuSUZMaUlpdjAxM2J3OE9W?= =?utf-8?B?My9nMVB3bVlvYW45cFJyVkxYazR6SERMUFNLcHgxZ2RTWTM3Y2MzQU1NQjdX?= =?utf-8?B?aVJ6SEFBblR3YVYzZ1ZLMmFzU0FWNDFQL3FXbXU0cTFQZjV4c0VkVHhmNytS?= =?utf-8?B?NENsU3lUZm1DMDhSbWhiazMvTjlmazYrNUxOZnRjQzFyclVMQnVzdjNaclBC?= =?utf-8?Q?Lv846Rp6bcBMB?= 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)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 08:35:41.1350 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7be18920-92d1-45e5-3005-08dcd7bce133 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: AM2PEPF0001C70D.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB8704 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