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 64ED245B40; Tue, 15 Oct 2024 09:04:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 524824060B; Tue, 15 Oct 2024 09:04:19 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2043.outbound.protection.outlook.com [40.107.22.43]) by mails.dpdk.org (Postfix) with ESMTP id 62179402E3 for ; Tue, 15 Oct 2024 09:04:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QKxyJxyw8BsV/xf52dUaAmoZqQ/KrzYIvwmsGXNN08nnYQs+PpFQoybaRmHsGHBR4GG8NqOY8LUHbkb7igFrph8uEhom04NFe+imFv+GgPP8it0T/YCH220Y73nVyYGHG/RvD7LvKUOfeZGV6ayww9aaE6IdLj7nxfmEbSExog6EXd7OQCmqcLdt5lkz7DlrxILuYyj8rC19prTvXR0HcdWDH2rWNoSQ09iQuhX3GvMkp0i7TIl6eBPb+2txcWtLhdx14xdhl6aFBCWYpvic5qN0Xp64IuBcK43xHUDMdeTn/9ZMr3yjPsfBefj3baBWeZD6XWnI4mXkPRTSuJEkXQ== 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=f/yANybCmYHpkyjaoiF7sZnt78JrZCf6/n5t92TixyOQ4bDqCSUggMvCdk3amPrW9YL0iFi+eg2cxj0EDANWPH5oGQmtO6wVuN9eSe1ocj4eVLutg5esafDf5sFu7buS8Wo9iHkXRvU/1YR8Kaie3G1KPw8VHeivwxFnANjg2s14xhLke4iGu1RutNwS0tZswlLrhHslTj5/7V9P8YwBT+WwtyFEH/ePNoL9bOeBJ2Lwf60YZntWGGpzxq5PoADVjonJWaDOZX+cbC31CVZEwgH+x9Yfi0WvucWED/7T56VOJmLQ5cEQcvIe3Uokhe25xG8awToyWTID6nIvemh9AA== 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=L8Ib0aJkGMBNQ0uVhqRFPsrEBVwofdNny7pIQWvWnEdOYW3dGbg2WEZRsjgVkLpHQCuocHAeRQ0SwCARfeoixL0Pp05p+oYlq8UVxBaX7Hgn24cKRp1dc5tiNdgibho8NmxjZ2rggK4bruuVE4NbMmefVwawm9OnVfyXVcVtljVv+E7a7qlBd5WNuoDgZbr2s83/B+AER6ZXSLPH/FkszwGlEAwMfqHr4G7siyO6xXKYEiUXrMq4s0+PAl4P6qg8NPTlatrYNK3kT/cdr4kxGFH0a4+V3vp/fg3fUokVHfO8tI45suXg05EcfumfEBUVBefe2UyH8jTF/8B0uStJiQ== Received: from AS9PR04CA0128.eurprd04.prod.outlook.com (2603:10a6:20b:531::10) by DB9PR07MB7100.eurprd07.prod.outlook.com (2603:10a6:10:21a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 07:04:12 +0000 Received: from AMS1EPF0000004A.eurprd04.prod.outlook.com (2603:10a6:20b:531:cafe::56) by AS9PR04CA0128.outlook.office365.com (2603:10a6:20b:531::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 07:04:12 +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 AMS1EPF0000004A.mail.protection.outlook.com (10.167.16.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 07:04:12 +0000 Received: from seliicinfr00050.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; Tue, 15 Oct 2024 09:04:11 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 896791C0073; Tue, 15 Oct 2024 09:04:11 +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 , Luka Jankovic , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v12 5/7] power: keep per-lcore state in lcore variable Date: Tue, 15 Oct 2024 08:55:03 +0200 Message-ID: <20241015065505.823840-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015065505.823840-1-mattias.ronnblom@ericsson.com> References: <20241014074348.821962-2-mattias.ronnblom@ericsson.com> <20241015065505.823840-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: AMS1EPF0000004A:EE_|DB9PR07MB7100:EE_ X-MS-Office365-Filtering-Correlation-Id: 54b24634-ec13-44d5-b885-08dcece792d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?QlFzeittSGtTbVFPNmZ4TWRpbllIci9ZdGpXd3NxS0FYRnpFNlhNVmZWL2xp?= =?utf-8?B?MzNzVU8xVnJHa1REM2pVU3E2MnBaUC9EZDNVaVF0OUIzTktDSmpod09wNURw?= =?utf-8?B?K0dRQWpOcFc2QVZVa3c2dGNOcnJBQ3pFZ0k5bVRrbHBTSFpkT01HWlpzanJB?= =?utf-8?B?b0liZEJDQzNuaFUrVkh0UWVhQ2Zvb1hmY2tZTGMvNEIxWUc3dk5SQzF1eGRk?= =?utf-8?B?VjBoREI0Zmh1SzdvWkxVZTYvWVVSV0RuSkZnVEx1V0hYd3lEK2ltZDV2cEJT?= =?utf-8?B?T3V3Mk03Zzd3S2tuQkFLWDNKQjNmV3JFRW1WMENtaHg4Z0lDeTV2VGlNbkRn?= =?utf-8?B?bkZPU1B3VGpoUVZPcEVLamRxSW1BaTN0LzVHM0VnREg5STZiYjlKajVmNnpC?= =?utf-8?B?bXowSWxUaU91OCtybDdQUnQwOUdaSEhZYmpiTDM5V3dLM0lkSnhScytRT1Bn?= =?utf-8?B?emJYYXlmTTN5L0hXL2ozZlMvQTBxemd4dWluZk9jc0hzb1c4VmNhVTZiMkV0?= =?utf-8?B?TVlIRmFLa0V5eWVubFFja3g2YnBkUnRoSkN5Nm1lM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RJY0lLTUFad2djQXpGelNIVWhzUW8xN2xlcGVT?= =?utf-8?B?SUZnZXpnUjdlMS9CZ09tNlNXYUdoYmlreS9LdEJqU1dHRDJyam5MMEJhMWlw?= =?utf-8?B?WExSQng4UC9pL3hBb2lZTExLMmU1YTU0ejFSU1FUbUdIdnBQQ1J2VzFzRGc5?= =?utf-8?B?TG9GakZ2dEk0M242ekRTUCtoaEo4bldURkF6NWt3TmNVVXVlWGN0TDlscUZx?= =?utf-8?B?ck5jeWNIWVhTYVFHM1daQ3VXcWdkS1U1VW9HbWJhdEx3NWY5VWtlVDQrYlVH?= =?utf-8?B?LzJtbmRkRGVvM09WYkFMWU1BZGFPcFJoc283c2dFV1hNRWpCcXoyOG1tMzRD?= =?utf-8?B?U3d6blVxL0dlUHE3MFVZWC9tOHlqa0VzOGJZalFiTCt4ditPVjNqbjZ4VnZx?= =?utf-8?Q?lzwmm8PH/qPvr?= 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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 07:04:12.4223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54b24634-ec13-44d5-b885-08dcece792d5 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: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7100 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; } } -- 2.43.0