Skip to contentSkip to conversation

Revealing unload_lock to everyone

DISCUSSION Dave Hansen 2 participants 2 messages Jan 31, 2002 – Feb 1, 2002

lore
Share & tools
lore
#0 lore raw

This came up in a conversation about ieee1394_core.c. In 2.5.3, the BKL is used to protect a module from being unloaded. The code looks like this:

        lock_kernel();
        read_lock(&ieee1394_chardevs_lock);
        file_ops = ieee1394_chardevs[blocknum].file_ops;
        module = ieee1394_chardevs[blocknum].module;
        read_unlock(&ieee1394_chardevs_lock);
	...
        INCREF(module);
        unlock_kernel();

The question is, how can we keep the module from being unloaded between the file_ops assignment, and the INCREF. Do we have a general purpose way, other than the BKL, to keep a module from being unloaded? There is unload_lock, but it is static to module.c. We can always make it global, but is there a better solution?

Signature · 2 lines
Dave Hansen
[email protected]
#1 lore raw
Quoted 13 lines · Dave Hansen

This came up in a conversation about ieee1394_core.c. In 2.5.3, the BKL is used to protect a module from being unloaded. The code looks like this:

        lock_kernel();
        read_lock(&ieee1394_chardevs_lock);
        file_ops = ieee1394_chardevs[blocknum].file_ops;
        module = ieee1394_chardevs[blocknum].module;
        read_unlock(&ieee1394_chardevs_lock);
	...
        INCREF(module);
        unlock_kernel();
Quoted 5 lines

The question is, how can we keep the module from being unloaded between the file_ops assignment, and the INCREF. Do we have a general purpose way, other than the BKL, to keep a module from being unloaded? There is unload_lock, but it is static to module.c. We can always make it global, but is there a better solution?

try_inc_mod_count().