Skip to content

Commit

Permalink
module: Unlink module with RCU synchronizing instead of stop_machine
Browse files Browse the repository at this point in the history
Unlink module from module list with RCU synchronizing instead
of using stop_machine(). Since module list is already protected
by rcu, we don't need stop_machine() anymore.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
mhiramathitachi authored and rustyrussell committed Nov 11, 2014
1 parent 4f48795 commit 461e34a
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,18 +1697,6 @@ static void mod_sysfs_teardown(struct module *mod)
mod_sysfs_fini(mod);
}

/*
* unlink the module with the whole machine is stopped with interrupts off
* - this defends against kallsyms not taking locks
*/
static int __unlink_module(void *_mod)
{
struct module *mod = _mod;
list_del(&mod->list);
module_bug_cleanup(mod);
return 0;
}

#ifdef CONFIG_DEBUG_SET_MODULE_RONX
/*
* LKM RO/NX protection: protect module's text/ro-data
Expand Down Expand Up @@ -1860,7 +1848,11 @@ static void free_module(struct module *mod)

/* Now we can delete it from the lists */
mutex_lock(&module_mutex);
stop_machine(__unlink_module, mod, NULL);
/* Unlink carefully: kallsyms could be walking list. */
list_del_rcu(&mod->list);
/* Wait for RCU synchronizing before releasing mod->list. */
synchronize_rcu();
module_bug_cleanup(mod);
mutex_unlock(&module_mutex);

/* This may be NULL, but that's OK */
Expand Down

0 comments on commit 461e34a

Please sign in to comment.