From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, suanmingm@nvidia.com,
thomas@monjalon.net,
"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
stable@dpdk.org, "Tyler Retzlaff" <roretzla@linux.microsoft.com>,
"Harry van Haaren" <harry.van.haaren@intel.com>,
"Aaron Conole" <aconole@redhat.com>
Subject: [PATCH v2] service: fix deadlock on worker lcore exit
Date: Thu, 3 Oct 2024 08:57:02 +0200 [thread overview]
Message-ID: <20241003065702.3051158-1-david.marchand@redhat.com> (raw)
In-Reply-To: <20241001162603.793853-1-mattias.ronnblom@ericsson.com>
From: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
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 <mattias.ronnblom@ericsson.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
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 <rte_common.h>
#include <rte_cycles.h>
#include <rte_atomic.h>
-#include <rte_malloc.h>
#include <rte_spinlock.h>
#include <rte_trace_point.h>
@@ -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
next prev parent reply other threads:[~2024-10-03 6:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 16:26 [PATCH] service: avoid worker lcore exit deadlock Mattias Rönnblom
2024-10-02 14:02 ` Tyler Retzlaff
2024-10-03 6:57 ` David Marchand [this message]
2024-10-03 9:13 ` [PATCH v2] service: fix deadlock on worker lcore exit David Marchand
2024-10-03 15:50 ` Van Haaren, Harry
2024-10-11 8:50 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241003065702.3051158-1-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=aconole@redhat.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=mattias.ronnblom@ericsson.com \
--cc=roretzla@linux.microsoft.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=suanmingm@nvidia.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).