Skip to content

Commit 7d9dda6

Browse files
Sebastian Andrzej Siewiorpetrpavlu
authored andcommitted
module: Allow __module_address() to be called from RCU section.
mod_find() uses either the modules list to find a module or a tree lookup (CONFIG_MODULES_TREE_LOOKUP). The list and the tree can both be iterated under RCU assumption (as well as RCU-sched). Remove module_assert_mutex_or_preempt() from __module_address() and entirely since __module_address() is the last user. Update comments. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20250108090457.512198-13-bigeasy@linutronix.de Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
1 parent 2bee017 commit 7d9dda6

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

kernel/module/internal.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,6 @@ char *module_next_tag_pair(char *string, unsigned long *secsize);
124124
#define for_each_modinfo_entry(entry, info, name) \
125125
for (entry = get_modinfo(info, name); entry; entry = get_next_modinfo(info, name, entry))
126126

127-
static inline void module_assert_mutex_or_preempt(void)
128-
{
129-
#ifdef CONFIG_LOCKDEP
130-
if (unlikely(!debug_locks))
131-
return;
132-
133-
WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
134-
!lockdep_is_held(&module_mutex));
135-
#endif
136-
}
137-
138127
static inline unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
139128
{
140129
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS

kernel/module/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@ bool is_module_address(unsigned long addr)
37493749
* __module_address() - get the module which contains an address.
37503750
* @addr: the address.
37513751
*
3752-
* Must be called with preempt disabled or module mutex held so that
3752+
* Must be called within RCU read section or module mutex held so that
37533753
* module doesn't get freed during this.
37543754
*/
37553755
struct module *__module_address(unsigned long addr)
@@ -3767,8 +3767,6 @@ struct module *__module_address(unsigned long addr)
37673767
return NULL;
37683768

37693769
lookup:
3770-
module_assert_mutex_or_preempt();
3771-
37723770
mod = mod_find(addr, &mod_tree);
37733771
if (mod) {
37743772
BUG_ON(!within_module(addr, mod));

0 commit comments

Comments
 (0)