From: Stephen Hemminger <shemminger@osdl.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: patrakov@ums.usu.ru, netdev@vger.kernel.org, davem@davemloft.net,
akpm@osdl.org
Subject: [PATCH] netdev: hotplug napi race cleanup
Date: Mon, 24 Apr 2006 15:23:41 -0700 [thread overview]
Message-ID: <20060424152341.094b72d8@localhost.localdomain> (raw)
In-Reply-To: <E1FX5zQ-000177-00@gondolin.me.apana.org.au>
This follows after the earlier two patches.
Change the initialization of the class device portion of the net device
to be done earlier, so that any races before registration completes are
harmless. Add a mutex to avoid changes to netdevice during the
class device registration.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
--- linux-2.6.orig/net/core/dev.c 2006-04-24 10:31:15.000000000 -0700
+++ linux-2.6/net/core/dev.c 2006-04-24 10:31:16.000000000 -0700
@@ -203,10 +203,12 @@
#ifdef CONFIG_SYSFS
extern int netdev_sysfs_init(void);
-extern int netdev_register_sysfs(struct net_device *);
-extern void netdev_unregister_sysfs(struct net_device *);
+extern void netdev_init_classdev(struct net_device *);
+#define netdev_register_sysfs(dev) class_device_add(&(dev->class_dev))
+#define netdev_unregister_sysfs(dev) class_device_del(&(dev->class_dev))
#else
#define netdev_sysfs_init() (0)
+#define netdev_init_classdev(dev) do { } while(0)
#define netdev_register_sysfs(dev) (0)
#define netdev_unregister_sysfs(dev) do { } while(0)
#endif
@@ -2870,6 +2872,8 @@
set_bit(__LINK_STATE_PRESENT, &dev->state);
+ netdev_init_classdev(dev);
+
dev->next = NULL;
dev_init_scheduler(dev);
write_lock_bh(&dev_base_lock);
@@ -3047,7 +3051,10 @@
* this is a delayed call after register_netdevice
* so no way to tell device driver what is wrong.
*/
+ rtnl_lock();
err = netdev_register_sysfs(dev);
+ __rtnl_unlock();
+
if (err) {
printk(KERN_ERR "%s: failed sysfs registration (%d)\n",
dev->name, err);
--- sky2-2.6.17.orig/net/core/net-sysfs.c 2006-04-24 10:31:14.000000000 -0700
+++ sky2-2.6.17/net/core/net-sysfs.c 2006-04-24 10:31:16.000000000 -0700
@@ -443,13 +443,8 @@
#endif
};
-void netdev_unregister_sysfs(struct net_device * net)
-{
- class_device_del(&(net->class_dev));
-}
-
-/* Create sysfs entries for network device. */
-int netdev_register_sysfs(struct net_device *net)
+/* Setup class device */
+void netdev_init_classdev(struct net_device *net)
{
struct class_device *class_dev = &(net->class_dev);
struct attribute_group **groups = net->sysfs_groups;
@@ -470,8 +465,6 @@
|| (net->wireless_handlers && net->wireless_handlers->get_wireless_stats))
*groups++ = &wireless_group;
#endif
-
- return class_device_add(class_dev);
}
int netdev_sysfs_init(void)
next prev parent reply other threads:[~2006-04-24 22:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20060418042300.GA11061@kroah.com>
[not found] ` <20060418042345.GB11061@kroah.com>
[not found] ` <44448DFF.3080108@ums.usu.ru>
[not found] ` <20060418153951.GC30485@kroah.com>
[not found] ` <4445BB0F.6010305@ums.usu.ru>
2006-04-21 17:25 ` Hotplug race on name change Stephen Hemminger
2006-04-22 0:28 ` Herbert Xu
2006-04-24 22:23 ` Stephen Hemminger [this message]
2006-04-25 1:30 ` [PATCH] netdev: hotplug napi race cleanup Andrew Morton
2006-04-26 9:43 ` David S. Miller
2006-05-07 1:09 ` David S. Miller
2006-05-08 16:54 ` Stephen Hemminger
2006-05-08 18:37 ` David S. Miller
2006-05-08 19:02 ` Stephen Hemminger
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=20060424152341.094b72d8@localhost.localdomain \
--to=shemminger@osdl.org \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=patrakov@ums.usu.ru \
/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).