patch 'eal: add helper to initialize process-shared mutex' has been queued to stable release 24.11.7

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Jun 11 15:19:30 CEST 2026


Hi,

FYI, your patch has been queued to stable release 24.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/13/26. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/63d0fa6dc17614aa5fd3a4ac8bca69cfa51a80fe

Thanks.

Luca Boccassi

---
>From 63d0fa6dc17614aa5fd3a4ac8bca69cfa51a80fe Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Wed, 29 Apr 2026 11:46:38 -0700
Subject: [PATCH] eal: add helper to initialize process-shared mutex

[ upstream commit c718d23bb15d02db5baa620edd8fbdc2faee51a1 ]

Drivers and libraries that place a pthread_mutex_t in shared memory
to coordinate primary and secondary DPDK processes must initialize
the mutex with PTHREAD_PROCESS_SHARED, otherwise behaviour is
undefined. Add an internal helper so this is done in one place rather
than copied into every driver.

Errors from the attribute calls are ignored: on platforms that do not
support cross-process mutex sharing the mutex still works within a
single process.

Bugzilla ID: 662

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/eal/include/rte_thread.h | 15 +++++++++++++++
 lib/eal/unix/rte_thread.c    | 11 +++++++++++
 lib/eal/version.map          |  1 +
 lib/eal/windows/rte_thread.c |  9 +++++++++
 4 files changed, 36 insertions(+)

diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h
index 8da9d4d3fb..27d5b9c594 100644
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
@@ -3,6 +3,7 @@
  * Copyright (C) 2022 Microsoft Corporation
  */
 
+#include <pthread.h>
 #include <stdint.h>
 
 #include <rte_os.h>
@@ -463,6 +464,20 @@ int rte_thread_value_set(rte_thread_key key, const void *value);
  */
 void *rte_thread_value_get(rte_thread_key key);
 
+/**
+ * Initialize a pthread mutex for use in shared memory accessible by
+ * multiple DPDK processes.
+ *
+ * Sets PTHREAD_PROCESS_SHARED so the mutex can synchronize threads
+ * across DPDK primary and secondary processes when the mutex resides
+ * in shared memory (e.g. hugepage memory).
+ *
+ * @param mutex
+ *   The mutex to initialize.
+ */
+__rte_internal
+void rte_thread_mutex_init_shared(pthread_mutex_t *mutex);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/eal/unix/rte_thread.c b/lib/eal/unix/rte_thread.c
index ea629c2065..3b8ef8615a 100644
--- a/lib/eal/unix/rte_thread.c
+++ b/lib/eal/unix/rte_thread.c
@@ -405,3 +405,14 @@ rte_thread_get_affinity_by_id(rte_thread_t thread_id,
 	return pthread_getaffinity_np((pthread_t)thread_id.opaque_id,
 		sizeof(*cpuset), cpuset);
 }
+
+void
+rte_thread_mutex_init_shared(pthread_mutex_t *mutex)
+{
+	pthread_mutexattr_t attr;
+
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+	pthread_mutex_init(mutex, &attr);
+	pthread_mutexattr_destroy(&attr);
+}
diff --git a/lib/eal/version.map b/lib/eal/version.map
index e2a622c3e4..9bbd83ffdb 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -448,5 +448,6 @@ INTERNAL {
 	rte_mem_page_size;
 	rte_mem_unmap;
 	rte_thread_create_internal_control;
+	rte_thread_mutex_init_shared;
 	rte_thread_set_prefixed_name;
 };
diff --git a/lib/eal/windows/rte_thread.c b/lib/eal/windows/rte_thread.c
index 6f991dfa5d..a332f6b386 100644
--- a/lib/eal/windows/rte_thread.c
+++ b/lib/eal/windows/rte_thread.c
@@ -606,3 +606,12 @@ cleanup:
 	}
 	return ret;
 }
+
+/* Note: Windows does not have PTHREAD_PROCESS_SHARED
+ * and DPDK on Windows only supports single process model.
+ */
+void
+rte_thread_mutex_init_shared(pthread_mutex_t *mutex)
+{
+	pthread_mutex_init(mutex, NULL);
+}
-- 
2.47.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-06-11 14:20:02.189396796 +0100
+++ 0021-eal-add-helper-to-initialize-process-shared-mutex.patch	2026-06-11 14:20:01.186745302 +0100
@@ -1 +1 @@
-From c718d23bb15d02db5baa620edd8fbdc2faee51a1 Mon Sep 17 00:00:00 2001
+From 63d0fa6dc17614aa5fd3a4ac8bca69cfa51a80fe Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit c718d23bb15d02db5baa620edd8fbdc2faee51a1 ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -22,3 +23,4 @@
- lib/eal/unix/rte_thread.c    | 12 ++++++++++++
- lib/eal/windows/rte_thread.c | 10 ++++++++++
- 3 files changed, 37 insertions(+)
+ lib/eal/unix/rte_thread.c    | 11 +++++++++++
+ lib/eal/version.map          |  1 +
+ lib/eal/windows/rte_thread.c |  9 +++++++++
+ 4 files changed, 36 insertions(+)
@@ -60 +62 @@
-index 950c0848ba..f3a6bd2ad3 100644
+index ea629c2065..3b8ef8615a 100644
@@ -63 +65 @@
-@@ -419,3 +419,15 @@ rte_thread_get_affinity_by_id(rte_thread_t thread_id,
+@@ -405,3 +405,14 @@ rte_thread_get_affinity_by_id(rte_thread_t thread_id,
@@ -68 +69,0 @@
-+RTE_EXPORT_INTERNAL_SYMBOL(rte_thread_mutex_init_shared)
@@ -78,0 +80,11 @@
+diff --git a/lib/eal/version.map b/lib/eal/version.map
+index e2a622c3e4..9bbd83ffdb 100644
+--- a/lib/eal/version.map
++++ b/lib/eal/version.map
+@@ -448,5 +448,6 @@ INTERNAL {
+ 	rte_mem_page_size;
+ 	rte_mem_unmap;
+ 	rte_thread_create_internal_control;
++	rte_thread_mutex_init_shared;
+ 	rte_thread_set_prefixed_name;
+ };
@@ -80 +92 @@
-index 85e5a57346..19bb9ed61d 100644
+index 6f991dfa5d..a332f6b386 100644
@@ -83 +95 @@
-@@ -621,3 +621,13 @@ cleanup:
+@@ -606,3 +606,12 @@ cleanup:
@@ -91 +102,0 @@
-+RTE_EXPORT_INTERNAL_SYMBOL(rte_thread_mutex_init_shared)


More information about the stable mailing list