netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: herbert@gondor.apana.org.au
Cc: dlstevens@us.ibm.com, greearb@candelatech.com, jarkao2@o2.pl,
	netdev@vger.kernel.org
Subject: Re: BUG: soft lockup detected on CPU#0! (2.6.18.2 plus hacks)
Date: Thu, 04 Jan 2007 12:33:33 -0800 (PST)	[thread overview]
Message-ID: <20070104.123333.91315611.davem@davemloft.net> (raw)
In-Reply-To: <E1H2M3X-0001HE-00@gondolin.me.apana.org.au>

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 04 Jan 2007 17:26:27 +1100

> David Stevens <dlstevens@us.ibm.com> wrote:
> >        You're right, I don't know whether it'll fix the problem Ben saw
> > or not, but it looks like the original code can do a receive before the
> > in_device is fully initialized, and that, of course, is bad.
> >        If the device for ip_rcv() is not the same one we were
> > initializing when the receive interrupted, then the patch should have
> > no effect either way -- I don't think it'll hide other problems.
> >        If it's hard to reproduce (which I guess is true), then you're
> > right, no soft lockup doesn't really tell us if it's fixed or not.
> 
> Actually I missed your point that the multicast locks aren't even
> initialised at that point.  So this does explain the soft lock-up
> and therefore your patch is clearly the correct solution.

I agree too, therefore I've added David's patch as below.

I'll push this to the -stable branches as well.  This fix is
correct even if it does not entirely clear up the soft lockup
bug being discussed in this thread, but I think it will :-)

commit 30c4cf577fb5b68c16e5750d6bdbd7072e42b279
Author: David L Stevens <dlstevens@us.ibm.com>
Date:   Thu Jan 4 12:31:14 2007 -0800

    [IPV4/IPV6]: Fix inet{,6} device initialization order.
    
    It is important that we only assign dev->ip{,6}_ptr
    only after all portions of the inet{,6} are setup.
    
    Otherwise we can receive packets before the multicast
    spinlocks et al. are initialized.
    
    Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 84bed40..25c8a42 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -165,9 +165,8 @@ struct in_device *inetdev_init(struct net_device *dev)
 			      NET_IPV4_NEIGH, "ipv4", NULL, NULL);
 #endif
 
-	/* Account for reference dev->ip_ptr */
+	/* Account for reference dev->ip_ptr (below) */
 	in_dev_hold(in_dev);
-	rcu_assign_pointer(dev->ip_ptr, in_dev);
 
 #ifdef CONFIG_SYSCTL
 	devinet_sysctl_register(in_dev, &in_dev->cnf);
@@ -176,6 +175,8 @@ struct in_device *inetdev_init(struct net_device *dev)
 	if (dev->flags & IFF_UP)
 		ip_mc_up(in_dev);
 out:
+	/* we can receive as soon as ip_ptr is set -- do this last */
+	rcu_assign_pointer(dev->ip_ptr, in_dev);
 	return in_dev;
 out_kfree:
 	kfree(in_dev);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9b0a906..171e5b5 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -413,8 +413,6 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 	if (netif_carrier_ok(dev))
 		ndev->if_flags |= IF_READY;
 
-	/* protected by rtnl_lock */
-	rcu_assign_pointer(dev->ip6_ptr, ndev);
 
 	ipv6_mc_init_dev(ndev);
 	ndev->tstamp = jiffies;
@@ -425,6 +423,8 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 			      NULL);
 	addrconf_sysctl_register(ndev, &ndev->cnf);
 #endif
