Messages in this thread | | | Date | Tue, 1 Jun 2010 10:44:39 +0800 | From | Américo Wang <> | Subject | Re: [PATCH 1/2] Make the module 'usage' lists be two-way |
| |
On Mon, May 31, 2010 at 01:16:23PM -0700, Linus Torvalds wrote: > >From: Linus Torvalds <torvalds@linux-foundation.org> >Date: Mon, 31 May 2010 12:19:37 -0700 >Subject: [PATCH 1/2] Make the module 'usage' lists be two-way > >When adding a module that depends on another one, we used to create a >one-way list of "modules_which_use_me", so that module unloading could >see who needs a module. > >It's actually quite simple to make that list go both ways: so that we >not only can see "who uses me", but also see a list of modules that are >"used by me". > >In fact, we always wanted that list in "module_unload_free()": when we >unload a module, we want to also release all the other modules that are >used by that module. But because we didn't have that list, we used to >first iterate over all modules, and then iterate over each "used by me" >list of that module. > >By making the list two-way, we simplify module_unload_free(), and it >allows for some trivial fixes later too. > >Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Hi, Linus,
> > /* Clear the unload stuff of the module. */ > static void module_unload_free(struct module *mod) > { >- struct module *i; >+ struct module_use *use, *tmp; > >- list_for_each_entry(i, &modules, list) { >- struct module_use *use; >- >- list_for_each_entry(use, &i->modules_which_use_me, list) { >- if (use->module_which_uses == mod) { >- DEBUGP("%s unusing %s\n", mod->name, i->name); >- module_put(i); >- list_del(&use->list); >- kfree(use); >- sysfs_remove_link(i->holders_dir, mod->name); >- /* There can be at most one match. */ >- break; >- } >- } >+ list_for_each_entry_safe(use, tmp, &mod->target_list, target_list) { >+ struct module *i = use->target; >+ DEBUGP("%s unusing %s\n", mod->name, i->name); >+ module_put(i); >+ list_del(&use->source_list); >+ list_del(&use->target_list); >+ kfree(use); >+ sysfs_remove_link(i->holders_dir, mod->name);
I think it's nice to have a remove_module_usage() here, since we already have add_module_usage().
Thanks.
| |