From: Geliang Tang <geliang@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>, Gang Yan <yangang@kylinos.cn>
Subject: Re: [RFC mptcp-next v11 05/15] mptcp: avoid sleeping in read_sock path under softirq
Date: Thu, 02 Apr 2026 16:08:47 +0800 [thread overview]
Message-ID: <10262ffce0d3bcb6159ba1e8da54ab8a9a650188.camel@kernel.org> (raw)
In-Reply-To: <7d09f88d-052c-4932-bb25-3831b32e0f94@redhat.com>
Hi Paolo,
Thanks for you help, I finally solved this deadlock issue as you
suggested.
On Wed, 2026-04-01 at 21:57 +0200, Paolo Abeni wrote:
> On 3/19/26 11:08 AM, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> >
> > When mptcp_read_sock() is called from softirq context via TLS
> > read_sock, lock_sock_fast() in mptcp_rcv_space_adjust() and
> > mptcp_cleanup_rbuf() may trigger might_sleep() warnings or
> > illegal sleeps, as softirq context cannot block.
> >
> > Replace lock_sock_fast() with spin_trylock_bh() to make locking
> > non-blocking and context-safe. Skip operations if the lock cannot
> > be acquired.
> >
> > Co-developed-by: Gang Yan <yangang@kylinos.cn>
> > Signed-off-by: Gang Yan <yangang@kylinos.cn>
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> > net/mptcp/protocol.c | 18 +++++++++---------
> > 1 file changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > index 5585f43cf879..e9e40dfab5ea 100644
> > --- a/net/mptcp/protocol.c
> > +++ b/net/mptcp/protocol.c
> > @@ -561,12 +561,11 @@ static void mptcp_send_ack(struct mptcp_sock
> > *msk)
> >
> > static void mptcp_subflow_cleanup_rbuf(struct sock *ssk, int
> > copied)
> > {
> > - bool slow;
> > -
> > - slow = lock_sock_fast(ssk);
> > - if (tcp_can_send_ack(ssk))
> > + if (!spin_trylock_bh(&ssk->sk_lock.slock))
> > + return;
>
> I discussed this topic off-list with Geliang. Let me report the info
> here, too, for future memory.
>
> This does not look like the correct solution: we risk not sending out
> the needed ack.
>
> The exact, complete and decoded call trace leading to the problematic
> lock could be helpful.
>
> I *guess* a better solution would be detecting the critical scenario
> from the mptcp/tls caller and in such a case queue the strp->work and
That's indeed the problem here.
/* Lower sock lock held */
void tls_strp_data_ready(struct tls_strparser *strp)
{
struct tls_context *ctx = tls_get_ctx(strp->sk);
/* This check is needed to synchronize with do_tls_strp_work.
* do_tls_strp_work acquires a process lock (lock_sock) whereas
* the lock held here is bh_lock_sock. The two locks can be
* held by different threads at the same time, but bh_lock_sock
* allows a thread in BH context to safely check if the process
* lock is held. In this case, if the lock is held, queue work.
*/
if (sock_owned_by_user_nocheck(strp->sk)) {
queue_work(tls_strp_wq, &strp->work);
return;
}
tls_strp_check_rcv(strp);
}
MPTCP should not only checks sock_owned_by_user_nocheck(sk) as TCP
does, but also needs to check whether the MPTCP data lock is held.
So I added a new .lock_is_held interface for struct tls_prot_ops in
v12. Also dropped this patch in v12.
Thanks,
-Geliang
> do
> not call into the tcp/mptcp code. The later strp worker invocation
> will
> happen from process context and could acquire the subflow lock
> without
> locking issues.
>
> /P
next prev parent reply other threads:[~2026-04-02 8:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 10:08 [RFC mptcp-next v11 00/15] MPTCP KTLS support Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 01/15] tls: introduce struct tls_prot_ops for protocol ops Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 02/15] tls: add tls_prot_ops pointer to tls_context Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 03/15] tls: add MPTCP SKB offset check in strp queue walk Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 04/15] mptcp: update mptcp_check_readable for TLS use Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 05/15] mptcp: avoid sleeping in read_sock path under softirq Geliang Tang
2026-04-01 19:57 ` Paolo Abeni
2026-04-02 8:08 ` Geliang Tang [this message]
2026-03-19 10:08 ` [RFC mptcp-next v11 06/15] mptcp: implement tls_mptcp_ops for MPTCP TLS Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 07/15] tls: disable device offload for MPTCP sockets Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 08/15] mptcp: update ULP getsockopt for TLS support Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 09/15] mptcp: enable ULP setsockopt " Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 10/15] selftests: mptcp: connect: use espintcp for ULP test Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 11/15] selftests: tls: add mptcp variant for testing Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 12/15] selftests: tls: increase nonblocking data size for MPTCP Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 13/15] selftests: tls: wait TCP_CLOSE in shutdown_reuse " Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 14/15] selftests: tls: add MPTCP test cases Geliang Tang
2026-03-19 10:08 ` [RFC mptcp-next v11 15/15] selftests: mptcp: cover mptcp tls tests Geliang Tang
2026-03-19 12:27 ` [RFC mptcp-next v11 00/15] MPTCP KTLS support 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=10262ffce0d3bcb6159ba1e8da54ab8a9a650188.camel@kernel.org \
--to=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=tanggeliang@kylinos.cn \
--cc=yangang@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