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 1B25045ECD; Tue, 17 Dec 2024 10:00:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05BFA40670; Tue, 17 Dec 2024 10:00:47 +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 0AE774066D for ; Tue, 17 Dec 2024 10:00:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734426045; 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=ZgQCRbyh7O3CK7B4qCZg3CTegzGKfuFmcta/MF39qaQ=; b=V8J6Kzoy6FUnWpGfqS/B3iiqUAomJxuwyqvcsA46JZCKJxpJADgZ/U1XWbwMDV2DYrEVLO d0xe5FJ+XKA1U/+2MVwJ0Gm91r92PR/ZucJxrkZ76dWYj9KX73jbmSZJ//f+/D3m7h1cEj qGi32bmhE5+K+frZiyFUrLFg/5XMgkE= Received: from mx-prod-mc-01.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-542-q7mc8739Oxm1cq89Iv3IQA-1; Tue, 17 Dec 2024 04:00:39 -0500 X-MC-Unique: q7mc8739Oxm1cq89Iv3IQA-1 X-Mimecast-MFC-AGG-ID: q7mc8739Oxm1cq89Iv3IQA 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C605195609E; Tue, 17 Dec 2024 09:00:36 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.167]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8E8FE19560A2; Tue, 17 Dec 2024 09:00:32 +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, Bruce Richardson , Konstantin Ananyev , Chengwen Feng , Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH v2 5/5] eal/x86: defer power intrinsics variable allocation Date: Tue, 17 Dec 2024 09:59:52 +0100 Message-ID: <20241217085954.3310414-6-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.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZrQ1grczdapvsiPCuqt3OXcmC2RGkr5ZP3JIaZSYB94_1734426037 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 The lcore variable in this code unit is only used through rte_power_monitor*() public symbols. Defer the unconditional lcore variable allocation in those symbols. Fixes: 18b5049ab4fe ("eal/x86: keep power intrinsics state in lcore variable") Cc: stable@dpdk.org Signed-off-by: David Marchand --- Changes since v1: - added an initialiser helper, --- lib/eal/x86/rte_power_intrinsics.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/eal/x86/rte_power_intrinsics.c b/lib/eal/x86/rte_power_intrinsics.c index e4cb913590..f7d558153e 100644 --- a/lib/eal/x86/rte_power_intrinsics.c +++ b/lib/eal/x86/rte_power_intrinsics.c @@ -22,7 +22,13 @@ struct power_wait_status { RTE_LCORE_VAR_HANDLE(struct power_wait_status, wait_status); -RTE_LCORE_VAR_INIT(wait_status); +static void +init_wait_status(void) +{ + if (wait_status != NULL) + return; + RTE_LCORE_VAR_ALLOC(wait_status); +} /* * This function uses UMONITOR/UMWAIT instructions and will enter C0.2 state. @@ -177,6 +183,7 @@ rte_power_monitor(const struct rte_power_monitor_cond *pmc, if (pmc->fn == NULL) return -EINVAL; + init_wait_status(); s = RTE_LCORE_VAR_LCORE(lcore_id, wait_status); /* update sleep address */ @@ -269,6 +276,7 @@ rte_power_monitor_wakeup(const unsigned int lcore_id) if (lcore_id >= RTE_MAX_LCORE) return -EINVAL; + init_wait_status(); s = RTE_LCORE_VAR_LCORE(lcore_id, wait_status); /* @@ -308,7 +316,7 @@ int rte_power_monitor_multi(const struct rte_power_monitor_cond pmc[], const uint32_t num, const uint64_t tsc_timestamp) { - struct power_wait_status *s = RTE_LCORE_VAR(wait_status); + struct power_wait_status *s; uint32_t i, rc; /* check if supported */ @@ -318,6 +326,9 @@ rte_power_monitor_multi(const struct rte_power_monitor_cond pmc[], if (pmc == NULL || num == 0) return -EINVAL; + init_wait_status(); + s = RTE_LCORE_VAR(wait_status); + /* we are already inside transaction region, return */ if (rte_xtest() != 0) return 0; -- 2.47.0