From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Ziyang Xuan <xuanziyang2@huawei.com>,
Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>
Subject: [RFC 6/6] net/hinic: fix mutexes for multi-process
Date: Thu, 29 Jan 2026 21:17:37 -0800 [thread overview]
Message-ID: <20260130052142.251649-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20260130052142.251649-1-stephen@networkplumber.org>
The hinic driver supports secondary processes, as shown by the
explicit check in hinic_dev_init(). Multiple mutexes are located
in structures allocated in shared memory (dev_private and
rte_zmalloc'd structures) that are accessible by both primary
and secondary processes.
However, the mutexes are initialized without PTHREAD_PROCESS_SHARED
attribute, which means synchronization between processes is
undefined behavior.
POSIX mutexes are by default private to the process creating them.
When a mutex protects data structures in shared memory that are
accessed by multiple processes, pthread_mutexattr_setpshared() must
be called with PTHREAD_PROCESS_SHARED.
Fix the hinic_mutex_init() wrapper function to set the
PTHREAD_PROCESS_SHARED attribute on all mutexes.
Bugzilla ID: 662
Fixes: ae865766b334 ("net/hinic: replace spinlock with mutex")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/hinic/base/hinic_compat.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h
index d3994c50e9..18148a119e 100644
--- a/drivers/net/hinic/base/hinic_compat.h
+++ b/drivers/net/hinic/base/hinic_compat.h
@@ -197,10 +197,21 @@ static inline u16 ilog2(u32 n)
return res;
}
+/*
+ * Initialize mutex for process-shared access.
+ * Structures may be in shared memory accessible by multiple processes,
+ * so mutexes must use PTHREAD_PROCESS_SHARED.
+ */
static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
const pthread_mutexattr_t *mattr)
{
- return pthread_mutex_init(pthreadmutex, mattr);
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ pthread_mutex_init(pthreadmutex, mattr ? mattr : &attr);
+ pthread_mutexattr_destroy(&attr);
+ return 0;
}
static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
--
2.51.0
prev parent reply other threads:[~2026-01-30 5:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 5:17 [RFC 0/6] Fix pthread mutexes for multi-process support Stephen Hemminger
2026-01-30 5:17 ` [RFC 1/6] ethdev: fix flow_ops_mutex for multi-process Stephen Hemminger
2026-01-30 5:17 ` [RFC 2/6] net/failsafe: fix hotplug_mutex " Stephen Hemminger
2026-01-30 5:17 ` [RFC 3/6] net/atlantic: fix mbox_mutex " Stephen Hemminger
2026-01-30 5:17 ` [RFC 4/6] net/axgbe: fix mutexes " Stephen Hemminger
2026-01-30 5:17 ` [RFC 5/6] net/bnxt: " Stephen Hemminger
2026-01-30 5:17 ` Stephen Hemminger [this message]
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=20260130052142.251649-7-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=cloud.wangxiaoyun@huawei.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=xuanziyang2@huawei.com \
/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