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 625D443AAA; Thu, 8 Feb 2024 19:25:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D432642E5C; Thu, 8 Feb 2024 19:24:59 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2080.outbound.protection.outlook.com [40.107.6.80]) by mails.dpdk.org (Postfix) with ESMTP id 1EE6F42E38 for ; Thu, 8 Feb 2024 19:24:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kv8/+LMicH1TGZPKm+uJYFUuJmkDEenYeA9TlayG3MZZIqKVefosvqHMQj6MP9WpzBew5owvRNZlWhhDZgIoTArY8ary/FJ/kZMiQYbqhPjR14mlHxA/TFYRiiEfzQdQ/JuU1h70HeMWT6tQeIzz2ZtkQzRaLxYxBrYRZ4YhYFNS0J2Az5T1oqstadOURQ4+8Disb27kgOgZcAtFVnH03KK9eUp4AJT8HYcfSqo7GaFQx82TjaCm9Z+dAk3f8zNg4arvhUuSpkL6mKCYjEarOpQ/VZGwOXSqpbDrRf5p35NLJ20jy5XEOBYX8cjKI4cY+cR0tPWxy6M6+O8tH7rC4w== 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=6M5eDI/e9A/eoZGR022N1+fXYGp1IWmdBUcIORrYIWg=; b=OY9Mg4S7l7iHYiujZphjXrSi37XvHDSDHBvgpw28O8OODYIiQ0rXV+ZH4P6Z8LFDEh+SOT/XGRKZOaYV/Q8+rLNffVTZpxeK3WyWhhKk9K/XY3FnaUWR3pMeH52wr9LVFeMw3RYwtvIeA31A+cj/Pq47iaV6w8zOiqeosIjxcu0DjlGjN4RnQVuytTbyCJ/vJBGBH5C2wiW0IERMZMby6bcXrQPtGKxrqIr9zpz4jLtb4rfCj89aPjnytsD3wiawpY/W9jTpae230DrJN01OMQ9ry0ruLiu2pbd6ar3NLpLKCL+wy2/KLiMBewDzmu9VLNKfcSIZZ+RXNXf5YkxOVQ== 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=6M5eDI/e9A/eoZGR022N1+fXYGp1IWmdBUcIORrYIWg=; b=t1Ex+qJTYsaYiNg186SCtupmOHj8LrFYGiMz7JKsA8cvN4WDjuqGrl39jbLIwtKhQjySg6Wo3jMzx7j6pmhPQM5PXOY5KfZIxxlE/sR7QfUwJE78OX/9NhnGIkJT9+xLx1g30WPUjMF2ho9+xCKzWc/u4979FdCUpRTZJk+AN72Jaw5ar5TUSYNT7c76FON0AP85CmD5jD3bGRpRDWY5XZ4Vh8CCH+00mDHySCYqaA7La+0Hm/qJLQvMiShcQH9IcNQgVDkzxYOLQTnYutfFRvJco+1sTKZ9PjuD2sW4Fy6Q6WaUNs39rrVvWAGvFLas5MVEEKYt7pQSmhvfj7sosQ== Received: from DB8PR06CA0063.eurprd06.prod.outlook.com (2603:10a6:10:120::37) by PA4PR07MB7534.eurprd07.prod.outlook.com (2603:10a6:102:ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.30; Thu, 8 Feb 2024 18:24:54 +0000 Received: from DB5PEPF00014B9F.eurprd02.prod.outlook.com (2603:10a6:10:120:cafe::39) by DB8PR06CA0063.outlook.office365.com (2603:10a6:10:120::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.39 via Frontend Transport; Thu, 8 Feb 2024 18:24:54 +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 DB5PEPF00014B9F.mail.protection.outlook.com (10.167.8.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Thu, 8 Feb 2024 18:24:54 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.61) with Microsoft SMTP Server id 15.2.1258.12; Thu, 8 Feb 2024 19:24:48 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id E6A2E380061; Thu, 8 Feb 2024 19:24:47 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [RFC 4/5] power: keep per-lcore state in lcore variable Date: Thu, 8 Feb 2024 19:16:43 +0100 Message-ID: <20240208181644.455233-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240208181644.455233-1-mattias.ronnblom@ericsson.com> References: <20240208181644.455233-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: DB5PEPF00014B9F:EE_|PA4PR07MB7534:EE_ X-MS-Office365-Filtering-Correlation-Id: 39fa8eb4-1838-4d34-c22c-08dc28d33f3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UexH1BathVelAkCmji1MABFUEM1XuRQX4QejEN5KfUXrG+e5oOXcDitFrwo6QCoMorR8e5UwNJ93CtqoYwUIJEoQdZCRuiixsQ1b6dQntU10ZDWJKwPrkd+uNxZlwp1f+WABl14RzoNYAyixHM/ptJnhXH/x70lJDnvHe49FjlRxjW8BWK0knQz0BAIKbkdIxKHaV73SvVh5DqTnTNonIgAg1f407t2JLKdecwPHxPgUoj2XyaQ+55g4NIc0n2ZQfK4n7qK+3VFaJsMGdryLWZoM0LtbFu2nEnaJea6fv9771b/KqFfrlcC0eRvvro285oztsLqIeCEcBrnBodC9NZA8BQVVu1ampLtMicwpGRqDFxCTOWf0tooKllRcbcOPif3a7XVGcRHareii3qiWw70N501NwCWo5pEWj9JTAbgG2+bQLjnvADxRgBfxeLbIcbPrLGblZa3P02LOV6abBdgpXkkjorWrnkVTaZACUbaJmrNrvcHI1LlALfzdfsAVWIrVwJdvOpwVwU3gKiIB+LOHxf+rCfaXzwGxcKlUVeyjp5bPIGtUNGXOcDdEMvhLLrDH4v1H3eOeD4v9XNeeGCg5l+lPd/ezpMgYshg1ekA= 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)(4636009)(396003)(376002)(136003)(346002)(39860400002)(230922051799003)(1800799012)(82310400011)(64100799003)(451199024)(186009)(36840700001)(46966006)(40470700004)(41300700001)(1076003)(107886003)(2616005)(86362001)(6266002)(336012)(26005)(5660300002)(478600001)(2906002)(70586007)(70206006)(6916009)(316002)(54906003)(8676002)(8936002)(4326008)(36756003)(6666004)(82960400001)(356005)(83380400001)(7636003)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2024 18:24:54.3143 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39fa8eb4-1838-4d34-c22c-08dc28d33f3c 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: DB5PEPF00014B9F.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB7534 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 Signed-off-by: Mattias Rönnblom --- lib/power/rte_power_pmd_mgmt.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index 591fc69f36..bb20e564de 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_PTR(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_PTR(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_PTR(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_PTR(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_PTR(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -772,10 +770,13 @@ RTE_INIT(rte_power_ethdev_pmgmt_init) { size_t i; int j; + 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); + for (i = 0; i < RTE_MAX_LCORE; i++) { + struct pmd_core_cfg *lcore_cfg = + RTE_LCORE_VAR_LCORE_PTR(i, lcore_cfgs); + TAILQ_INIT(&lcore_cfg->head); } /* initialize config defaults */ -- 2.34.1