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 66BA245A91 for ; Thu, 3 Oct 2024 08:57:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B73D400D7; Thu, 3 Oct 2024 08:57:33 +0200 (CEST) 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 466EA400D7 for ; Thu, 3 Oct 2024 08:57:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727938650; 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=jaC3wGa8alklLjUiC3BBawY8Y2nucwloJEv4focfEv8=; b=DqS3/2hEpRZUr+QRXEQ5ChBCHbwtUX2EUYWroUPtK1LWSKnol4ODMO72+gR7MRKDhj+hKq CiOLDz0jdgZUdv80clv/Q2p4AKKuuMWzYGCfapVbpUf367xxX7lNotpRvchWQb5edvcr2L qjZiIK0H+yXKuZigPif/P892p0axYRY= Received: from mx-prod-mc-02.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-395-awG1CqURP-mquvBE_naJQQ-1; Thu, 03 Oct 2024 02:57:27 -0400 X-MC-Unique: awG1CqURP-mquvBE_naJQQ-1 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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 902D31955EEA; Thu, 3 Oct 2024 06:57:25 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.68]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0714719560A2; Thu, 3 Oct 2024 06:57:21 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stephen@networkplumber.org, suanmingm@nvidia.com, thomas@monjalon.net, =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , stable@dpdk.org, Tyler Retzlaff , Harry van Haaren , Aaron Conole Subject: [PATCH v2] service: fix deadlock on worker lcore exit Date: Thu, 3 Oct 2024 08:57:02 +0200 Message-ID: <20241003065702.3051158-1-david.marchand@redhat.com> In-Reply-To: <20241001162603.793853-1-mattias.ronnblom@ericsson.com> References: <20241001162603.793853-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: Mattias Rönnblom Calling rte_exit() from a worker lcore thread causes a deadlock in rte_service_finalize(). This patch makes rte_service_finalize() deadlock-free by avoiding the need to synchronize with service lcore threads, which in turn is achieved by moving service and per-lcore state from the heap to being statically allocated. The BSS segment increases with ~156 kB (on x86_64 with default RTE_MAX_LCORE and RTE_SERVICE_NUM_MAX). According to the service perf autotest, this change also results in a slight reduction of service framework overhead. Fixes: 33666b448f15 ("service: fix crash on exit") Cc: stable@dpdk.org Signed-off-by: Mattias Rönnblom Acked-by: Tyler Retzlaff --- Changes since v1: - rebased, --- lib/eal/common/rte_service.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index a38c594ce4..5b6805b8d8 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -76,8 +75,8 @@ struct __rte_cache_aligned core_state { }; static uint32_t rte_service_count; -static struct rte_service_spec_impl *rte_services; -static struct core_state *lcore_states; +static struct rte_service_spec_impl rte_services[RTE_SERVICE_NUM_MAX]; +static struct core_state lcore_states[RTE_MAX_LCORE]; static uint32_t rte_service_library_initialized; int32_t @@ -95,21 +94,6 @@ rte_service_init(void) return -EALREADY; } - rte_services = rte_calloc("rte_services", RTE_SERVICE_NUM_MAX, - sizeof(struct rte_service_spec_impl), - RTE_CACHE_LINE_SIZE); - if (!rte_services) { - EAL_LOG(ERR, "error allocating rte services array"); - goto fail_mem; - } - - lcore_states = rte_calloc("rte_service_core_states", RTE_MAX_LCORE, - sizeof(struct core_state), RTE_CACHE_LINE_SIZE); - if (!lcore_states) { - EAL_LOG(ERR, "error allocating core states array"); - goto fail_mem; - } - int i; struct rte_config *cfg = rte_eal_get_configuration(); for (i = 0; i < RTE_MAX_LCORE; i++) { @@ -122,10 +106,6 @@ rte_service_init(void) rte_service_library_initialized = 1; return 0; -fail_mem: - rte_free(rte_services); - rte_free(lcore_states); - return -ENOMEM; } void @@ -135,10 +115,6 @@ rte_service_finalize(void) return; rte_service_lcore_reset_all(); - rte_eal_mp_wait_lcore(); - - rte_free(rte_services); - rte_free(lcore_states); rte_service_library_initialized = 0; } -- 2.46.2