Commit 5ff22646 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Jessica Yu

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: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarJessica Yu <jeyu@redhat.com>
parent 1f318a8b
...@@ -4170,22 +4170,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr) ...@@ -4170,22 +4170,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
struct module *mod; struct module *mod;
preempt_disable(); preempt_disable();
list_for_each_entry_rcu(mod, &modules, list) { mod = __module_address(addr);
if (mod->state == MODULE_STATE_UNFORMED) if (!mod)
continue; goto out;
if (mod->num_exentries == 0)
continue; if (!mod->num_exentries)
goto out;
e = search_extable(mod->extable, e = search_extable(mod->extable,
mod->extable + mod->num_exentries - 1, mod->extable + mod->num_exentries - 1,
addr); addr);
if (e) out:
break;
}
preempt_enable(); 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; return e;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment