The only difference between module and non-module is whether the code
and data areas are freed or left in the kernel for the next user. All
other processing should be the same for hotplug. This is why
CONFIG_HOTPLUG retains the __exit code in the kernel instead of
discarding it at link time.
>Besides, a common pattern for those "hold this down, kick that, then
>slowly count to ten, and now it's safe to release" solutions seems
>to be that it takes roughly ten times as long to find the race
>condition buried deep within them, than it took for the respective
>predecessor.
I don't like 'wait for n seconds then release' methods, as you say they
just hide the problem. Neither Rusty nor I are suggesting that
approach. Rusty's idea is
Check use count.
Unregister.
Ensure that all code that had a reference to the module has either
dropped that reference or bumped the use count.
Check use count again, it may have been bumped above.
If use count is still 0, there are no stale references left. It is
now safe to unload, call the module unallocate routine then free its
area.
If use count != 0, either schedule for removal when the count goes to
0 or reregister. I prefer reregister, Rusty prefers delayed removal.
Ensuring that all code has either dropped stale references or bumped
the use count means that all processes that were not sleeping when
rmmod was started must proceed to a sync point. It is (and always has
been) illegal to sleep while using module code/data (note: using, not
referencing).
-
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/