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 48BFE45BD4; Fri, 25 Oct 2024 10:50:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BC5840156; Fri, 25 Oct 2024 10:50:54 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2045.outbound.protection.outlook.com [40.107.20.45]) by mails.dpdk.org (Postfix) with ESMTP id 7CBD64003C for ; Fri, 25 Oct 2024 10:50:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=She4tNGy7PrguahBWl97KrZ8vGcZxcFQemOVJ0rbbrVmsmQavmRQeupQYVwKoVOYLNQcrMclnOt1dSZga/neRd7cvqRKtkjeC3plbSPF0QCEvYRdBa5lmjtfKfvMmig2KoZ7R3M1I4iCl8btJxOyJN6FR/6jxS44ZKygjXvSOHY8MtrIw8Mn6cF6Rf5vYdpxQISpT/wZ/Hgk/Okh9tcbx8ww6YvFjHdH0MphtiLjG8+dpLJ9aCzm+87136nxz+ukrMszpsneiryMTKBX7h5mghbZilqpQNCkefP0roHUQaUGIf/WuqqcBwMM3NpuksivW47PYNa1mZXyIaaOYK560A== 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=JUViexrXDbwH+ykxkmrKOl9oFD2NuR3+ptOQP5fWbe0=; b=wO2Ml6XdB01wkDyuV4IqVYluB5U7HAGBCqGdBiafbwwvCEasKLN+AsCapoj0i6kdgwiI57bPAXrRvCNWGCE5sTlRABGY+7dtdoT/Bs6+3l+JcZtrUEoCSL/Q9LW8cPoyRMcgYHjEcIn1GVd65/sjHCLt3reh0uyKfkkvbQ9GtmNSD9ket4JpLvFPCo12kn+uu/AbCl8o8e9H57/hyFiG5s1fOv0512ssjmcpPxZzgrxA5h24hjhhNWMd79ErATiI0cGwsJSOafjEqVwKwn7pJm3qUHL17n4y3cpQjNaDVR4pwB8erJrhnNKjal9kHX2olKP928C6qbIdDpO2v6y6Cw== 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=JUViexrXDbwH+ykxkmrKOl9oFD2NuR3+ptOQP5fWbe0=; b=JbUJX2ZhbIrbFHpCz4RmFuXENW1mHAT2HtVgOZli25ZnVVF0AebV1cM8ztLWt7tNJuPOsCOD8Uds39twlGoVGJlYqIF1JDE13esWiGurNozHCWDtBhW6/C3zdnKSZUeqBsk8peFfkYa62tob8RLpZ5Nv95kTy65LAsDN3wb/F40/we6mi7PgAXEM5oYTOwfvXE+aR8PFwe4FhF39X5jifXpLsKftyCOGhQcvLBHiqVwN9ZWhPv53dV+lMsCd1iRV/t1Ev4izCuV3QuTNbdC+bq/B0jeo7K8aCCzydrWt5ZppCnj0RNJyTAYWJT8X0k07+37qWPv/1TWnCsfC3FR0JQ== Received: from DUZPR01CA0259.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b9::7) by AS8PR07MB7303.eurprd07.prod.outlook.com (2603:10a6:20b:259::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Fri, 25 Oct 2024 08:50:51 +0000 Received: from DB5PEPF00014B97.eurprd02.prod.outlook.com (2603:10a6:10:4b9:cafe::93) by DUZPR01CA0259.outlook.office365.com (2603:10a6:10:4b9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20 via Frontend Transport; Fri, 25 Oct 2024 08:50:51 +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 DB5PEPF00014B97.mail.protection.outlook.com (10.167.8.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 08:50:50 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.69) with Microsoft SMTP Server id 15.2.1544.11; Fri, 25 Oct 2024 10:50:50 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 1BA7C1C009D; Fri, 25 Oct 2024 10:50:50 +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 , Thomas Monjalon , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Konstantin Ananyev , Chengwen Feng Subject: [PATCH v17 6/8] power: keep per-lcore state in lcore variable Date: Fri, 25 Oct 2024 10:41:47 +0200 Message-ID: <20241025084149.873037-7-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025084149.873037-1-mattias.ronnblom@ericsson.com> References: <20241023075302.869008-1-mattias.ronnblom@ericsson.com> <20241025084149.873037-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: DB5PEPF00014B97:EE_|AS8PR07MB7303:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ea0d278-6804-4279-2972-08dcf4d220c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?OGZ4RXA3K1J5V0o5UDNoWjZSY3Jody9lbG5IbGJlMkZFSjgzLzBsTGFBb2Fl?= =?utf-8?B?ZHJ0dlRXWjU5aEg0U2N6Q3lCM0FFMGdQN3hxWkVKRVNSQWdOQ0QxVkl0L3Jn?= =?utf-8?B?ek1BZTlmN1kvTTQ2ZDVYU2R2MzVGakI2cnF5OUQyUHRyd01LcFFKYURleHZx?= =?utf-8?B?S1dIQ0Q0SnBHck9QbXNObU5Xakh1R3dpOXliVDlVTHUrZ2ExNDN2UzJlaElN?= =?utf-8?B?K0x4aGZsTjdFTmp1WGl3aUpJbzBJOUxJbnYxRUd6SDZaOHg2bSs3MHdDK3Va?= =?utf-8?B?eXdxTnBzR1I3MzJVQ1htT2R2NTMzSnJEb2s4Zmd0TzIvUVVmOUh1RFJPNVpp?= =?utf-8?B?S1ZLYzZYTFg2ODhwTFUyU2dHM2ZXMWgwc1ZCKzdXRm5LdkljODlGNklyTjgx?= =?utf-8?B?RUdKaTlQVzJQVkEwb2tuanNpWUF2blJPYlVRVklrKzVkcVNZbGN0a2FyQXdh?= =?utf-8?B?SVFaZk5YNTBRa3ovMmVTeHl1aWxraHVZMUY0Vk1yWXBkdUg5NVIvck4vR3ZO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cFRFbGl2K1ZsSzJBcFVu?= =?utf-8?B?cS84ZlhxcnI3cjd6TE90RTU3MUl2d3UvUGRGNnkxS0pCdll1VkRiK2xKMmtr?= =?utf-8?B?TzlvRmlTbkJheXduWHFXVFpBSGZBUDlXNE92TjBJNDJORDBtRE8waW9SaCtH?= =?utf-8?B?VEZrbHY5a1MvdWdNMWxoRUdlU3NYS3ZHQkppYmhqcWtEVzZ4Nk0yV2lFU3NR?= =?utf-8?B?TVIrSElyNG5mckd3YlpOQThnQkpTOGhWY2xaL3lQb3Z6RVVPZmtIVUFWQ2Fz?= =?utf-8?B?M0c1ck1OUDI3cEx5bUJ0VVJsS0ZYUXNDbmFwYzZVUnJxemgySk5LMXorT0ly?= =?utf-8?B?ZVAvSEhXZ3lqTDVySmN4cWhjZ2ZoV3E5aFZlUmRUNXVMZFh1RWFoZytqcWpt?= =?utf-8?B?TDZudlZjZm5WNmt5UFNrdEcveDh3RGFpMXZwdEZJcmVabERQMDdyTmtvbE9y?= =?utf-8?B?NEZVSUR1VWt5dVVGek9JRXZ5V3RQVEw3cnM4RCtzdytSclE9PQ==?= 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)(7416014)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 08:50:50.9441 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ea0d278-6804-4279-2972-08dcf4d220c8 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: DB5PEPF00014B97.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7303 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 5e50613f5b..a2fff3b765 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