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 9240A45B59; Thu, 17 Oct 2024 08:07:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 579A7402F0; Thu, 17 Oct 2024 08:07:12 +0200 (CEST) Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2076.outbound.protection.outlook.com [40.107.249.76]) by mails.dpdk.org (Postfix) with ESMTP id 0E6B1402E2 for ; Thu, 17 Oct 2024 08:07:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dXka6KWvf6jh4Urj4PKuLKDgqzYLAVNhygnXSBsC6l2d7q0NmvhPaNW6Lv2eK71hCeIcbUUF6Kivk+4KH1oqKS5hUsbFLRmOJ6Y4vwT+gF6t7GqQghsjabpeDmommD1LF+x/Ez/VZAxST67waUjCTtITgQYenmBP69i1z0ay/dBxA3Cd7Qubub/UmhVnlcomjgbyTmrvLuLRA5z4kRi4hB2sPz6iz0pJxvjG3uHLA7Mdkpj0Zww2I7Y+AIojRTCKGOV91FXfu1otaoEJZI+zwiPI0SSKx+YC4NkNEesC7tmjdRxZzfdsQ/Rk33cmm7ckVf2tJQkbR8vDsQbEjcgvRQ== 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=fgGvEdU4oP2VvxxJBFw7rocIdfPCeSVcgUr69sGrc+Y=; b=DpMbl7Ar00BxHy8mv7mOCzFF9s71Na0G8DM/uKL2++2Ebpb6i8KL3rzadWMrWX93oVwvFZIXTZgveY0l2ZtPZXR22zkoyDnNqR6HNj4iVWeoPHEof688aSE1vy7afGgjr7hS3qvFaXvkZRvoWrCUEMdOgTSvo/t1y2+0/W4sCnM2K/p6Z2mgKNWh2k3ZF2Ip9Prj+K3kJOivaio5thwVYxRDJGOg0MfdMCKVNlHXjwh1r6VrukwQjKO804xE4j+3ZT0KXEK32+IUEGHzPudliJd0EJ9Mgz8VBpSmtpkgUHJLf5I9HI7UUYwCAo+jxznzY2LsLXnhZ+coEGzR66mniw== 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=fgGvEdU4oP2VvxxJBFw7rocIdfPCeSVcgUr69sGrc+Y=; b=TdGlg4Z7OuGSW6/kXkG5zUtQ/Fr/dZCaSbMEZ/j6t47jzHV+GunEZtuHdD0Oto3/f/mH6Gu5Sj0pqQsCpVZlu5GlVnIcpec7xkzFaF7wfJ2dU/uCCzPNAfseEyG5qVIdIMp3FdK8VH9bFbiPtlBmtxFrB7gB+IXgJIWPfsPljBvCTTU9y6db038t70imbckhUNYCLZKCTebJAo2zYsGN1BuY6hv2aNY+qhvuIg2zqcLmFl21bNMbj/vNUudP1n1GdRyPo9rn27K8QAMVesF+OJ45jjV2NQIeFdSFNdwsfs6n5Ec2814NVbpUU6tCRZLChd+oSgihUIFAjkq3xuzRHw== Received: from AM6P193CA0065.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::42) by AS2PR07MB9027.eurprd07.prod.outlook.com (2603:10a6:20b:557::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Thu, 17 Oct 2024 06:07:01 +0000 Received: from AMS0EPF000001A8.eurprd05.prod.outlook.com (2603:10a6:209:8e:cafe::91) by AM6P193CA0065.outlook.office365.com (2603:10a6:209:8e::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 06:07:01 +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 AMS0EPF000001A8.mail.protection.outlook.com (10.167.16.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Thu, 17 Oct 2024 06:07:00 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.65) with Microsoft SMTP Server id 15.2.1544.11; Thu, 17 Oct 2024 08:06:57 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 824D338007D; Thu, 17 Oct 2024 08:06:57 +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 v15 5/7] power: keep per-lcore state in lcore variable Date: Thu, 17 Oct 2024 07:57:41 +0200 Message-ID: <20241017055743.848292-6-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241017055743.848292-1-mattias.ronnblom@ericsson.com> References: <20241016131916.827788-2-mattias.ronnblom@ericsson.com> <20241017055743.848292-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: AMS0EPF000001A8:EE_|AS2PR07MB9027:EE_ X-MS-Office365-Filtering-Correlation-Id: 3304fc9c-bc0a-42f7-6648-08dcee71ea5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YWloVFNtd1FsMnZPV3k2QmFRc0psWlI5SXZGZ1VvVDBQQVk4ZkREbFptOWV5?= =?utf-8?B?STNLak1SKzRiVGlPdTFLUGtCdFdZditGVWQ2WDJPUE54eUZDVm0xTUFNRDkv?= =?utf-8?B?cWNZM1NTYUU3UDNzQzJnMXk4Zm1KdkJudG1vcnczMTFOUGRHc1lBNDlkSXVk?= =?utf-8?B?YXZqWU9HV0RVK21GZGZ5Uk4vejBTQ1lSa0pIWVQ5bnc4LzBhSm8wMEUzQlJt?= =?utf-8?B?eXVpSWJhNkFLTlVrVEY2TWxHRERoWGw0dERrS0krSkMxM1ZsYXdWUEltYlFK?= =?utf-8?B?dXh0NUtPSjZsTms3Rzk3SU95RE5acE83KzllUE5UdnV5azFQWC9HWGROcWhk?= =?utf-8?B?MTBZODRHYm1yYlV0OHFzS1ByZmZxNXBUZzkrUzVHRUxzcVA0TGl5Y1BudFBJ?= =?utf-8?B?eWdFUkJpeEdjZk91K2FxNGFIemM0eXBJRHJCdEVLY0tEbElvVWY2SnV2VEJQ?= =?utf-8?B?Y2VPbXJRc2hmNGdTR3FWa05hVEZpNVh1c09ZdHNvNitCazJwSndId1hFUnU4?= =?utf-8?B?dU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EpD?= =?utf-8?B?akVLZENPTjRlWlRIdlFrVlFmV3dodFZTQ0VQbXlDYVBQb2hVYy9MNG9aWjE2?= =?utf-8?B?RDlMR01rTFRlU09LUmpoWkI3cEoranVYNDdlc0pFMmlxYXVHbTZsMkJhOVQr?= =?utf-8?B?SStRZ1QvNkQrcXBPTll4ek1Kai85SzR0Sm95Q0ZKbTFjVUVneGNxRWxTYnJO?= =?utf-8?B?RHhEKzNsZkZHZUZ0ekhtcmtnaENTRGppcXd0T3RhSDQvQjZVVGV0QWtybnhH?= =?utf-8?B?QXRCME1BMldKcWEwVnU5QmcvWVpYY1AzeDUrZXhGNkV0dDJNSEdXQUp6d0RK?= =?utf-8?B?TjRoVUYzVmJwcUd3eDZwYnVtcWQrOHRGb0IwM0xueWRha0FSMTdDc0FpSlJ1?= =?utf-8?B?a1N0OGRyYS9ZNDI5NGNQb09EbnB6NHlOcU04ejl2QVBOeFEvbWRHOXlRRHh5?= =?utf-8?B?YlkxUnR4MXdtMEdDR2N0QmhNblphZzl6SXVVZnp5TE5HSGc9PQ==?= 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)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 06:07:00.9716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3304fc9c-bc0a-42f7-6648-08dcee71ea5b 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: AMS0EPF000001A8.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR07MB9027 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 830a6c7a97..4bab2d5108 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(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(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(lcore_cfgs); struct queue_list_entry *queue_conf = arg; if (likely(!empty)) { @@ -519,7 +517,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(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -620,7 +618,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(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -770,21 +768,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(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