Re: [RFC] fix sysfs symlinks

From: Rusty Russell
Date: Sat Apr 17 2004 - 01:17:31 EST


On Fri, 2004-04-16 at 05:14, viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
wrote:
> BTW, how about a new section that would
> a) be allocated separately at module load time
> b) contain a kobject with ->release() freeing that section
> c) be populated with structures containing kobjects and having
> no ->release(); main kobject would be pinned down by them. Original
> refcount in each of those guys would be 1.
>
> module_exit() would unregister all stuff we have in there and then drop
> the references to them. No waiting for anything and when all references
> to these objects are gone, we get the section freed. That can happen
> way after the completion of rmmod - as the matter of fact we could have
> the same module loaded again by that time.

Or you could skip the extra section, and keep all the module memory
until later. Instead of a section marker, you then set the release of
those static things to "static_release" which does the put on the module
memory kref:

void static_release(struct kobject *kobj)
{
struct module *mod;

down(&module_mutex);
list_for_each_entry(mod, &modules, list) {
BUG_ON(within(kobj, mod->module_init, mod->init_size);
if (within(kobj, mod->module_core, mod->core_size)) {
kref_put(&mod->mem_kref);
up(&module_mutex);
return;
}
}
up(&module_mutex);
BUG();
}

One question which comes to mind, who does the original kref_get()s on
the module memory? Even if we did have a separate section, the module
loader can't know how many objects objects are in there...

Cheers,
Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell

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