Overzealous permenant mark removed
PATCH 1/1 Overzealous permenant mark removed
Linus, please apply.
Name: Modules without init functions don't need exit functions
Author: Rusty Russell
Status: Trivial
D: If modules don't use module_exit(), they cannot be unloaded. This
D: safety mechanism should not apply for modules which don't use
D: module_init() (implying they have nothing to clean up anyway).
kernel/module.c +3 -2
@@ -405,7 +405,8 @@ sys_delete_module(const char *name_user, } } -if (!mod->exit || mod->unsafe) { +/* If it has an init func, it must have an exit func to unload */ +if ((mod->init && !mod->exit) || mod->unsafe) { forced =try_force (flags);if (!forced) {/* This module can't be removed */
@@ -473,7 +474,7 @@ static void print_unload_info(struct seqif (mod->unsafe)seq_printf (m," [unsafe]" ); -if (!mod->exit) +if (mod->init && !mod->exit)seq_printf (m," [permanent]" );seq_printf (m,"\n" );
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 4 lines · Rusty Russell
Name: Modules without init functions don't need exit functions
D: If modules don't usemodule_exit(), they cannot be unloaded. This
D: safety mechanism should not apply for modules which don't use
D:module_init()(implying they have nothing to clean up anyway).
Just a heads up, as this bit me with agpgart which had a module_init() but no module_exit() and then found itself un-unloadable[1]. I don't know if agpgart found itself in the unique position of doing this (It only really used its _init function to clear some vars, and printk a banner), but its something to keep an eye out for.
I fixed it by adding a null _exit function, (which later did a sanity check just for good measure).
Dave
[1] Coo, a new silly word.
Signature · 2 lines
| Dave Jones. http://www.codemonkey.org.uk | SuSE Labs
In message <[email protected]> you write:
Quoted 7 lines · Rusty Russell
Quoted 5 lines
Name: Modules without init functions don't need exit functions
D: If modules don't usemodule_exit(), they cannot be unloaded. This
D: safety mechanism should not apply for modules which don't use
D:module_init()(implying they have nothing to clean up anyway).
Quoted 5 lines
Just a heads up, as this bit me with agpgart which had a
module_init()but nomodule_exit()and then found itself un-unloadable[1]. I don't know if agpgart found itself in the unique position of doing this (It only really used its_initfunction to clear some vars, and printk a banner), but its something to keep an eye out for.
The banner, well, you know Linus' position on printing banners 8)
The rest seems superfluous:
int __init agp_init(void)
{
static int already_initialised=0;
if (already_initialised!=0)
return 0;
already_initialised = 1;
memset(&agp_bridge, 0, sizeof(struct agp_bridge_data));
agp_bridge.type = NOT_SUPPORTED;
printk(KERN_INFO "Linux agpgart interface v%d.%d (c) Dave Jones\n",
AGPGART_VERSION_MAJOR, AGPGART_VERSION_MINOR);
return 0;
}Hope that helps,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 2 lines · Rusty Russell
The banner, well, you know Linus' position on printing banners 8)
Well, I don't much enjoy banners, but on the other hand I enjoy nasty little made-up rules that make people jump through hoops to do what they really want to do even less.
I don't really think that having no exit function should mean that you can't unload it ("unless you have no init function, in which case it's ok, unless it's the third thursday in a month that starts with the letter 'M', in which case you can only unload it if you walk widdershins around the computer thrice").
In other words, the rule really should be: "if the usage count > 1, you can't unload it".
And if somebody wants to create an un-unloadable driver, he should just increment the module count and be done with it. No magic rules (maybe you can make /proc/modules print out "<permanent>" if the count is over some number, and then people who want permanent modules just initialize the count past that).
Linus
In message <[email protected]> you wri te:
Quoted 5 lines
And if somebody wants to create an un-unloadable driver, he should just increment the module count and be done with it. No magic rules (maybe you can make
/proc/modulesprint out "<permanent>" if the count is over some number, and then people who want permanent modules just initialize the count past that).
OTOH, your approach left us with stuff that wasn't modular at all (like IPv4) because people felt it was somehow "wrong" to make it non-unloadable.
I guess it depends on numbers. If we see lots of drivers which initialize things and don't really need to clean up, you're right.
If we see far more "I didn't implement unloading" drivers, it's easiest to do the safe thing: require the author DO SOMETHING to make the module unloadable, not vice versa.
But the change is trivial,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.