MPTCP Linux Development
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Mat Martineau <mathew.j.martineau@linux.intel.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net] mptcp: fix lockdep false positive
Date: Mon, 12 Dec 2022 13:06:46 +0100	[thread overview]
Message-ID: <f84cb49cee8ac2f51f15123e7ffb80da1a055ce7.camel@redhat.com> (raw)
In-Reply-To: <194f648f-4813-a0ef-2c28-dd46acc3c4eb@linux.intel.com>

Hello,

Sorry for the extra latency
On Wed, 2022-12-07 at 17:50 -0800, Mat Martineau wrote:
> > @@ -1813,8 +1813,18 @@ void mptcp_subflow_queue_clean(struct sock *listener_ssk)
> > 
> > 		do_cancel_work = __mptcp_close(sk, 0);
> > 		release_sock(sk);
> > -		if (do_cancel_work)
> > +		if (do_cancel_work) {
> > +			/* lockdep will report a false positive ABBA deadlock between
> > +			 * cancel_work_sync and the listener socket. The involved locks
> > +			 * belong to differen sockets WRT the existing AB chain.
> 
> s/differen/different/
> 
> > +			 * Using a per socket key would be very invasive and heavy, just
> > +			 * tell lockdep to consider the listener socket released here
> > +			 */
> > +			mutex_release(&listener_sk->sk_lock.dep_map, _RET_IP_);
> > 			mptcp_cancel_work(sk);
> > +			mutex_acquire(&listener_sk->sk_lock.dep_map,
> > +				      SINGLE_DEPTH_NESTING, 0, _RET_IP_);
> 
> Any concerns about this change breaking lockdep if the existing 
> assumptions about listener sockets no longer apply? For example, if 
> someone made the unfortunate choice to start using mptcp_worker() with a 
> MPTCP listener sock?

I'm not sure I read the above correctly. This change does not bring
extra assumption about listener sockets. Starting the worker on the
listener socket will not impact the above annotation: the listener
socker will try to catch/shutdown/cancel the releated worker in the
related mptcp_close() call.

I'm unsure I explained the current problem in a clear way.

Here we have 2 msk sockets ('listener_sk' and 'sk'). The above code is
invoked under the listener sk socket lock.  

Lockdep see:

workqueue(sk) waits for lock(sk)

lock(listener_sk) waits for workqueue(sk)

and barks loudly since listener_sk and sk have the same 'key' - are
basically the same thing from lockdep perspective. A 'cleaner' fix
would be setting different lockdep key either on the mptcp workqueue or
on the socket. I refrained from that since it would be quite more
invasive (dynamic lockdep key allocation /cleanup).

Let me check if it is as painful as I thought...

thanks,

Paolo


  reply	other threads:[~2022-12-12 12:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 17:52 [PATCH mptcp-net] mptcp: fix lockdep false positive Paolo Abeni
2022-12-07 20:55 ` mptcp: fix lockdep false positive: Tests Results MPTCP CI
2022-12-08  1:50 ` [PATCH mptcp-net] mptcp: fix lockdep false positive Mat Martineau
2022-12-12 12:06   ` Paolo Abeni [this message]
2022-12-12 14:56     ` Paolo Abeni

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=f84cb49cee8ac2f51f15123e7ffb80da1a055ce7.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=mptcp@lists.linux.dev \
    /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