Only "first use" (ie. ->open) functions need gaurding against unloads.
Any subsequent functions are guaranteed to have a reference to the
module, and don't need to bother with the refcount. I have a few ideas
to optimize the refcounting better than it is now.
> 2) Introduce a delay after unregistering a module's services and before
> removing the code from memory.
>
> This puts all the penalty and complexity where it should be, in the
> unload path. However it requires a two stage rmmod process (check
> use count, unregister, delay, recheck use count, remove if safe)
> so all module cleanup routines need to be split into unregister and
> final remove routines.
>
> This is relatively easy to do without preemption, it is
> significantly harder with preempt. There are also unsolved problems
> with long running device commands with callbacks (e.g. CD-R fixate)
> and with kernel threads started from a module (must wait until
> zombies have been reaped).
The callbacks should hold references that would not allow the module to
unload. Other than that, this is the same problem the RCU folks are
working on.
> Rusty and I agree that option (2) is the only sane way to do module
> unload, assuming that we retain module unloading. First decide if the
> extra work is justified.
Freeing up the limited vmalloc address space should be justification enough.
-- Brian Gerst
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/