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 1E92343B51; Tue, 20 Feb 2024 09:57:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD5A340ED8; Tue, 20 Feb 2024 09:57:18 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2042.outbound.protection.outlook.com [40.107.7.42]) by mails.dpdk.org (Postfix) with ESMTP id 3E15940A76 for ; Tue, 20 Feb 2024 09:57:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iqk8siOofoC6dE7jakJl8Czlb5y0YmjBsyF8uoyj307GS8QGaKKCPJeq8uyhBo81vk9sgUds4NfPMDQfKXKUqGbsqHN4LJPZj1FuGIGGwVTuG+rQgBgAkMmanfFpXBovvZF0M+iryZHWREe3jB9LgcVtfB60nIcUgwCEzrBjnlw5DP/LLq7VZgojvVsIobG+G1nhdmKrkkaEJqo7NQpPUVvPGAkVbigD4XShYybQPOsL0xrpdJWGHW25VZrO1V1wuzK5Jasc5tXonbjTkInGomOnhrS+FcnvAi3RoOUDfu18Kixqo5Z726SP+QQ/HiZs27XE4hXcGvnJzeGGvr53cQ== 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=hA3eebkW386q9v1GUm1Am8s0DTEito5MB0PqT9AGAX8=; b=OkjMtWk8Jg2BQzl9FpsQyDvO+32NraEZCQMms5Qxat0P0Av9PvRWunUJSq9q2tka9FJm8eFvjRW5kV2AgxNtvEPktjxXYoEhAN8IvUFXqzhFFhVsqX2A72tpzkL7cTcCUIuqsxvhceJxAevONAWfAcwB6KY2gjSmXmu2uV81lEco+bbO1geEENfJ15BR//W97eqHp7ULWa0Jilo80L9RWFUPACkHPKxWV1qQSFsBLzAJ4JPo/tV27rfRJyiwRE5nz9S47364DvhKnPhQSFHcICbqSjxnbZeNwimzKBe9MFpXtE4w32ad2FThgApxSBJicNvwcEVGlhE/ySoQSRzXbQ== 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=hA3eebkW386q9v1GUm1Am8s0DTEito5MB0PqT9AGAX8=; b=T3mjT3KjgTEqpf5T+SDZEVVpuv9g6arUwzk+ufxYb6JMVPaQ0VHRBXKxlV/b64w5bfsB12Tw2RvbJxYlvVNKPNFztRIuMekv9XACqQzd6hW7kuQ8w/b7JNYWW3R6aaQJDWynt1j0+TajehxlGRZbg7RJf3yrAa1Rig/i/BtzCnw8AEDFjT+adHrHZWvFEuPSqTDqq+N/hLjS42dU2emiTzHyiTiBPBU2xuDmIi/jc0DdrvpDnc9spLAXc2zaxobYJ6pGSNJZVTE4c9zQ0NV+eGuhf8sPrTyDqgt0mTs39A8HjLJctjyZoOnKH80+v0JUmW3uxuqgR3trcWbCvLXWUw== Received: from AS8P251CA0013.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::28) by VI1PR07MB6285.eurprd07.prod.outlook.com (2603:10a6:800:13a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.38; Tue, 20 Feb 2024 08:57:09 +0000 Received: from AMS0EPF00000190.eurprd05.prod.outlook.com (2603:10a6:20b:2f2:cafe::36) by AS8P251CA0013.outlook.office365.com (2603:10a6:20b:2f2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.38 via Frontend Transport; Tue, 20 Feb 2024 08:57:09 +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 AMS0EPF00000190.mail.protection.outlook.com (10.167.16.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 20 Feb 2024 08:57:09 +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.1258.12; Tue, 20 Feb 2024 09:57:06 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 40E3B1C006A; Tue, 20 Feb 2024 09:57:06 +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 v3 4/6] power: keep per-lcore state in lcore variable Date: Tue, 20 Feb 2024 09:49:06 +0100 Message-ID: <20240220084908.488252-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220084908.488252-1-mattias.ronnblom@ericsson.com> References: <20240219094036.485727-2-mattias.ronnblom@ericsson.com> <20240220084908.488252-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: AMS0EPF00000190:EE_|VI1PR07MB6285:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b621672-1c65-44ea-e275-08dc31f1ebbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: telbrJI7Rhm30dzdPZ+3qwLW3M+PFO5Zoj/s7s1l4wf1joDBCcZ4IITtAYOEDy5dTJDVgnbDLqPyKFeMQG9wNOmz/gP43R/8KAX8V5cUPVqVH8M/MrH+XYYV24HiyLxMyCUsKfZC32viIBkBCzXwJh4p1Svi4i/NXoCVLiZQnj4HvysToK2FNp25MTRIttXfD8S3j6cFLNo5EWgdauzo2qWoHX5ncqtvi/r9tuExeFSxa9xPGwEcvs4X+mlF6ctbQGMHK0M2w8v6Ynmm+0LlfsadPUOiwQKG1PCcMHf1qg90AlDpXWe7Q0TnSzuSC456nTBFsTibiBOdjB5zyvzgOyG0XXGGMVv8V8bENzk5SUu1jQhewDoedRxN7SFi2YSc9nKSYxYOusqd/Q4kkGjQpyuz+H6VtWBsgmFWN1SN348PUT0k2ue5Lfvs/lmfLP08Rz2g7bYbpDlw1rO0PY12N66vxZCg3JKLsqspjFoXaKXLfQ3jVkxpAN8Hq0hN8VY+56br4P50a6/pOxNFLpJNlKsoWBs0n8hO+1SU4NYghD7+ULs5aJzKZoYByrWC5vagXib3niHQAgfaeMZGpCO3+LDft+tWE8/l8wb2HmBIltaC+UgaHNI2jJ8kOOorfZ3w3zfmGRqy4Pu0kldXUhBykmHfkQE1Oik4JZ2mIzSOI4I= 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)(36860700004)(46966006)(40470700004); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2024 08:57:09.0981 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b621672-1c65-44ea-e275-08dc31f1ebbb 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: AMS0EPF00000190.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB6285 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 --- 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..ea30454895 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); @@ -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