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 E0B4943FC4; Mon, 6 May 2024 10:39:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D7634068A; Mon, 6 May 2024 10:38:35 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2080.outbound.protection.outlook.com [40.107.13.80]) by mails.dpdk.org (Postfix) with ESMTP id DF67E402DE for ; Mon, 6 May 2024 10:38:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTJKZiZfz46RD2yPKUMHcWCvu10VUQErMKridACMChFQVa4MY/QqGPAed/rrFGAlnlx2LzT5UD2E9YMRYIG8aCQx9z1lw6EFVWlPqW26xoFOxA5oOGKnCTpiYdhFmuYvv9dZGnSiATgyplQar5FRVRquL7lvrneVsTTbdQNDl2GN6OONUXrH+2FsUnwQPKnSYRS8/81eIKLeBxyC8Y0z5NUgcocYL7yTr4Vkgmb+Ee1yh2rxACxnlWCR++HVynoym3gipSn6CngNGM95o9NV5xSop1yQnsMfjp5Qf1po3jAiCtmzBgSxl3fScureZL4Fu0pREv0jSiV5jRrT8LPvrA== 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=UAPG5IrKv36TlW4hfjOUZ0AP0ETcFjlN5y7QwuYr6i8=; b=Bh8sqDo/gpMqc5kNvSzMEdecAhXpFYJ4ypepDnjO7bWUOsGlJbryNAfxPh6+OT57Sx8Nw5ySh1cwTS1BhbIioazv2SVIESky79GfJjMY1RzNgStAuixOxSGno0eif+9p1VWMCT4c9D/PTMSo3/mPkTPuusKSujuozCRx4NvAzTt5Mg21ITYRBXcQPxKuUY3hxy6i5MgtS3sJ56lj5BiExqzpIzXcMZf/CIilCo3pIGTXwIqXorYpsIceWMO+Hh0PzCDR/3ksoyBayjj1EWe7VWMQTbrQYk4MLoaPE0C/YfKEg3HXY43Bw1mFI1zxPxxb+OaMa6HfpCkEImlI5wXHuA== 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=UAPG5IrKv36TlW4hfjOUZ0AP0ETcFjlN5y7QwuYr6i8=; b=WNpYou7kzk4+XoWP20xAAuQL2alsjw5NI3K17lvn7uHcR0hl20AAWMlmmyBob1ohgnjD1WXJyUGlxWN/Re04dPUwZio88aySa2SKbLes+EqBW1JiYi81pk8XPbde8bisMKVtBKkxsUj9VouJfSb0SatAf7oLpOs6EFD07Ij+XjIgKX12r1Nm2bIPQJ/sm7SxTLGgDTuvsdHfYejZn4kEwCaPLRQ1JsvHYVM4+rwKtcq4DSB2JKUqqi5Trb0Uti5avZ3V0k2ScllYVjD25lr2q+mO8gtIckIIxiCkZnjdIYni/mk1f7SqCXG5dxWjubpEh8PUAxSq6fx6xOEqs9ERCw== Received: from DU6P191CA0028.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53f::14) by AM9PR07MB7057.eurprd07.prod.outlook.com (2603:10a6:20b:2c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 08:38:25 +0000 Received: from DU2PEPF00028D04.eurprd03.prod.outlook.com (2603:10a6:10:53f:cafe::4) by DU6P191CA0028.outlook.office365.com (2603:10a6:10:53f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41 via Frontend Transport; Mon, 6 May 2024 08:38:23 +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 DU2PEPF00028D04.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Mon, 6 May 2024 08:38:23 +0000 Received: from seliicinfr00050.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.1544.9; Mon, 6 May 2024 10:38:23 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 234B71C006A; Mon, 6 May 2024 10:38:23 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger , Konstantin Ananyev , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [RFC v6 4/6] power: keep per-lcore state in lcore variable Date: Mon, 6 May 2024 10:27:19 +0200 Message-ID: <20240506082721.120666-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506082721.120666-1-mattias.ronnblom@ericsson.com> References: <20240228100928.524277-2-mattias.ronnblom@ericsson.com> <20240506082721.120666-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: DU2PEPF00028D04:EE_|AM9PR07MB7057:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ae2840b-7287-4ce6-3694-08dc6da7e461 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|82310400017|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RnAxTmg4Z003WDJFaVdUMjJtWVpibWlDYzF1bmQwRVIwdGFSeUF0N2hIaEJK?= =?utf-8?B?a0RWeTg0K2k2MXVhTVYvWHBJUnJXNEpLNnR4ZXBwMDFzSXZOUVM4djg5a2tt?= =?utf-8?B?bkovWVpMbTZVZGtyVnE0Q2JQbUJxVmVoY2tORDRqMzNmSzRDZjBwRWxBZDQx?= =?utf-8?B?cmZmSFYrT2NWTzF5ZE5QbElrSEhCOFZ0V3QwMHR4S1FYZmlMcVlwbGJVbmNm?= =?utf-8?B?NWRMZ2ZlTnI4RWRWSTFJb0gzSHVDSHM5Q0ZsekhEOXV2NmZUZDJIUXozM05Q?= =?utf-8?B?c1hvaUN6ZWNDcHdaUTN1Y0V5K2FSSDNWTnBmUXE0b0dpMUdzYUZUcU9lTmNv?= =?utf-8?B?endXeEF3dDBNdWdUZktiUkRtUGlmUzRORGcyUEZHREt4NzN0S0t4ZitNaGQy?= =?utf-8?B?WlhhZk1aVDlZZXhQV1BpaXhoajRHcXA5VWc5SGhzZmZ3ejR3aUVWR21waXJo?= =?utf-8?B?Yk5XaUFJakwvZUdoelFPU21ZdjZUT0czbU1FcllydUNYYmV1TEI3YzVuV0xl?= =?utf-8?B?cWJWeW5QMzBNVzcydWIreUdCNkZySzM5KzlqOVErWXdDb0xvUE1KMVB4QmYy?= =?utf-8?B?Q2NVLzJadFQ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f-8?B?alpnLytUZm1xQ1Z4QWU1bUxLV1k3bWhJM1dKNkwreFRoekczVERPSk96akpF?= =?utf-8?B?aXYwZ0kxQitlK1lFWEZLQ3NsQ1dLb0xlcHc4V2dOZ2haUU4vdHdWTnVkejM3?= =?utf-8?B?ZmlvcHhPMW05NDhjMTBCK0YyYno4SS9rZ29rdUxEVWlYaW1SUzE0d211czNl?= =?utf-8?B?RTdjRXY0U1hWUmNBanM5Z3NBWk1OYzdGaDBoU1lqOERURWh1U3NYaVRBL1g1?= =?utf-8?B?akZ4dEZoK1JodUNoZlFHTUZEdG84bitudXN0Y2pqT0RwcW0vWTR5ckRMaExV?= =?utf-8?Q?/O/wLz448dDLThFY3Nth/pztglg7iFaqxu93A=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:(13230031)(1800799015)(82310400017)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 08:38:23.7060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ae2840b-7287-4ce6-3694-08dc6da7e461 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: DU2PEPF00028D04.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR07MB7057 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 Acked-by: Morten Brørup --- 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