From patchwork Tue Sep 10 07:03:42 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: 143841 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 E59E245952; Tue, 10 Sep 2024 09:13:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6798842798; Tue, 10 Sep 2024 09:13:12 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by mails.dpdk.org (Postfix) with ESMTP id DAF8342789 for ; Tue, 10 Sep 2024 09:13:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v3CE3ELjbILKt66aK/ZfZCBo55mcN6dFTuIo1dwOEEI0QmcrYDUfTlyvJH22+TnkZx0CSszdSuOU+FM+f2zUoTwGmMmXQospse9/Fk8ysSZqVprEtStqg+XtQ+UJ6W5TRaFutY8Emm3bG/9XkPgSUn14hrtYM6wfNWGHrNuwBnbv3Pt354z6hI/pM0+dKMes0JSqZpA3mpyVH1v8JPkPRvVBtrxr+7fHpQgT1TOg/tSCyDthU9zi8zs3FB1XZeovl1ryJrcnO39kG0fEDG7ZYSvH6Fg20bskC61f9eWSrSCtsmbCh9gH+QM3ixjjzE5N5sYqNlsfCZ/kr/gAZAVupg== 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=Bnv3fhEigfCjgXR3N50oul4L77+ZhQGs+jI0FbcYFAUMaDLuLblh9dxYup+Nydm3K/GUIh0ESB85dGCI42vkYZtIQf8w1ydGm3CCRQryMvmVbqhkIcqm+lQswttduegrjmd/Yb3tq91NQ7EGryhXGFXRj1/Hq8eVVzgtWtZn2zvQjB3hyGYZg3GUVDPKpcBIsw0lYxEjZgkJpH/dlWVYvl+hcBHVwHkpO2OZCtLcWFi01M2RwatPTb57t786OIPhVXnOL+yRL776GDO+GNtOQ8himMk+gmGWn56F0+U4nYi33sqCxWTnWOMZrLc2pXYDRFSKv8MhN4zzBAo5ETWUCQ== 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=gOIzyotvxFaqSWs6SCmURa1VK9/kMRq8HjKPFPma+SVeeGxVT0kprf9PD91P6Umbl+lmhUhvf/G4g5IROrY3C1q+VfATCqjN+hK9SMpYI4RyUWnFaOdmJDCgGXtDHFTxCrJCwwTkqzDrYSVwihu02qpNbR9liJlyXlIamynXF2beq5T3RgUQrXsZhFkphbg5T3y89rSNQxQCmbRgL+qdLjaS2QdFSE1IXpuURNe72Nnaj423a7AM7rdXGBSrDjupAbne2RphuhPPs5CEtkf813HM4zPYDvrgsy2H9Mcym/W9X1dOgg+BcXIg+bpJh13zKTKoTLV5I76L5VLt/Zssaw== Received: from DB7PR02CA0013.eurprd02.prod.outlook.com (2603:10a6:10:52::26) by AS2PR07MB9278.eurprd07.prod.outlook.com (2603:10a6:20b:60e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.28; Tue, 10 Sep 2024 07:13:06 +0000 Received: from DU2PEPF00028CFF.eurprd03.prod.outlook.com (2603:10a6:10:52:cafe::c5) by DB7PR02CA0013.outlook.office365.com (2603:10a6:10:52::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23 via Frontend Transport; Tue, 10 Sep 2024 07:13:06 +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 DU2PEPF00028CFF.mail.protection.outlook.com (10.167.242.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 10 Sep 2024 07:13:06 +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.1544.11; Tue, 10 Sep 2024 09:13:05 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id A39D838007D; Tue, 10 Sep 2024 09:13:05 +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 , =?utf-8?q?Mattias_R=C3=B6nnblom?= Subject: [PATCH 4/6] power: keep per-lcore state in lcore variable Date: Tue, 10 Sep 2024 09:03:42 +0200 Message-ID: <20240910070344.699183-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910070344.699183-1-mattias.ronnblom@ericsson.com> References: <20240506082721.120666-2-mattias.ronnblom@ericsson.com> <20240910070344.699183-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028CFF:EE_|AS2PR07MB9278:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bd3716e-99bf-4e74-97bf-08dcd1680484 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?A0wt4RTLuqwNkhXC7PHqZPrP8alP7Tb?= =?utf-8?q?GA4bfRpqoxFhhr2pYwYiMJG4NSVFDBOBhIxVRpsfBRzpQZdL3D1q/FVS4XInFvdZA?= =?utf-8?q?nE1gfC5CbJQ9DvxJStlKU3YfOFV/PSUs2wXirrbWJK3D/eeREQPeD9hfNx/roBiNf?= =?utf-8?q?y0jpZ3tCaygkXYixsbC1OZyQXjSH1ySIFl4cnEuh2Uyg7JJbVVd3LK/KaOMflox8X?= =?utf-8?q?cnGiL124iyLz/fvRabk3dCBc/q3Cvi9hIqqQDwyo5tc6qaRXiZN12tTqGJU3M7XQq?= =?utf-8?q?6e994/HC67EgXsCVXMvL6iQjl1Dlo6lUXpRi2xTIEufSa1DeYuzWQMmDuxU9nfc6r?= =?utf-8?q?tLOOdAQOo+M5fkabI8ns1aTK+W41Cni40uisQivEX9yZbIYTrELFS8m1o3POOY83L?= =?utf-8?q?9VvvSOdIBH4Z1Gm7JGAMno7Vqr07E40dWoFG95TEYEWplQojt5x9PVjc+bgO96XrW?= =?utf-8?q?cL5qZ+u0ye58GLYIleQp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3cP3qC5BGuaTeCQ0nI8ieOiG76gQPZfFo53nNRi3URHbeVXICE?= =?utf-8?q?ehxGjz6+7Dr?= 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)(82310400026)(36860700013)(1800799024)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 07:13:06.1588 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bd3716e-99bf-4e74-97bf-08dcd1680484 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: DU2PEPF00028CFF.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR07MB9278 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; } }