From: Artemy Kovalyov <artemyko@nvidia.com>
To: <dev@dpdk.org>
Cc: Thomas Monjalon <thomas@monjalon.net>, <stable@dpdk.org>,
Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [PATCH v2 5/5] eal: fix memzone fbarray cleanup
Date: Thu, 7 Mar 2024 07:01:13 +0000 [thread overview]
Message-ID: <20240307070113.29580-6-artemyko@nvidia.com> (raw)
In-Reply-To: <20240307070113.29580-1-artemyko@nvidia.com>
The initialization of the Memzone file-backed array ensures its
uniqueness by employing an exclusive lock. This is crucial because only
one primary process can exist per specific shm_id, which is further
protected by the exclusive EAL runtime configuration lock.
However, during the process closure, the exclusive lock on both the
fbarray and the configuration is not explicitly released. The
responsibility of releasing these locks is left to the generic quit
procedure. This can lead to a potential race condition when the
configuration is released before the fbarray.
To address this, we propose explicitly closing the memzone fbarray. This
ensures proper order of operations during process closure and prevents
any potential race conditions arising from the mismatched lock release
timings.
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Artemy Kovalyov <artemyko@nvidia.com>
---
lib/eal/common/eal_common_memzone.c | 12 ++++++++++++
lib/eal/common/eal_private.h | 5 +++++
lib/eal/linux/eal.c | 1 +
3 files changed, 18 insertions(+)
diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c
index 1f3e701..7db8029 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -447,6 +447,18 @@
return ret;
}
+void
+rte_eal_memzone_cleanup(void)
+{
+ struct rte_mem_config *mcfg;
+
+ mcfg = rte_eal_get_configuration()->mem_config;
+
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ rte_fbarray_destroy(&mcfg->memzones);
+ }
+}
+
/* Walk all reserved memory zones */
void rte_memzone_walk(void (*func)(const struct rte_memzone *, void *),
void *arg)
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 4d2e806..944c365 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -81,6 +81,11 @@ struct rte_config {
int rte_eal_memzone_init(void);
/**
+ * Cleanup the memzone subsystem (private to eal).
+ */
+void rte_eal_memzone_cleanup(void);
+
+/**
* Fill configuration with number of physical and logical processors
*
* This function is private to EAL.
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 9b59cec..dfcbe64 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1375,6 +1375,7 @@ static void rte_eal_init_alert(const char *msg)
eal_trace_fini();
eal_mp_dev_hotplug_cleanup();
rte_eal_alarm_cleanup();
+ rte_eal_memzone_cleanup();
/* after this point, any DPDK pointers will become dangling */
rte_eal_memory_detach();
rte_eal_malloc_heap_cleanup();
--
1.8.3.1
next prev parent reply other threads:[~2024-03-07 7:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 4:25 [PATCH 0/5] addressing races in concurrent process startup Artemy Kovalyov
2023-12-12 4:25 ` [PATCH 1/5] app/test-pm: add multiprocess test Artemy Kovalyov
2023-12-12 17:09 ` Stephen Hemminger
2023-12-17 3:53 ` [PATCH v2 1/5] app/test-mp: " Artemy Kovalyov
2024-03-06 20:20 ` David Marchand
2024-03-07 6:59 ` [PATCH 0/5] addressing races in concurrent process startup Artemy Kovalyov
2024-03-07 7:01 ` Artemy Kovalyov
2024-03-07 7:01 ` [PATCH v2 1/5] app/test-mp: add multiprocess test Artemy Kovalyov
2024-03-13 16:05 ` Burakov, Anatoly
2024-03-07 7:01 ` [PATCH v2 2/5] eal: fix multiprocess hotplug race Artemy Kovalyov
2024-03-13 16:05 ` Burakov, Anatoly
2024-03-07 7:01 ` [PATCH v2 3/5] ipc: fix mp channel closure to prevent message loss Artemy Kovalyov
2024-03-13 16:06 ` Burakov, Anatoly
2024-03-07 7:01 ` [PATCH v2 4/5] eal: fix first time primary autodetect Artemy Kovalyov
2024-03-13 16:06 ` Burakov, Anatoly
2024-03-07 7:01 ` Artemy Kovalyov [this message]
2024-03-13 16:17 ` [PATCH v2 5/5] eal: fix memzone fbarray cleanup Burakov, Anatoly
2023-12-12 4:25 ` [PATCH 2/5] eal: fix multiprocess hotplug race Artemy Kovalyov
2023-12-12 4:25 ` [PATCH 3/5] ipc: fix mp channel closure to prevent message loss Artemy Kovalyov
2023-12-12 4:25 ` [PATCH 4/5] eal: fix first time primary autodetect Artemy Kovalyov
2023-12-12 4:25 ` [PATCH 5/5] eal: fix memzone fbarray cleanup Artemy Kovalyov
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=20240307070113.29580-6-artemyko@nvidia.com \
--to=artemyko@nvidia.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--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).