From: Werner Almesberger <wa@almesberger.net>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, Doug Ledford <dledford@redhat.com>,
Alexander Viro <viro@math.psu.edu>
Subject: Re: Module Refcount & Stuff mini-FAQ
Date: Tue, 26 Nov 2002 04:12:12 -0300 [thread overview]
Message-ID: <20021126041212.B22825@almesberger.net> (raw)
In-Reply-To: <20021126044142.48F332C07F@lists.samba.org>; from rusty@rustcorp.com.au on Tue, Nov 26, 2002 at 02:16:44PM +1100
Rusty Russell wrote:
> Yes, but between doing and undoing (in the failure path) someone has
> started using the module.
But how ? Don't we have only two ways of calling a module, i.e.
by symbol, or by callback ? All callbacks that might call a module
must be protected with try_module_get, right ? (*)
(*) Actually, if the registration can be revoked, and the
deregistration function does properly synchronize with on-going
callbacks, you shouldn't need try_module_get either. E.g.
del_timer_sync doesn't need to know about module owners.
So, if you make try_module_get work during initialization, and
modules don't publish their symbols before initialization is done,
there should be no problem ?
> Given we have a method of isolating a module already, it seems logical
> to use it to prevent exactly this race.
But that's mainly the symbol-unload race, considering that any call
through a function pointer requires try_module_get anyway. Without
try_module_get, there would also be callback-unload races if
callback de-registration doesn't synchronize (e.g. del_timer
vs. del_timer_sync).
By the way, it's also not so nice that there can't be
callbacks at removal, e.g.
service_unregister(...)
{
...
for_pending_requests(req) {
...
if (try_module_get(req->owner))
req->fn(req,REQUEST_CANCELLED);
else
printk(KERN_CRIT "we just dropped a request on the "
"floor, how nice\n");
...
}
...
}
Calling this from the module removal function would be
perfectly safe.
Actually ... can't you allow modules to be called until the
cleanup function has returned ?
> Unfortunately my last attempt
> assumed noone did this, and broke IDE and SCSI (hence pissing
> *everyone* off 8).
Two in one strike ain't bad ;-) Maybe we can find something that
gets rid of that pesky NFS, too, e.g. by adding
#define while if /* enforce efficient programming practices */
to linux/kernel.h, or such ;-)
- Werner
--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
next prev parent reply other threads:[~2002-11-26 7:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-18 22:58 Rusty Russell
2002-11-19 2:30 ` Werner Almesberger
2002-11-24 22:50 ` Rusty Russell
2002-11-25 2:07 ` Werner Almesberger
2002-11-25 2:27 ` Rusty Russell
2002-11-25 6:39 ` Werner Almesberger
2002-11-25 22:43 ` Rusty Russell
2002-11-26 2:26 ` Werner Almesberger
2002-11-26 3:16 ` Rusty Russell
2002-11-26 7:12 ` Werner Almesberger [this message]
2002-11-26 22:56 ` Rusty Russell
2002-11-19 2:40 ` John Levon
2002-11-24 23:02 ` Rusty Russell
2002-11-25 0:38 ` John Levon
2002-11-19 3:10 ` kksymoops Jeff Garzik
2002-11-19 3:50 ` kksymoops Jeff Garzik
2002-11-19 21:10 ` kksymoops Rusty Russell
2002-11-20 15:46 ` kksymoops Kai Germaschewski
2002-11-23 22:23 ` Module Refcount & Stuff mini-FAQ Pavel Machek
2002-11-25 0:26 ` Rusty Russell
2002-11-19 19:18 Adam J. Richter
2002-11-20 12:25 Adam J. Richter
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=20021126041212.B22825@almesberger.net \
--to=wa@almesberger.net \
--cc=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=viro@math.psu.edu \
/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
all inboxes | Powered by JetHome®