|| ||Linus Torvalds <torvalds-AT-osdl.org>|
|| ||Alan Stern <stern-AT-rowland.harvard.edu>|
|| ||Re: PATCH: (as177) Add class_device_unregister_wait() and
platform_device_unregister_wait() to the driver model core|
|| ||Sun, 25 Jan 2004 11:02:58 -0800 (PST)|
|| ||Greg KH <greg-AT-kroah.com>,
Kernel development list <linux-kernel-AT-vger.kernel.org>,
Patrick Mochel <mochel-AT-digitalimplant.org>|
On Sun, 25 Jan 2004, Alan Stern wrote:
> Is there some reason why modules don't work like this?
There's a few:
- pain. pain. pain.
- doing proper refcounting of modules is _really_ really hard. The reason
is that proper refcounting is a "local" issue: you reference count a
single data structure. It's basically impossible to make a "global"
reference count without jumping through hoops.
- lack of testing. Unloading a module happens once in a blue moon, if
The proper thing to do (and what we _have_ done) is to say "unloading of
modules is not supported". It's a debugging feature, and you literally
shouldn't do it unless you are actively developing that module.
Sadly, some modules are broken. Old 16-bit PCMCIA in particular _depends_
on unloading modules, since the old PCMCIA layer doesn't do hotplug: it
literally thinks of module load/unload as the "plug/unplug" event.
But it basically boils down to: don't think of module unload as a "normal
event". It isn't. Getting it truly right is (a) too painful and (b) would
be too slow, so we're not even going to try.
(As an example of "too painful, too slow", think of something like a
packet filter module. You'd literally have to increment the count in every
part that gets a packet, and decrement the count at every point where it
lets the packet go. And since it would have to be SMP-safe, it would have
to be a locked cycle, or we'd have to have per-CPU counters - at which
point you now also have to worry about things like preemption and
sleeping, which just means that it would be a _lot_ of very fragile code).
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
to post comments)