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 E753A459AD; Mon, 16 Sep 2024 13:02:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C17840E96; Mon, 16 Sep 2024 13:01:41 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2084.outbound.protection.outlook.com [40.107.247.84]) by mails.dpdk.org (Postfix) with ESMTP id 83C5E40E25 for ; Mon, 16 Sep 2024 13:01:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jQ4y/eqis2WMteNRS0y6Slewq5n54FeMULrON+WcriIPqUx3dwKfHbbYH+Oh09ZhrlCN9sFMtDPJsWbSOHZQy3syHVa33yHa0NxDiNwnm/dU9S4Vhyh35SAvVkSwwYWma3uW/FHIKFCFJGFhBFTlC1gu/daF584CvPVFXsp6CcAy7OoihSBwBexD79sQcnb0REW0MuoFhZSKVUkoNDSfdWga5IGen3Gxgbnz1R682S4iW/2JUlzU7ILnqdEhCZoSoehr8T6tq3nvi9rgfqcx/s/6ysWCjb3lLizOZX5Tm0gjXnBVrFTG80c8x81SZf21B71fVXGZFMbMYbCBCQNT+g== 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=kBpxqgX85DWxmyTJGvSPz7yoWBkPj6gMBWw5io8Onaw=; b=ZDtBjzwZA0XDzE4BVZV3V5leNxNGbwJdlc4BgTaSRYZehASQ/U9Rr5LOjSro9afrRPmkA6zqXaOiimwoAj0ji5VAfjaOL+QaAX1aSDPG4PJ9QDlAG04i5HW8+mbdOWOUGKKE9k46UNIY3ETh2GKgvtONfqE6AjE+UD7+iCzQKy9z+Z7YELk+W4fK4pBJypYQbWKVah6xxqx2G6gAkBklgMMhC1j+It/q+VhRC0iwNu/A8rutBpF19Zsq+34vkjjWvdvdQ6OUj/mQHOgYDMWS8McYLLl7nb5sI5BIymAo6VQ8G8wnh+WXVdFkgXaS2Cb1w7Mmsn5ArXAJwSxoka7v6g== 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=kBpxqgX85DWxmyTJGvSPz7yoWBkPj6gMBWw5io8Onaw=; b=JEyKbKp0l3vTRDONAhDndGOKErlb9F9tH9LaHMTb2JI80vUrhSeCVhIDWty50jT27WmNVMbgMq2x2oQiqAVCha/i9MFKCem3QI43KALvjSisRuv/pb3wqbXOoJT5h3+/35AddxI5VXPXa6fQWJUHGB0nO8WgWDMPJNESf9tgqL/xD9mBbJVVJQe6HyUkQCzourODAUqj+7607VJ06AjvIjcd/DncDcuKchoIMKeVvv3/y2EOQM7PDhblvIsdXoos9HTlJkjOx12mILD92SX8sYYTH6ja1mbtkQPTDcLwDN8rlQZBu+WQI1vsMI+JeNLilHuJ49BPP2E82FU8zyvy+w== Received: from AS9PR05CA0047.eurprd05.prod.outlook.com (2603:10a6:20b:489::26) by PR3PR07MB6649.eurprd07.prod.outlook.com (2603:10a6:102:6d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Mon, 16 Sep 2024 11:01:31 +0000 Received: from AMS1EPF0000004E.eurprd04.prod.outlook.com (2603:10a6:20b:489:cafe::39) by AS9PR05CA0047.outlook.office365.com (2603:10a6:20b:489::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Mon, 16 Sep 2024 11:01:31 +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 AMS1EPF0000004E.mail.protection.outlook.com (10.167.16.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 11:01:31 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.62) with Microsoft SMTP Server id 15.2.1544.11; Mon, 16 Sep 2024 13:01:28 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 8F041380070; Mon, 16 Sep 2024 13:01:28 +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?= Subject: [PATCH v4 5/7] power: keep per-lcore state in lcore variable Date: Mon, 16 Sep 2024 12:52:08 +0200 Message-ID: <20240916105210.721315-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240916105210.721315-1-mattias.ronnblom@ericsson.com> References: <20240912084429.703405-2-mattias.ronnblom@ericsson.com> <20240916105210.721315-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: AMS1EPF0000004E:EE_|PR3PR07MB6649:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fb5a750-bb55-4dc0-2639-08dcd63eebe1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?eXJhbmZTS0N4aU1Gd2Z1cjN3Z0RUUGdmUmxLRmlKZ1p1bXlEUlVoVk1IUnc4?= =?utf-8?B?QmcrUXZGeHlkcGFDTk1FbFF0RktqNHJEekozUEd1Si9OSThwbnJHZ0dOTE0z?= =?utf-8?B?QjFDOWE0cHZiYnBrQUxXS1NycGRNS1RmblVHNXhBWXloNEJWMzc4eGhEYmV4?= =?utf-8?B?UzJsVHBQRXh3enc5NjhZSGo1Qk5OUVZEZU1RV1NQV2diTzZRV3M4M0QrTTdT?= =?utf-8?B?dnBNSVp2djFSVERwbEVta2g5dDdGTkg1WG1XQXBxWGt3ZllPeUlqWE5jQTJo?= =?utf-8?B?V2t6Vm5hMElTMVRRK2hIU0toNXZuT09RSmZFdTZwa2hpaVJmRTRkNTArM1V6?= =?utf-8?B?VUNWUEZSSnlXVk5KVHJUSCtQOXVsVitSZ2JDRG93blpFUW9oVERuR0dNK1BI?= =?utf-8?B?VDJDeHNvSFVlejNDbC96d2tMeG1pMkQzRklvWG94QkIrWG5OSS9PZmFsUk1T?= =?utf-8?B?a3BUSzdYVDgyMGlGZDdzM0x2c1ZTRHQ1UTY0SUg0bXJSNlFwakxreDg2b0Q4?= =?utf-8?B?eHpIREtpMXZMdTh3MUlhRmxIVTVqaDc1Rm1ucUVzQ044ejhEWk1OSnFqMlR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DNSK0c5ZnZNamJ4TTVXakVm?= =?utf-8?B?YkZmWlZHa1pHNG1UZHlMTFNkRWRJZzhtV3poY2trNFNxbGhZdjRlMDNiS0xy?= =?utf-8?B?RDQrUWMwYzdNb3dURUxEQXlMeWhsbGdOcXhodDhsOGJNYVpMRXg3dFdXMkh2?= =?utf-8?B?UzIzdjljbmtIM2NrWUJXeTJRQWo3SGErZWRrTWF3UStyY1Z3emJiRStpWVIx?= =?utf-8?B?QkRIZzJiOS9YV2doa1BJbUVJRERadHV4bXhJU3lBNC9sZUNUNENJMExpSHhm?= =?utf-8?B?WVQrOCs2UVJ3VnVzK1phajNTdlkrVUVBQmx6VFp0ZEsyTFRUWEJraTJLMnNB?= =?utf-8?Q?bqf3xNEWJWA2Upp/xs7ZCOJPz0PXgbvXgGYjk=3D?= 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)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 11:01:31.3016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fb5a750-bb55-4dc0-2639-08dcd63eebe1 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: AMS1EPF0000004E.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB6649 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 -- RFC v3: * Replace for loop with FOREACH macro. --- lib/power/rte_power_pmd_mgmt.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index b1c18a5f56..a5139dd4f7 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,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; } } -- 2.34.1