From patchwork Fri Oct 11 08:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 145737 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 146A645B12; Fri, 11 Oct 2024 10:28:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF5AC4028B; Fri, 11 Oct 2024 10:28:19 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2079.outbound.protection.outlook.com [40.107.20.79]) by mails.dpdk.org (Postfix) with ESMTP id BC9A7400D5 for ; Fri, 11 Oct 2024 10:28:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RlG6/pfDmXYLm59qsXZLNyuQ3LZp4V7VjjWdKfMlSgbJ7oRblshgju3NY31h0gr5OdhFt7Qv9Yrn4cXGFUSfe3oJc1WFmU3aFXdCImaL5BXAsim2g9R3X1SuKXd6QCv6UU2bkFM4/21ASLbY8v11ZwqbMUL+Jcaw0IcUGZ9O/0V7/4g5WBYs8QUwu8NbClsO6FSkbdpJqfV2EHiDqWecAsj/pfoqrtLEOHMmeVxzArgKdlG3wmm1fus52STd+Lx5+0YWoYCyXWAwzkEHt73TpPpWc8dcD869zmCUwF3tFaxjF7/7pdbIDxeUi37TcjJmtkd2d5lj7Bsx0KclWRqJNA== 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=I6eBdVj6TTREPl1adE/ZI6LdfXkc5+v20xTIc56iI5BOnVSxYON/XoHXN40K7V1BHC9dB0rtg4m9FcARhCx5W7SfY1kvJIeEqJzLSdaVwZGXSczhinwk8x8q+cR3oeKkm6SXJxT3X0TSdpwmceWhZ2pG1jOKx9Wys48ChgeGDARnrxSwc7nl4hAxNLlUUH7dbyg27CrLtefHJGKctKg7q+aYGHC4Aab2VZZLHVsxmBFCOyPYb4G1uTDPI/pNJ17DoYLO83uN5a00KrdrqR8birP6FHmKwCs1BDmMyoGokFsPXxxGnsTB9m/ZPMuyzi6r7Jj15OekZcsTqHw4HaeU/Q== 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=WjKFNL3C21HtO6NniCEy78h6GR3qe6Si9KsHlcF6YVgIEBVMWebIQWwsU709H9X3vq7Ebylq4kaccS2czTH/7t1LrD1aw2Z5GAlzA/dJKheCXjhL/gv2fcuE+UkRqfmBL2/XpJuWRTL1zinTwJ3OwVxngSBkW1adCi4q+iNf0g8o5XsY/PC+jl7chu/eVLh6OM0mRMOY+W0LTAeWWDuVnzPQDbiu2mcEDkCVdljsyWN6u91zuZwTlrsbDiehtuk3BuywKJ2/LY6DZ8JitNkbqU9+Pwxez0TBJCbQxIDt9A7kUx3OT3GmFZw1da87CR7J5I/5w4sBi5MJjeyRrtZqNA== Received: from DUZPR01CA0281.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b9::9) by AS8PR07MB7944.eurprd07.prod.outlook.com (2603:10a6:20b:393::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Fri, 11 Oct 2024 08:28:17 +0000 Received: from DB1PEPF000509F4.eurprd02.prod.outlook.com (2603:10a6:10:4b9:cafe::5c) by DUZPR01CA0281.outlook.office365.com (2603:10a6:10:4b9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.20 via Frontend Transport; Fri, 11 Oct 2024 08:28:17 +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 DB1PEPF000509F4.mail.protection.outlook.com (10.167.242.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Fri, 11 Oct 2024 08:28:16 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.69) with Microsoft SMTP Server id 15.2.1544.11; Fri, 11 Oct 2024 10:28:16 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 0F99A38007D; Fri, 11 Oct 2024 10:28:16 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , David Marchand , Jerin Jacob , Luka Jankovic , =?utf-8?q?Mattias_R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v10 5/7] power: keep per-lcore state in lcore variable Date: Fri, 11 Oct 2024 10:18:59 +0200 Message-ID: <20241011081901.816211-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241011081901.816211-1-mattias.ronnblom@ericsson.com> References: <20241010142205.813134-2-mattias.ronnblom@ericsson.com> <20241011081901.816211-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509F4:EE_|AS8PR07MB7944:EE_ X-MS-Office365-Filtering-Correlation-Id: c5efe31f-ffdc-4f99-44fd-08dce9cea7c2 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?q?L3gqq4dtm6uwf2EtDCJOaIYaapKHM4s?= =?utf-8?q?gjQvQMFUjUua7BTAVRFTUZSVaA8QHMWbbZKdpDfgmHO2ygdg7WIiQNbNQjs805u+7?= =?utf-8?q?xyjiKJQyApTh0eMzvSLABhNjoVDLUl3Uysap/ujyW9ycTdqMlDtEQ/yYqP66eltwp?= =?utf-8?q?89SaNTLq8y5vgEgK8SgaS0OM568lpESEj4J3ms87WPjMN0GLYkYXIahH/90Wul3fE?= =?utf-8?q?kzKE/ryJG8kraGgNTODhlqa9eQTsmiTiWlS0ezK1A00AqJ59uYyigTPVWfl08PZVe?= =?utf-8?q?EEv+Qm8nE3UTc9nh4BW837kaeP5MDDsixBm1Ts4dZu0mTyz0Hj+ChjINgh6DDoUwV?= =?utf-8?q?EJn7gXnjcHHB5aR5j7hAv5AZXwWV1ZHG5hr2xvXp1BNSpGk2FlnFz5Ssbuz8qLguX?= =?utf-8?q?em+L4RiFRrNA+12ztbagTfGVwS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G1KgPJ6xNATDJUqt84ytvclLlUC9V+cNrU/D?= =?utf-8?q?B4qglZqCuHxm?= 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: 11 Oct 2024 08:28:16.6048 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5efe31f-ffdc-4f99-44fd-08dce9cea7c2 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: DB1PEPF000509F4.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7944 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; } }