From: "David S. Miller" <davem@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: shemminger@osdl.org, netdev@oss.sgi.com
Subject: Re: [PATCH] Move inetdev/ifa over to RCU
Date: Sun, 15 Aug 2004 23:21:53 -0700 [thread overview]
Message-ID: <20040815232153.54e95346.davem@redhat.com> (raw)
In-Reply-To: <20040816030826.GA8341@gondor.apana.org.au>
On Mon, 16 Aug 2004 13:08:26 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> So we should reverse the two statements and add an smp_wmb().
I totally agree, and let's kill the lock too since it is
in fact useless now. I've done this as follows:
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/08/15 23:08:21-07:00 davem@nuts.davemloft.net
# [IPV4]: Kill inetdev_lock, no longer needed.
#
# It no longer protects anything, all users held RTNL
# semaphore to boot. Also, fix a potential race in the
# new RCU inetdev code, grab the reference on the idev
# before attaching it via dev->ip_ptr.
#
# Based upon discussions with Herbert Xu.
#
# Signed-off-by: David S. Miller <davem@redhat.com>
#
# net/ipv4/devinet.c
# 2004/08/15 23:07:17-07:00 davem@nuts.davemloft.net +6 -14
# [IPV4]: Kill inetdev_lock, no longer needed.
#
diff -Nru a/net/ipv4/devinet.c b/net/ipv4/devinet.c
--- a/net/ipv4/devinet.c 2004-08-15 23:08:59 -07:00
+++ b/net/ipv4/devinet.c 2004-08-15 23:08:59 -07:00
@@ -90,8 +90,6 @@
/* Locks all the inet devices. */
-static spinlock_t inetdev_lock = SPIN_LOCK_UNLOCKED;
-
static struct in_ifaddr *inet_alloc_ifa(void)
{
struct in_ifaddr *ifa = kmalloc(sizeof(*ifa), GFP_KERNEL);
@@ -158,11 +156,12 @@
neigh_sysctl_register(dev, in_dev->arp_parms, NET_IPV4,
NET_IPV4_NEIGH, "ipv4", NULL);
#endif
- spin_lock_bh(&inetdev_lock);
- dev->ip_ptr = in_dev;
+
/* Account for reference dev->ip_ptr */
in_dev_hold(in_dev);
- spin_unlock_bh(&inetdev_lock);
+ smp_wmb();
+ dev->ip_ptr = in_dev;
+
#ifdef CONFIG_SYSCTL
devinet_sysctl_register(in_dev, &in_dev->cnf);
#endif
@@ -201,10 +200,8 @@
#ifdef CONFIG_SYSCTL
devinet_sysctl_unregister(&in_dev->cnf);
#endif
- spin_lock_bh(&inetdev_lock);
+
in_dev->dev->ip_ptr = NULL;
- /* in_dev_put following below will kill the in_device */
- spin_unlock_bh(&inetdev_lock);
#ifdef CONFIG_SYSCTL
neigh_sysctl_unregister(in_dev->arp_parms);
@@ -248,9 +245,8 @@
ifap1 = &ifa->ifa_next;
continue;
}
- spin_lock_bh(&inetdev_lock);
+
*ifap1 = ifa->ifa_next;
- spin_unlock_bh(&inetdev_lock);
rtmsg_ifa(RTM_DELADDR, ifa);
notifier_call_chain(&inetaddr_chain, NETDEV_DOWN, ifa);
@@ -260,9 +256,7 @@
/* 2. Unlink it */
- spin_lock_bh(&inetdev_lock);
*ifap = ifa1->ifa_next;
- spin_unlock_bh(&inetdev_lock);
/* 3. Announce address deletion */
@@ -324,9 +318,7 @@
}
ifa->ifa_next = *ifap;
- spin_lock_bh(&inetdev_lock);
*ifap = ifa;
- spin_unlock_bh(&inetdev_lock);
/* Send message first, then call notifier.
Notifier will trigger FIB update, so that
next prev parent reply other threads:[~2004-08-16 6:21 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-12 23:59 [PATCH] Move inetdev/ifa over to RCU David S. Miller
2004-08-13 2:20 ` James Morris
2004-08-13 10:02 ` Herbert Xu
2004-08-13 16:03 ` Stephen Hemminger
2004-08-13 16:38 ` David S. Miller
2004-08-13 21:56 ` Herbert Xu
2004-08-13 22:19 ` David S. Miller
2004-08-14 0:34 ` Herbert Xu
2004-08-14 0:39 ` David S. Miller
2004-08-14 0:54 ` Herbert Xu
2004-08-14 1:25 ` Herbert Xu
2004-08-14 1:30 ` Herbert Xu
2004-08-14 5:08 ` Herbert Xu
2004-08-14 6:27 ` neigh_create/inetdev_destroy race? Herbert Xu
2004-08-16 2:14 ` David S. Miller
2004-08-16 10:51 ` Herbert Xu
2004-08-29 6:42 ` David S. Miller
2004-08-29 6:50 ` Herbert Xu
2004-08-31 6:08 ` David S. Miller
2004-08-31 10:41 ` Herbert Xu
2004-09-02 5:21 ` David S. Miller
2004-09-02 13:06 ` Herbert Xu
2004-09-03 13:36 ` Herbert Xu
2004-09-03 16:00 ` Stephen Hemminger
2004-09-03 23:49 ` Herbert Xu
2004-09-07 20:50 ` David S. Miller
2004-09-03 16:18 ` David S. Miller
2004-08-16 2:08 ` [PATCH] Move inetdev/ifa over to RCU David S. Miller
2004-08-16 2:43 ` Herbert Xu
2004-08-16 3:08 ` David S. Miller
2004-08-16 3:14 ` Herbert Xu
2004-08-16 6:23 ` David S. Miller
2004-08-14 6:31 ` Herbert Xu
2004-08-14 6:32 ` Herbert Xu
2004-08-16 3:01 ` David S. Miller
2004-08-14 1:40 ` Herbert Xu
2004-08-16 3:03 ` David S. Miller
2004-08-16 3:23 ` Herbert Xu
2004-08-16 6:24 ` David S. Miller
2004-08-14 4:30 ` Stephen Hemminger
2004-08-14 4:36 ` Herbert Xu
2004-08-16 2:59 ` David S. Miller
2004-08-16 2:58 ` David S. Miller
2004-08-16 3:08 ` Herbert Xu
2004-08-16 6:21 ` David S. Miller [this message]
2004-08-16 8:13 ` Herbert Xu
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=20040815232153.54e95346.davem@redhat.com \
--to=davem@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@oss.sgi.com \
--cc=shemminger@osdl.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).