sys_delete_module (NULL) - a bug, or a feature?

Nimrod Zimerman (zimerman@deskmail.com)
Mon, 4 Jan 1999 23:00:27 +0200


Hello.

I've recently noticed that calling sys_delete_module(NULL) (in
kernel/module.c), which is supposed to remove all automatically loaded
modules that aren't used, doesn't always work as expected. It requires
several calls to sys_delete_module to reliably remove all unused modules.

For example, I got the 'lp' device auto-loaded (with parport_pc and
parport). lsmod says:

Module Size Used by
parport_pc 5520 1 (autoclean)
lp 4616 0 (autoclean)
parport 6868 1 (autoclean) [parport_pc lp]

After 'rmmod -a' once, lsmod still says:

Module Size Used by
parport_pc 5520 1 (autoclean)
lp 4616 0 (autoclean)
parport 6868 1 (autoclean) [parport_pc lp]

After another 'rmmod -a', lsmod says:

Module Size Used by
parport_pc 5520 0 (autoclean)
parport 6868 0 (autoclean) [parport_pc]

And finally, after another try, lsmod happily announces that no modules are
loaded.

Is this a bug? Is this a feature? I don't know.

The reason this happens, however, is the MOD_VISITED flag. It prevents
modules from immediately being released after performing a MOD_INC_USE_COUNT
or MOD_DEC_USE_COUNT on them.
I can't say that I understand why MOD_VISITED is required, and even if this
thing is a feature, I'd love to know what is the reason for it.

Thanks.

Nimrod

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/