diff options
author | Peter Zijlstra <peterz@infradead.org> | 2017-02-08 15:48:01 +0100 |
---|---|---|
committer | Jessica Yu <jeyu@redhat.com> | 2017-02-10 19:21:10 -0800 |
commit | 5ff22646d246e23bf8056c63bed6aaf9fd22ed12 (patch) | |
tree | a7e60df861e3c92e706b06a407c1f01bdbec2be3 /kernel | |
parent | 1f318a8bafcfba9f0d623f4870c4e890fd22e659 (diff) | |
download | linux-5ff22646d246e23bf8056c63bed6aaf9fd22ed12.tar.bz2 |
module: Optimize search_module_extables()
While looking through the __ex_table stuff I found that we do a linear
lookup of the module. Also fix up a comment.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Jessica Yu <jeyu@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/kernel/module.c b/kernel/module.c index 330f64e7e193..32d0d32abbf6 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -4170,22 +4170,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr) struct module *mod; preempt_disable(); - list_for_each_entry_rcu(mod, &modules, list) { - if (mod->state == MODULE_STATE_UNFORMED) - continue; - if (mod->num_exentries == 0) - continue; + mod = __module_address(addr); + if (!mod) + goto out; - e = search_extable(mod->extable, - mod->extable + mod->num_exentries - 1, - addr); - if (e) - break; - } + if (!mod->num_exentries) + goto out; + + e = search_extable(mod->extable, + mod->extable + mod->num_exentries - 1, + addr); +out: preempt_enable(); - /* Now, if we found one, we are running inside it now, hence - we cannot unload the module, hence no refcnt needed. */ + /* + * Now, if we found one, we are running inside it now, hence + * we cannot unload the module, hence no refcnt needed. + */ return e; } |