On 9/25/25 12:16 AM, Julian LaGattuta wrote: >> Could you please explain the motivation for doing this in more detail? >> >> I think we shouldn't attempt to do anything clever with modules that >> crashed during initialization. Such a module can already leave the >> system in an unstable state and trying to recover can cause even more >> problems. For instance, I don't see how it is safe to call the module's >> exit function. > > Thank you for your response Petr. The motivation comes from when I > wanted to replace a crashed module with one which does not crash > without having to reboot. I looked around and saw some other people > complain about it on stackoverflow.
Hm, I'm still not sure I understand the use case. If it is about being able to remove a crashed module when developing it, then I wouldn't expect rebooting the machine to be much of an issue. If it is on the other hand about removing it on a production machine, then I think attempting this can leave the machine in a worse state and not something we should encourage or support. > > I thought that if a module crashed during init, it would be in a no > better position compared to if it were forcefully removed. > Therefore, there is no reason why this shouldn't be an option as it > couldn't make the problem worse. A module can be halfway through its initialization when it crashes. It may have already registered with various parts of the kernel and I believe that removing the module from under the kernel's control could result in even more problems. The current support for forcefully removing a module overrides the kernel's tracking of module references. This option was originally introduced by "[PATCH] Forced module unload" [1]. As far as I can see, it was related to the module loader rework at that time in "[PATCH] In-kernel Module Loader" [2]. This rework provided raceless loading/unloading and marked several MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT interfaces as obsolete and unsafe. Since some modules still used the old racy interfaces, it seems the forced removal option was added to make it possible to remove such modules. However, this issue should have been fixed a long time ago, so I wonder if even the current CONFIG_MODULE_FORCE_UNLOAD support is useful. [1] https://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux-fullhistory.git/commit/?id=d0f8c9a4c2c9d93463d157248c73028670e80a97 [2] https://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux-fullhistory.git/commit/?id=4c877b08daf4b463c144cbd2748ed1659931a0dd -- Thanks, Petr

