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 8EE5845ECD for ; Tue, 17 Dec 2024 10:00:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 750004066D; Tue, 17 Dec 2024 10:00:33 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5E83E40668 for ; Tue, 17 Dec 2024 10:00:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734426031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vPr3TX0y1WvWcTnWiffK7sGbqWFO6MZy7pmVHMv0erQ=; b=MSedmxBxn6I5GDDw5rOYQyv84v/LeptxZwlFwX5hDRoe2xdwOpDFT0DCWwsJuxsSlnZaaJ Lh4XN3OdAstFYf0yx34H2YY6GSSBy8itpxTvQ4Ej0uF5GD1SvCdmgSCs9QmduZZ59fcgql mRhk5yn0W8MxiYXNGLf3OpONa4HvHro= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-PbjYF68dNsGcpnSSTYqqDQ-1; Tue, 17 Dec 2024 04:00:25 -0500 X-MC-Unique: PbjYF68dNsGcpnSSTYqqDQ-1 X-Mimecast-MFC-AGG-ID: PbjYF68dNsGcpnSSTYqqDQ Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C8D51955F06; Tue, 17 Dec 2024 09:00:23 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.167]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CEC2F19560A2; Tue, 17 Dec 2024 09:00:18 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, frode.nordahl@canonical.com, mattias.ronnblom@ericsson.com, anatoly.burakov@intel.com, stable@dpdk.org, David Hunt , Sivaprasad Tummala , Konstantin Ananyev , Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Chengwen Feng Subject: [PATCH v2 3/5] power: defer lcore variable allocation Date: Tue, 17 Dec 2024 09:59:50 +0100 Message-ID: <20241217085954.3310414-4-david.marchand@redhat.com> In-Reply-To: <20241217085954.3310414-1-david.marchand@redhat.com> References: <20241205175754.1673888-1-david.marchand@redhat.com> <20241217085954.3310414-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: q4oYVr0D0beJCHBJfU7-Zaile4j9Sbj9hIt2QyCM0Fo_1734426024 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The lcore variable in this code unit is only used through rte_power_ethdev_pmgmt_queue_*() public symbols. Defer the unconditional lcore variable allocation in those symbols. Fixes: 130643319579 ("power: keep per-lcore state in lcore variable") Cc: stable@dpdk.org Signed-off-by: David Marchand --- Changes since v1: - moved some unrelated comment on queue_id, - renamed initialisation helper, --- lib/power/rte_power_pmd_mgmt.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index a2fff3b765..369ce3c354 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -72,6 +72,22 @@ struct __rte_cache_aligned pmd_core_cfg { }; static RTE_LCORE_VAR_HANDLE(struct pmd_core_cfg, lcore_cfgs); +static void +init_lcore_cfgs(void) +{ + struct pmd_core_cfg *lcore_cfg; + unsigned int lcore_id; + + if (lcore_cfgs != NULL) + return; + + RTE_LCORE_VAR_ALLOC(lcore_cfgs); + + /* initialize all tailqs */ + RTE_LCORE_VAR_FOREACH(lcore_id, lcore_cfg, lcore_cfgs) + TAILQ_INIT(&lcore_cfg->head); +} + static inline bool queue_equal(const union queue *l, const union queue *r) { @@ -517,6 +533,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, goto end; } + init_lcore_cfgs(); lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ @@ -618,6 +635,8 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id, } /* no need to check queue id as wrong queue id would not be enabled */ + + init_lcore_cfgs(); lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ @@ -768,16 +787,8 @@ rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore) } RTE_INIT(rte_power_ethdev_pmgmt_init) { - unsigned int lcore_id; - struct pmd_core_cfg *lcore_cfg; int i; - RTE_LCORE_VAR_ALLOC(lcore_cfgs); - - /* initialize all tailqs */ - RTE_LCORE_VAR_FOREACH(lcore_id, lcore_cfg, lcore_cfgs) - TAILQ_INIT(&lcore_cfg->head); - /* initialize config defaults */ emptypoll_max = 512; pause_duration = 1; -- 2.47.0