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 3381E45E3B for ; Thu, 5 Dec 2024 18:58:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2F46440BA4; Thu, 5 Dec 2024 18:58:46 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6225940BA0 for ; Thu, 5 Dec 2024 18:58:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733421524; 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=UQ8bPngdZdNpWy5ovWMjBCBJ5QDaa5Qkq9jhKyud7rk=; b=Xqv28r6ZtsZICDeg72wt7jwoVHPaND9YAsN0rH9huMBvm0/m4pWwTI+mcKbIhrnnxtzwEH +MB92H6AekwSkHer0+vDhCklMpiz69v02JxKVqxCoOmL+Wz0trs3JlvqEALBgzDs2RVDSF X92IN6wrvKjSOebP7uCKFvaezrHgdZY= 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-462-ClnURqcPNGqPRh8eQEAO-Q-1; Thu, 05 Dec 2024 12:58:40 -0500 X-MC-Unique: ClnURqcPNGqPRh8eQEAO-Q-1 X-Mimecast-MFC-AGG-ID: ClnURqcPNGqPRh8eQEAO-Q Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 2EDF01956088; Thu, 5 Dec 2024 17:58:38 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.129]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F03BF19560A2; Thu, 5 Dec 2024 17:58:31 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, frode.nordahl@canonical.com, mattias.ronnblom@ericsson.com, stable@dpdk.org, Anatoly Burakov , David Hunt , Sivaprasad Tummala , Stephen Hemminger , Chengwen Feng , Konstantin Ananyev , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH 2/3] power: defer lcore variable allocation Date: Thu, 5 Dec 2024 18:57:53 +0100 Message-ID: <20241205175754.1673888-3-david.marchand@redhat.com> In-Reply-To: <20241205175754.1673888-1-david.marchand@redhat.com> References: <20241205175754.1673888-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -Vm8QIJOPp6Jx0O-RL-jEmhDD5R2CZeYiUsfiag5tCE_1733421518 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 --- 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..29e2d438a3 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -72,6 +72,19 @@ struct __rte_cache_aligned pmd_core_cfg { }; static RTE_LCORE_VAR_HANDLE(struct pmd_core_cfg, lcore_cfgs); +static void +alloc_lcore_cfgs(void) +{ + struct pmd_core_cfg *lcore_cfg; + unsigned int lcore_id; + + 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 +530,9 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, goto end; } + if (lcore_cfgs == NULL) + alloc_lcore_cfgs(); + lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ @@ -617,6 +633,9 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id, return ret < 0 ? -EINVAL : -EBUSY; } + if (lcore_cfgs == NULL) + alloc_lcore_cfgs(); + /* no need to check queue id as wrong queue id would not be enabled */ lcore_cfg = RTE_LCORE_VAR_LCORE(lcore_id, lcore_cfgs); @@ -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