How to prevent a module from unloading when in used

Chetan Nanda chetannanda at gmail.com
Wed Jul 16 11:27:38 EDT 2014


On Wed, Jul 16, 2014 at 8:49 PM, Chetan Nanda <chetannanda at gmail.com> wrote:

>
>
> On Wed, Jul 16, 2014 at 6:39 PM, John de la Garza <john at jjdev.com> wrote:
>
>> On Wed, Jul 16, 2014 at 04:00:18PM +0530, Chetan Nanda wrote:
>> > A depends on B, so B is automatically loaded when A is loaded.
>> > B module is also directly being used by the user side code via misc
>> > interface.
>> >.
>> > Now when I am unloading module A, via "modprobe -r A" it is also
>> unloading
>> > the module B which is being used by the application and resulting in the
>> > kernel crash.
>>
>> You said that A depends on B, right?  Why do you have A dependng on B?
>> If it A needs to have B then it makes sense that you can not remove A
>> while
>> B is in use.  If A doesn't need B, why not remove the dependency.
>
>
A is calling few APIs defined by B.

But why when user space application is already using  module B. (it has
already open its device fd) kernel allows to remove it.

I tried with doing try_module_get() in the module's open function, it
prevent module B unloading but cause thread doing modprobe -r to hang
Is there any other way to mark module as busy when being used by user
application?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140716/9399133f/attachment.html 


More information about the Kernelnewbies mailing list