Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Arun Sharma <asharma@fb.com>
Cc: Maximilian Engelhardt <maxi@daemonizer.de>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	StuStaNet Vorstand <vorstand@stusta.mhn.de>
Subject: Re: Kernel crash after using new Intel NIC (igb)
Date: Thu, 26 May 2011 21:47:26 +0200	[thread overview]
Message-ID: <1306439246.2543.10.camel@edumazet-laptop> (raw)
In-Reply-To: <4DDEAA3C.7020502@fb.com>

Le jeudi 26 mai 2011 à 12:30 -0700, Arun Sharma a écrit :
> On 5/24/11 11:35 PM, Eric Dumazet wrote:
> 
> >> Another possibility is to do the list_empty() check twice. Once without
> >> taking the lock and again with the spinlock held.
> >>
> >
> > Why ?
> >
> 
> Part of the problem is that I don't have a precise understanding of the 
> race condition that's causing the list to become corrupted.
> 
> All I know is that doing it under the lock fixes it. If it's slowing 
> things down, we do a check outside the lock (since it's cheap). But if 
> we get the wrong answer, we verify it again under the lock.
> 

You dont get the problem. Problem is : We can do the empty() test only
if protected by the lock.

If not locked, result can be wrong. [ false positive or negative ]


> > list_del_init(&p->unused); (done under lock of course) is safe, you can
> > call it twice, no problem.
> 
> Doing it twice is not a problem. But doing it when we shouldn't be doing 
> it could be the problem.
> 
> The list modification under unused_peers.lock looks generally safe. But 
> the control flow (based on refcnt) done outside the lock might have races.
> 

"might" is not a good word when dealing with this ;)

> Eg: inet_putpeer() might find the refcnt go to zero, but before it adds 
> it to the unused list, another thread may be doing inet_getpeer() and 
> set refcnt to 1. In the end, we end up with a node that's potentially in 
> use, but ends up on the unused list.
> 

Did you test my fix ?

Its doing the right thing : Using refcnt as the only marker to say if
the item must be removed from unused list (and lock the central lock
protecting this list only when needed)

Since we already must do an atomic operation on refcnt, using
atomic_inc_return [ or similar full barrier op ] is enough to tell us
the truth.

  reply	other threads:[~2011-05-26 19:47 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-24 22:32 Kernel crash after using new Intel NIC (igb) Maximilian Engelhardt
2011-04-26 23:34 ` Wyborny, Carolyn
2011-04-27 11:46   ` Maximilian Engelhardt
2011-04-27 12:04     ` Eric Dumazet
2011-04-27  4:24 ` Eric Dumazet
2011-04-27  4:32   ` Eric Dumazet
2011-04-27 11:51     ` Maximilian Engelhardt
2011-05-12 21:10       ` Arun Sharma
2011-05-12 21:15         ` Eric Dumazet
2011-05-24 21:33           ` Arun Sharma
2011-05-25  2:44             ` Eric Dumazet
2011-05-25  6:06               ` Arun Sharma
2011-05-25  6:35                 ` Eric Dumazet
2011-05-26 15:06                   ` Ben Hutchings
2011-05-26 19:30                   ` Arun Sharma
2011-05-26 19:47                     ` Eric Dumazet [this message]
2011-05-26 21:48                       ` Arun Sharma
2011-05-26 22:01                         ` Eric Dumazet
2011-05-27  0:09                           ` Arun Sharma
2011-05-27  3:27                             ` Eric Dumazet
2011-05-27  7:56                               ` Yann Dupont
2011-05-27 17:40                               ` David Miller
2011-05-27 17:52                               ` Arun Sharma
2011-05-27 19:56                                 ` Eric Dumazet
2011-05-27 21:14                                   ` Arun Sharma
2011-05-28  5:41                                     ` Eric Dumazet
2011-05-28 18:04                                       ` Ingo Molnar
2011-05-29  7:33                                         ` Eric Dumazet
2011-05-29  7:38                                           ` Ingo Molnar
2011-05-29  7:43                                             ` Eric Dumazet
2011-05-29 12:33                                               ` Ingo Molnar
2011-05-30 18:34                                                 ` Arun Sharma
2011-05-31 10:50                                                   ` Ingo Molnar
2011-07-13 13:38                               ` Maximilian Engelhardt

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=1306439246.2543.10.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=asharma@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxi@daemonizer.de \
    --cc=netdev@vger.kernel.org \
    --cc=vorstand@stusta.mhn.de \
    /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