From: Rusty Russell <rusty@rustcorp.com.au>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: davem@redhat.com, kuznet@ms2.inr.ac.ru, netdev@oss.sgi.com,
acme@conectiva.com.br
Subject: Re: dev->destructor
Date: Tue, 06 May 2003 14:18:36 +1000 [thread overview]
Message-ID: <20030506075808.388332C07F@lists.samba.org> (raw)
In-Reply-To: Your message of "Mon, 05 May 2003 13:00:50 MST." <20030505130050.4b9868bb.shemminger@osdl.org>
In message <20030505130050.4b9868bb.shemminger@osdl.org> you write:
> As an experiment, tried acquiring module ref count every time network
> device is ref counted.
Brave man 8)
> The result is discovering that there are cases in the Ethernet
> module init path where there is a call to dev_hold() without a
> previous explicit ref count.
Well caught: this is in fact a false alarm. Coming, as we do, out of
module_init(), we actually hold an implicit reference.
It's logically consistent to make it implicit, and cuts out some code
in the unload path.
How's this?
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: Hold Initial Reference To Module
Author: Rusty Russell
Status: Tested on 2.5.69
D: __module_get is theoretically allowed on module inside init, since
D: we already hold an implicit reference. Currently this BUG()s: make
D: the reference count explicit, which also simplifies delete path.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.69/kernel/module.c working-2.5.69-module-init-ref/kernel/module.c
--- linux-2.5.69/kernel/module.c 2003-05-05 12:37:13.000000000 +1000
+++ working-2.5.69-module-init-ref/kernel/module.c 2003-05-06 12:11:18.000000000 +1000
@@ -214,6 +214,8 @@ static void module_unload_init(struct mo
INIT_LIST_HEAD(&mod->modules_which_use_me);
for (i = 0; i < NR_CPUS; i++)
atomic_set(&mod->ref[i].count, 0);
+ /* Hold reference count during initialization. */
+ atomic_set(&mod->ref[smp_processor_id()].count, 1);
/* Backwards compatibility macros put refcount during init. */
mod->waiter = current;
}
@@ -500,16 +502,6 @@ sys_delete_module(const char __user *nam
goto out;
}
- /* Coming up? Allow force on stuck modules. */
- if (mod->state == MODULE_STATE_COMING) {
- forced = try_force(flags);
- if (!forced) {
- /* This module can't be removed */
- ret = -EBUSY;
- goto out;
- }
- }
-
/* If it has an init func, it must have an exit func to unload */
if ((mod->init != init_module && mod->exit == cleanup_module)
|| mod->unsafe) {
@@ -1448,6 +1440,7 @@ sys_init_module(void __user *umod,
printk(KERN_ERR "%s: module is now stuck!\n",
mod->name);
else {
+ module_put(mod);
down(&module_mutex);
free_module(mod);
up(&module_mutex);
@@ -1463,6 +1456,9 @@ sys_init_module(void __user *umod,
mod->init_size = 0;
up(&module_mutex);
+ /* Drop initial reference. */
+ module_put(mod);
+
return 0;
}
next prev parent reply other threads:[~2003-05-06 4:18 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 ` dev->destructor Stephen Hemminger
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 ` Rusty Russell [this message]
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=20030506075808.388332C07F@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=acme@conectiva.com.br \
--cc=davem@redhat.com \
--cc=kuznet@ms2.inr.ac.ru \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.