From patchwork Wed Feb 28 10:09:26 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: 137418 X-Patchwork-Delegate: david.marchand@redhat.com 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 44C2143C1F; Wed, 28 Feb 2024 11:17:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3880A427E8; Wed, 28 Feb 2024 11:17:38 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2040.outbound.protection.outlook.com [40.107.7.40]) by mails.dpdk.org (Postfix) with ESMTP id 86F3D40DDB for ; Wed, 28 Feb 2024 11:17:24 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QiNr7Eljkb8nM+MRdrsbgpfBShpIDiH+g51pHX8TbWYyDWM16QtA6JppLV7bgO/TOfzEryXNj55Zfe2S7QI4JziCWCm6eSnNKoVB2Qwr6ycJAvoI2hRnLLzQs3bkpwsLnhdLKxu+yKriBFmHU85EGWqk3TDTXgIzllulMKQlxAPjP2p+sBK9PEnZCCst4X8AYjpvCqFb0KPuri4DHxCI9hW/uo7erOYWj/MpQLB0sKocjpIJNBmt2jZi8bJDMbw3HS+YHgUy6w+YUEb+qxW3bHKypghaPYa9u3DMVBiW4xJtqh3PehRBAQgAWSSJ1X5IC1dHs4CXvFZ1IHFgTHxa/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=r6P73IjIGICPMlen7Dz9PuYmagHog0FDx6vR5RaQ6yk=; b=cZ0+HxD/T+29NxzmbkhSI+XpQbwymZK/ZpLpVz8piVWvp8bNGtC03IVtH6anWeTMUUWZewJ4lLkDEbTMHjVz7iEHAA4VhA25xR4bQO1lSl1i6jd8x1/cYUY2SgBT86vA2iquEowHYGFMu8wpc/nSywlkvpUXWxQaUV0h8ZOEQ1EjvyaHURS21Nm/g1tIPe3bGqqnlJuOtcwZyc0mt9lULH03f4t4LQtvovV2z5QZqZfOZv2GMl+559qpxM0WdXaVaPOYXnGJig0leiWXJHlPr998F0B8C6u2s49CFEmUKAwxNhqZeqDfkmFY29IOXmBeCU4XRDc9g+cD+uGIzwvvzA== 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=r6P73IjIGICPMlen7Dz9PuYmagHog0FDx6vR5RaQ6yk=; b=M+GtHtkoYYzCw1n+/+6T9QwiXT/YpNFMfy02RJ8qSo/XyeFh1akwEwlI83GxN3k4ZHu9ttc0f30DLjz96ew9W7BmXYp96f2WFoRb2cbHf4vF35cwdu8L9KB3Zu7UpakNO6Hmc4l08Kaa4Z2fh/NiVNDUpROpASgr6dqsliTFT5cSyRvWxI0CCZG82lVk/sVAj7PNisORDns5JQyHplvFavPN8GwJx41rK+HQOEQj1Dx2GGASwYWm8vDSE0ras9ue4rrA2GsFDfetXtqS7HqWoze0qPwwesDDygGJDJpJWObSEQS+Q6+pxmrUyJVp9Xep277EqkkJaTAs/zDcY54w/g== Received: from DU2PR04CA0233.eurprd04.prod.outlook.com (2603:10a6:10:2b1::28) by PAXPR07MB7821.eurprd07.prod.outlook.com (2603:10a6:102:13c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.37; Wed, 28 Feb 2024 10:17:23 +0000 Received: from DU6PEPF0000B620.eurprd02.prod.outlook.com (2603:10a6:10:2b1:cafe::32) by DU2PR04CA0233.outlook.office365.com (2603:10a6:10:2b1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.27 via Frontend Transport; Wed, 28 Feb 2024 10:17:22 +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 DU6PEPF0000B620.mail.protection.outlook.com (10.167.8.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Wed, 28 Feb 2024 10:17:22 +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.1258.12; Wed, 28 Feb 2024 11:17:22 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 1A85D380061; Wed, 28 Feb 2024 11:17:22 +0100 (CET) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger , =?utf-8?q?Mattias_R=C3=B6nn?= =?utf-8?q?blom?= Subject: [RFC v5 4/6] power: keep per-lcore state in lcore variable Date: Wed, 28 Feb 2024 11:09:26 +0100 Message-ID: <20240228100928.524277-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228100928.524277-1-mattias.ronnblom@ericsson.com> References: <20240225150330.517225-2-mattias.ronnblom@ericsson.com> <20240228100928.524277-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU6PEPF0000B620:EE_|PAXPR07MB7821:EE_ X-MS-Office365-Filtering-Correlation-Id: b369456c-0003-4d25-66dd-08dc38467430 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T8jOL4VOpU9YFzpF/KMbE4nE1vDxFezT7FQZa9ZYfvP1NVlEgRo+LQkbiZmqMHkgvZ4Z6jiEre7D3+vo8216Blk64kjHh3GAw0h+qpFpuYk1S9K9TPpSIxX4yW+seH56fE1C6mSEnahm2gkHB5LDVIXUe6+WyDkkA9jfzydWOY0RPX7WVCYtXM991ExnFPIk60hB73R35/xSMLIh9deL0Tz16KcogBDPLHOl4t3jtv4OhBu2q3Bixj59Oj1zVzKYMVSBYY1Rn0JUXE+t3MDxr2n8qo3++ovQXgcG1bvVhZCoRrO/pXdelf76pYoYrhdHzK+AhIU0pCC3GiXL4zzQcM4ZlWQZroJ24XgEiiXskK4v/AmYxRC4riiHvNPbTeZrPtTq+2/rfI7JUfCJmH1lV3ygUCtffCTd7FTEIliqd+DbwbsoVrw22Jc/Azd8TCWfqFrfrwa1VjLKAFDaHDIui5Lxo/4p/yX+3MWirQ49umjiwoOnE2wJ78A4JOxpbzHLYQ0/bnFRGZLO0/MHJUB7eaU1Rd3dpX5ynZiP62KMbqxizrjvWwUjq3OkT1fkUGGG79C7q3Mr0DQLcuQD6kCW/g3XC+SirtREDT8B+uhJGiCJKuHtZews4ZBjXyRtTrnlGRRGNojOKyh+Fh1G9khP20mqTUtRwzOQRQR9pl7091VCBw/jgDXnMSLgkfO8JUYdTDGDcFblNIcUUoqsH0fctmGVOhAUQDMbb4NGcRx5mtidx5hYPIJtnbodjnQQql50 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:(13230031)(82310400014)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 10:17:22.7025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b369456c-0003-4d25-66dd-08dc38467430 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: DU6PEPF0000B620.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR07MB7821 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. RFC v3: * Replace for loop with FOREACH macro. Signed-off-by: Mattias Rönnblom Acked-by: Morten Brørup --- lib/power/rte_power_pmd_mgmt.c | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index 591fc69f36..595c8091e6 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 @@ -68,8 +69,8 @@ struct pmd_core_cfg { /**< Number of queues ready to enter power optimized state */ uint64_t sleep_target; /**< Prevent a queue from triggering sleep multiple times */ -} __rte_cache_aligned; -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; } }