public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: jarkao2@gmail.com, penguin-kernel@I-love.SAKURA.ne.jp,
	linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] net: fix a lockdep splat
Date: Thu, 23 Sep 2010 07:05:00 +0200	[thread overview]
Message-ID: <1285218300.2380.68.camel@edumazet-laptop> (raw)
In-Reply-To: <20100922.212332.45886457.davem@davemloft.net>

Le mercredi 22 septembre 2010 à 21:23 -0700, David Miller a écrit :
> From: David Miller <davem@davemloft.net>
> Date: Wed, 22 Sep 2010 20:53:24 -0700 (PDT)
> 
> > From: Eric Dumazet <eric.dumazet@gmail.com>
> > Date: Thu, 23 Sep 2010 00:43:39 +0200
> > 
> >> (A) (this is used in net/sunrpc/xprtsock.c)
> >> read_lock(&sk->sk_callback_lock) (without blocking BH)
> >> <BH>
> >> spin_lock(&sk->sk_slock.slock);
> >> ...
> >> read_lock(&sk->sk_callback_lock);
> >> ...
> > 
> > What's the exact path that leads to this?  I looked quickly and couldn't
> > find which sunrpc callback override does it.
> 
> Sorry, I'm being unusually dense at the moment, ignore this question :-)

No problem ;)

But we might answer it anyway for other readers :

vi +1417 net/sunrpc/xprtsock.c

static void xs_udp_write_space(struct sock *sk)
{
        read_lock(&sk->sk_callback_lock);

// We can be interrupted here and call INPUT_PATH()

        /* from net/core/sock.c:sock_def_write_space */
        if (sock_writeable(sk))
                xs_write_space(sk);

        read_unlock(&sk->sk_callback_lock);
}

INPUT_PATH()
{
	spin_lock(&sk->slock);
	queue skb to receive queue or backlog
	spin_unlock(&sk->slock);
}


If another cpu does (C), we can deadlock.

C)
spin_lock_bh(&sk->sk_slock)
...
write_lock_bh(&sk->sk_callback_lock)
...

Then we can have a deadlock with (A)

CPU1 [A]                                CPU2 [C]
read_lock(&sk->sk_callback_lock)
<BH>                                    spin_lock_bh(&sk->sk_slock)
<wait to spin_lock(slock)>
                                        <wait to write_lock_bh(callback_lock)>


It seems only TCP stack contains [C] cases, in very unlikely paths, but still...

Since all AF_INET sockets share the same af_callback_key 
*and* the same af_family_slock_keys, lockdep warned Tetsuo because
 it detects an UDP [A] case and a TCP [C] case.




  reply	other threads:[~2010-09-23  5:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-24 11:53 [2.6.35-rc3] NFS: possible irq lock inversion dependency Tetsuo Handa
2010-09-07 12:32 ` [2.6.36-rc3] " Tetsuo Handa
2010-09-21  6:51   ` [2.6.35-rc5] INET?: " Tetsuo Handa
2010-09-21  7:56     ` Eric Dumazet
2010-09-21  9:10       ` [2.6.36-rc5] " Tetsuo Handa
2010-09-21  9:35         ` Eric Dumazet
2010-09-21 10:13           ` Eric Dumazet
2010-09-22  7:14             ` Tetsuo Handa
2010-09-22  8:31               ` Eric Dumazet
2010-09-22  8:34                 ` Eric Dumazet
2010-09-22  8:38                   ` Eric Dumazet
2010-09-22  8:58                     ` Tetsuo Handa
2010-09-22 17:35                       ` Eric Dumazet
2010-09-22 19:34                         ` [PATCH] net: fix a lockdep splat Eric Dumazet
2010-09-22 20:33                           ` David Miller
2010-09-22 22:13                           ` Jarek Poplawski
2010-09-22 22:43                             ` Eric Dumazet
2010-09-23  3:53                               ` David Miller
2010-09-23  4:23                                 ` David Miller
2010-09-23  5:05                                   ` Eric Dumazet [this message]
2010-09-23  5:42                               ` Eric Dumazet
2010-09-23  6:32                               ` Tetsuo Handa
2010-09-23  6:44                                 ` Eric Dumazet
2010-09-25  5:26                                 ` David Miller

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=1285218300.2380.68.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jarkao2@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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