From: Geliang Tang <geliang@kernel.org>
To: mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: [PATCH mptcp-next v4 0/3] add distinct lockdep class for MPTCP sockets
Date: Tue, 20 Oct 2026 12:34:42 +0800 [thread overview]
Message-ID: <cover.1792470313.git.tanggeliang@kylinos.cn> (raw)
From: Geliang Tang <tanggeliang@kylinos.cn>
The mptcp_nvme.sh selftest reports lockdep "possible recursive locking"
warnings when running NVMe over MPTCP. The issue occurs because MPTCP
sockets and their subflows share the same k-sk_lock-AF_INET lockdep class,
causing lockdep to flag false warnings in paths that hold the MPTCP socket
lock and then lock a subflow (setsockopt, connect, bind, worker send-ack).
This series fixes the issue by giving MPTCP sockets their own distinct
lockdep class (sk_lock-AF_INET-MPTCP for IPv4, sk_lock-AF_INET6-MPTCP for
IPv6), similar to how nvme-tcp handles it. This approach is more efficient
than reclassifying each subflow individually, properly supports IPv6, and
follows existing kernel patterns.
A KUnit test is included to verify the fix works correctly.
v4:
- Include existing patch to propagate sk_reuse and sk_reuseport settings
from MPTCP socket to subflows, and fix unconditional sk_bound_dev_if
override in __mptcp_subflow_connect()
- Enhanced KUnit test to cover SO_BINDTODEVICE and SO_BINDTOIFINDEX
socket options in addition to SO_REUSEADDR
- Refactored sockopt test into helper functions (mptcp_test_reuseaddr,
mptcp_test_bindtodevice, mptcp_test_bindtoifindex) for better
maintainability
- Added proper socket cleanup using kunit_add_action_or_reset() to
prevent resource leaks on test failures
- Added READ_ONCE annotation for lockless access to msk->first
- Added period to Kconfig help text
v3:
- Assign separate lock classes for kernel and user MPTCP sockets to
prevent lockdep from conflating their usage patterns (kernel sockets
may nest with fs/storage locks, user sockets record mmap_lock
dependencies through page faults)
- Call mptcp_reclassify_socket() from mptcp_init_sock() for active sockets
and from mptcp_sk_clone_init() before bh_lock_sock() for passive sockets
- Remove duplicate lock reclassification from pm_kernel.c (PM listener
sockets are now reclassified through mptcp_init_sock() path)
- Enhanced KUnit test to cover both IPv4/IPv6 and active/passive sockets,
with direct lockdep key comparison when CONFIG_PROVE_LOCKING is enabled
- Update Kconfig help text to mention sockopt tests
- https://patchwork.kernel.org/project/mptcp/cover/cover.1792378794.git.tanggeliang@kylinos.cn/
v2:
- Move reclassification to __mptcp_init_sock() to cover cloned sockets,
as Matt suggested
- Extract mptcp_reclassify_socket() helper for reuse in PM listener socket
creation
- Remove #ifdef CONFIG_DEBUG_LOCK_ALLOC wrapper as suggested by Matt
- Update lock class names to msk_lock-AF_INET/msk_lock-AF_INET6
- Note: checkpatch.pl warns about line length > 80 columns in pm_kernel.c,
but kept for consistency with existing code style
- https://patchwork.kernel.org/project/mptcp/cover/cover.1792114102.git.tanggeliang@kylinos.cn/
v1:
- https://patchwork.kernel.org/project/mptcp/cover/cover.1792060837.git.tanggeliang@kylinos.cn/
Geliang Tang (3):
mptcp: give MPTCP sockets a distinct lockdep class
mptcp: inherit sk_reuse and fix dev bind override
mptcp: kunit: add sockopt test
net/mptcp/Kconfig | 2 +-
net/mptcp/Makefile | 4 +-
net/mptcp/pm_kernel.c | 16 ----
net/mptcp/protocol.c | 37 +++++++-
net/mptcp/sockopt.c | 5 ++
net/mptcp/sockopt_test.c | 184 +++++++++++++++++++++++++++++++++++++++
net/mptcp/subflow.c | 4 +-
7 files changed, 232 insertions(+), 20 deletions(-)
create mode 100644 net/mptcp/sockopt_test.c
--
2.55.0
next reply other threads:[~2026-10-20 4:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 4:34 Geliang Tang [this message]
2026-10-20 4:34 ` [PATCH mptcp-next v4 1/3] mptcp: give MPTCP sockets a distinct lockdep class Geliang Tang
2026-10-20 4:34 ` [PATCH mptcp-next v4 2/3] mptcp: inherit sk_reuse and fix dev bind override Geliang Tang
2026-10-20 8:44 ` sashiko-bot
2026-10-20 4:34 ` [PATCH mptcp-next v4 3/3] mptcp: kunit: add sockopt test Geliang Tang
2026-10-20 8:55 ` sashiko-bot
2026-10-21 13:26 ` [PATCH mptcp-next v4 0/3] add distinct lockdep class for MPTCP sockets MPTCP CI
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=cover.1792470313.git.tanggeliang@kylinos.cn \
--to=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=tanggeliang@kylinos.cn \
/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