From: Stephen Hemminger <shemminger@osdl.org>
To: "David S. Miller" <davem@redhat.com>
Cc: netdev@oss.sgi.com, kuznet@ms2.inr.ac.ru
Subject: Re: dev->destructor
Date: Wed, 30 Apr 2003 09:33:03 -0700 [thread overview]
Message-ID: <20030430093303.2e80e7ad.shemminger@osdl.org> (raw)
In-Reply-To: <20030429.232631.68131803.davem@redhat.com>
On Tue, 29 Apr 2003 23:26:31 -0700 (PDT)
"David S. Miller" <davem@redhat.com> wrote:
>
> Stephen, you're right about the dev->destructor problem.
> I misread your postings, and I'm very sorry about that.
> We were talking about two different things, and admittedly
> I had forgotten how some of this stuff works.
>
> Alexey, currently dev->{open,close} are what does get/put
> of device module reference.
>
> However, device unregister can explode if dev->destructor is
> present. Unlike in dev->destructor==NULL case, we do not
> wait for remnant dev->refcnt to go away. Therefore we could
> invoke dev->destructor() after module is unloaded.
>
> I guess there are two ways to address this problem:
>
> 1) dev_get() gets module reference and dev_put() puts is.
> Ugly, as this means dev_get() can fail, but this does
> cover all the possible cases.
>
> 2) Make unregister_netdev() wait for refcount to reach 1
> regardless of whether dev->destructor is NULL or not.
>
> I don't like #1. Do you see some holes in #2?
>
> As Stephen brought up, this also means we should do something
> about that NETDEV_UNREGISTER code in dst_dev_event() :-(
There are other (not nice possibilities).
A) Require driver have a wait queue per device and wait after unregister.
Ugly and requires repeated work.
B) Put wait queue and wakeup logic in netdevice/unregister_netdev.
Adds more to already overloaded netdevice structure, but
could cleanup existing polling stuff.
C) Audit unregister notifier callbacks to ensure they all dev_put,
all references to device. This works for
normal IPv4 except for the dst cache. The following patch causes
the dst cache to do this.
--- linux-2.5/net/core/dst.c 2003-04-29 11:54:39.000000000 -0700
+++ linux-2.5-bridge/net/core/dst.c 2003-04-29 10:17:15.000000000 -0700
@@ -228,7 +228,7 @@
_race_ _condition_.
*/
if (event!=NETDEV_DOWN &&
- dev->destructor == NULL &&
+ (dev->destructor == NULL || dev->owner) &&
dst->output == dst_blackhole) {
dst->dev = &loopback_dev;
dev_put(dev);
D) Your option #2 only needs to be done if device is a module
otherwise, can just let destructor run later.
--- linux-2.5/net/core/dev.c 2003-04-29 11:54:39.000000000 -0700
+++ linux-2.5-bridge/net/core/dev.c 2003-04-30 09:28:34.000000000 -0700
@@ -2737,7 +2737,7 @@
free_divert_blk(dev);
#endif
- if (dev->destructor != NULL) {
+ if (dev->destructor != NULL && dev->owner == NULL) {
#ifdef NET_REFCNT_DEBUG
if (atomic_read(&dev->refcnt) != 1)
printk(KERN_DEBUG "unregister_netdevice: holding %s "
next prev parent reply other threads:[~2003-04-30 16:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-30 6:26 dev->destructor David S. Miller
2003-04-30 16:33 ` Stephen Hemminger [this message]
2003-05-01 1:10 ` dev->destructor kuznet
2003-05-01 7:00 ` dev->destructor David S. Miller
2003-05-01 12:01 ` dev->destructor Rusty Russell
2003-05-01 11:09 ` dev->destructor David S. Miller
2003-05-01 17:51 ` dev->destructor Arnaldo Carvalho de Melo
2003-05-01 16:55 ` dev->destructor David S. Miller
2003-05-01 17:28 ` dev->destructor Arnaldo Carvalho de Melo
2003-05-02 4:06 ` dev->destructor kuznet
2003-05-02 5:25 ` dev->destructor Rusty Russell
2003-05-02 20:48 ` dev->destructor David S. Miller
2003-05-03 4:07 ` dev->destructor Rusty Russell
2003-05-03 3:46 ` dev->destructor David S. Miller
2003-05-05 5:18 ` dev->destructor Rusty Russell
2003-05-03 4:00 ` dev->destructor David S. Miller
2003-05-05 16:08 ` dev->destructor Stephen Hemminger
2003-05-06 14:25 ` dev->destructor David S. Miller
2003-05-07 2:54 ` dev->destructor Rusty Russell
2003-05-05 20:00 ` dev->destructor Stephen Hemminger
2003-05-06 4:18 ` dev->destructor Rusty Russell
2003-05-06 14:23 ` dev->destructor David S. Miller
2003-05-06 22:32 ` [PATCH 2.5.69] IPV4 should use dev_hold Stephen Hemminger
2003-05-07 7:32 ` David S. Miller
2003-05-07 2:50 ` dev->destructor Rusty Russell
2003-05-07 3:58 ` dev->destructor David S. Miller
2003-05-06 22:35 ` dev->destructor Stephen Hemminger
2003-05-06 23:51 ` [RFC] Experiment with dev and module ref counts 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=20030430093303.2e80e7ad.shemminger@osdl.org \
--to=shemminger@osdl.org \
--cc=davem@redhat.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@oss.sgi.com \
/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).