+	/* protected by rtnl_lock */
+	rcu_assign_pointer(dev->ip6_ptr, ndev);
 	return ndev;
 }
 

  parent reply	other threads:[~2007-01-04 20:33 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20  2:13 BUG: soft lockup detected on CPU#0! (2.6.18.2 plus hacks) Ben Greear
2006-12-22  7:13 ` [PATCH] igmp: spin_lock_bh in timer (Re: BUG: soft lockup detected on CPU#0!) Jarek Poplawski
2006-12-22  7:42   ` Jarek Poplawski
2006-12-22 13:47     ` Ben Greear
2006-12-22 14:05     ` Ben Greear
2006-12-27  8:24       ` Jarek Poplawski
2006-12-27 16:16         ` Ben Greear
2006-12-28 12:56           ` Jarek Poplawski
2006-12-29 11:16           ` Jarek Poplawski
2006-12-22  9:48   ` Jarek Poplawski
2006-12-22 11:16   ` Herbert Xu
2006-12-22 12:53     ` Jarek Poplawski
2007-01-02  5:00 ` BUG: soft lockup detected on CPU#0! (2.6.18.2 plus hacks) Ben Greear
2007-01-02  7:39   ` Jarek Poplawski
2007-01-02  8:23     ` Jarek Poplawski
2007-01-02  9:23       ` Jarek Poplawski
2007-01-02 23:35   ` David Stevens
2007-01-02 23:43     ` Ben Greear
2007-01-03  8:07     ` Jarek Poplawski
2007-01-03  8:28       ` Jarek Poplawski
2007-01-03 16:53         ` Ben Greear
2007-01-03 22:14   ` David Stevens
2007-01-03 23:13     ` David Stevens
2007-01-03 23:35       ` Ben Greear
2007-01-03 23:56         ` David Stevens
2007-01-04  0:30       ` Herbert Xu
2007-01-04  1:02         ` Ben Greear
2007-01-04  1:14           ` Herbert Xu
2007-01-04  5:41           ` David Stevens
2007-01-04  5:34         ` David Stevens
2007-01-04  6:26           ` Herbert Xu
2007-01-04  8:03             ` Jarek Poplawski
2007-01-04  8:29               ` Herbert Xu
2007-01-04  8:50                 ` Jarek Poplawski
2007-01-04 10:27                   ` Herbert Xu
2007-01-04 11:04                     ` Jarek Poplawski
2007-01-04 17:04                       ` Ben Greear
2007-01-05 13:55                         ` Jarek Poplawski
2007-01-04 20:33             ` David Miller [this message]
2007-01-05  6:38               ` Jarek Poplawski
2007-01-05  9:38                 ` Herbert Xu
2007-01-05 11:19                   ` [PATCH] devinet: inetdev_init out label moved after RCU assignment Jarek Poplawski
2007-01-05 11:23                     ` Herbert Xu
2007-01-05 11:37                       ` Jarek Poplawski
2007-01-09 22:38                       ` David Miller
2007-01-05 19:52                     ` David Stevens
2007-01-05 20:33               ` BUG: soft lockup detected on CPU#0! (2.6.18.2 plus hacks) Ben Greear
2007-01-05 20:34                 ` David Miller
2007-01-08  6:53                 ` Jarek Poplawski
2007-01-08 16:57                   ` Ben Greear
2007-01-08 18:03                     ` Stephen Hemminger
2007-01-09  8:10                       ` Jarek Poplawski
2007-01-10  9:04                         ` Jarek Poplawski
2007-01-10 12:50                           ` Jarek Poplawski
2007-01-10 20:01                             ` Stephen Hemminger
2007-01-11  7:24                               ` Jarek Poplawski
2007-01-11  7:40                                 ` David Miller
2007-01-11  8:29                                   ` Jarek Poplawski
2007-01-11  8:35                                     ` Jarek Poplawski
2007-01-11  8:39                                       ` Jarek Poplawski
2007-01-11  9:27                                         ` David Miller
2007-01-11 11:09                                           ` Jarek Poplawski
2007-01-11 17:42                                             ` RCU info Stephen Hemminger
2007-01-12 12:19                                               ` Jarek Poplawski

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=20070104.123333.91315611.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dlstevens@us.ibm.com \
    --cc=greearb@candelatech.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jarkao2@o2.pl \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).