Skip to content

Commit 5ff2264

Browse files
Peter ZijlstraJessica Yu
authored andcommitted
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>
1 parent 1f318a8 commit 5ff2264

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

kernel/module.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4170,22 +4170,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
41704170
struct module *mod;
41714171

41724172
preempt_disable();
4173-
list_for_each_entry_rcu(mod, &modules, list) {
4174-
if (mod->state == MODULE_STATE_UNFORMED)
4175-
continue;
4176-
if (mod->num_exentries == 0)
4177-
continue;
4173+
mod = __module_address(addr);
4174+
if (!mod)
4175+
goto out;
41784176

4179-
e = search_extable(mod->extable,
4180-
mod->extable + mod->num_exentries - 1,
4181-
addr);
4182-
if (e)
4183-
break;
4184-
}
4177+
if (!mod->num_exentries)
4178+
goto out;
4179+
4180+
e = search_extable(mod->extable,
4181+
mod->extable + mod->num_exentries - 1,
4182+
addr);
4183+
out:
41854184
preempt_enable();
41864185

4187-
/* Now, if we found one, we are running inside it now, hence
4188-
we cannot unload the module, hence no refcnt needed. */
4186+
/*
4187+
* Now, if we found one, we are running inside it now, hence
4188+
* we cannot unload the module, hence no refcnt needed.
4189+
*/
41894190
return e;
41904191
}
41914192

0 commit comments

Comments
 (0)