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 32920459BF; Tue, 17 Sep 2024 16:42:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05B3E40EF0; Tue, 17 Sep 2024 16:42:06 +0200 (CEST) Received: from outbound.mail.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) by mails.dpdk.org (Postfix) with ESMTP id 07F2B40261 for ; Tue, 17 Sep 2024 16:42:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AdbvCSHhYj5c4jQRmi9tOfsJhMBlHiG0dnJNRALlN7KwJ6NJpda/OuPTzXDg4GX2TV2NlKTGMmuAl4Fvs2wCjAchOWQF23c7lhlys/h+PhYiQ7lg5MV5eIDoC8V8NHV3Ki8XqpvHOWIiXs20CaL22xE9ZXqdq2jB3EgH+RXB2Mzm93XbKBfmK69VLkHKbKGaVocUQmMzs40fQBAy8tUeaO7DbH9pGSFQrQbj6iOUC7VR5+IvWsTxDeZG/gWoTagQfozrY9sEanT7c7Rg56dkC6qOO2Qkev1jjwZXB66dvn+5J3h8h0ctFm/9peOAIPl/H3GXCXxy8XGX/ah9JQhjAA== 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=oEe+gNcsYj75J8UJ0kkdBX9KMzvZQUJBU1LmkYQTxXY=; b=IdgnhALl347iYQY46CcW2+9RUx67gFus9/AtNt5mmbCXfekAdMPSRgh+MyS3zUpXPM7s+36tWr7mvnG/u93FVgyiMMaaWy0ENHtvoaEO9XMh1NvRsoAJww5URg8OFexL1bpd1u7sSTpEV+9mI/L9eShxM85VD/bZBLd5lQ0AkuQNxXoKuG0DY6BiiafH96mXqAGhPCRfunT/w1GCEgUudud7gIQ2HKvXqRlrAEfKzfmGOt2ZBdhasyrJbBgBX719vtULXLKmcv3nxMJ7PSV7C+OH+klx6MlgZr7jvd9bq+B479vFA96gFIa/X5KuiE3NpRtjLbSl9JZ5iAQPKILiqg== 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=oEe+gNcsYj75J8UJ0kkdBX9KMzvZQUJBU1LmkYQTxXY=; b=xJWtoRtZIdNz4fxnbbrfTSrZBCv3LjxZekwoH4ksIThX9jGgq6exkPsOmPgfdteJzuzvhO++oIu7ysODGCa51/0I8liyuG8uI3246TNqgtUlhKIAUuxkrAsUA9gqrfML2gj7g1Nfltg7Q0YcYlgEMaijpO3MUa/2OxPWPjSqJf1daWT83DZ0RfDiy7Dj0bmjfxYzy8rwN67k4ywD6eLJ+9su2EkK0O9SPelH5XiEIes6lyIgghFsu8cDKEiBbkbnmMO0eNJOGnlxekVl0Cz93e33IN4F+X4omE+Us5PgCXc4hgGuI3NWcQOEyivmpVDSNt5TeIcctlLAvYzVcwFGsw== Received: from DB8PR03CA0027.eurprd03.prod.outlook.com (2603:10a6:10:be::40) by DBAPR07MB6598.eurprd07.prod.outlook.com (2603:10a6:10:185::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Tue, 17 Sep 2024 14:41:57 +0000 Received: from DB1PEPF000509FD.eurprd03.prod.outlook.com (2603:10a6:10:be:cafe::8b) by DB8PR03CA0027.outlook.office365.com (2603:10a6:10:be::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Tue, 17 Sep 2024 14:41:57 +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 DB1PEPF000509FD.mail.protection.outlook.com (10.167.242.39) 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, 17 Sep 2024 14:41:57 +0000 Received: from seliicinfr00049.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.11; Tue, 17 Sep 2024 16:41:57 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id EFCF5380070; Tue, 17 Sep 2024 16:41:56 +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?= , Konstantin Ananyev Subject: [PATCH v5 5/7] power: keep per-lcore state in lcore variable Date: Tue, 17 Sep 2024 16:32:37 +0200 Message-ID: <20240917143239.724069-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240917143239.724069-1-mattias.ronnblom@ericsson.com> References: <20240916105210.721315-2-mattias.ronnblom@ericsson.com> <20240917143239.724069-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: DB1PEPF000509FD:EE_|DBAPR07MB6598:EE_ X-MS-Office365-Filtering-Correlation-Id: 841f2fcd-d3f9-4d3c-5d7d-08dcd726e1f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aEsxZ1JRcE1hRjgzamczOHp3TXVXQlA5d0FBcGxhWVFhVURnSjFBOWFlTmcz?= =?utf-8?B?SC9lUW5EZ2t1Vm1haS9oTnh2SVNRMWptZ0xnREc2cm53UVhGRHBGQUl0a0Nl?= =?utf-8?B?ZSs3dkswRS9XQkJQRkRneTQzeE1VUVdCMk94YW1kMlc4MlhoL1RGSERtL2lp?= =?utf-8?B?UkRLc2t3SXhNNjBGN1g5TFpRTFd1a3ZILzVjSC91VUhkUWN0QjFtaTZrdml1?= =?utf-8?B?aVpvYmgyRFBMZERmZEFLbVE1MXh2clVDVmdsL3hSQVdqbXFYcm9TVlJJcDd1?= =?utf-8?B?UmpGbjZ5bkV6cUhKMkw5TEtVSGQvdVZvUWFoVldqbUtCb0ZCK29qMVZNbGY2?= =?utf-8?B?VGtjZWZZN05QVjA1M09ObC90clJXSnRzT2xFTzgzaHZHZjlvZEhmSVpTc09P?= =?utf-8?B?QytiSGJEVXN5MW9UU1F5bXkwTDRNNXZRdkh6YWJBczU1cTkwSVBRV2w1RVg4?= =?utf-8?B?SHVSV2tkVU80ZFdHYmwzdlB0RUpDdXEyczF4MTU3b3o3R1lEeVV1ZmR3QmRP?= =?utf-8?B?dXlWaUk5b3hxRlYzd3ViK0RXT1B4Wk9KVTFNQ3RT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KL0duVEwzbVpwWTJtUmF4YWhrUXp1MEM4ZHV3Zlla?= =?utf-8?B?RXlUZk5RUElKS2pJUTZKWGc5VFB1SW1Sb1cvd2J2WVJSbDEwQ3BPd3RXY0p5?= =?utf-8?B?aENZKzM3TU9OUmlKM2hwTml5NWI1UVJTZFRqZkJlQ3RrZW03dWdXcVRlZU5Y?= =?utf-8?B?WDcwdjVmcUFmQnFnTjVTc255MVdFREZEYllGZ2N5NUphTFZickJmZnU1SUd5?= =?utf-8?B?MXRjdUZqVFg2QTNHM2dCZytmanBHeHU1dG1ZYXBvREFLdnFXN1A4OU9Ta2p6?= =?utf-8?B?dEdTa0lHUTJzSlRoUWZET1p0MG1KTHMzNElLOWI1UkViTDUwcXFIRVVCUU5a?= =?utf-8?Q?ttd/3Octt09VEnK3rcyX7GEo26mdZ5tOBLdmU=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)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2024 14:41:57.8735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 841f2fcd-d3f9-4d3c-5d7d-08dcd726e1f6 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: DB1PEPF000509FD.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR07MB6598 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 -- 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