Convert modlist_lock to be a raw spinlock This is a preparationary patch for converting stacktrace over to the new dwarf2 unwinder. lockdep uses stacktrace and the new unwinder takes the modlist_lock so using a normal spinlock would cause a deadlock. Use a raw lock instead. Included hacky build fix by Andrew Morton. TBD Better solution for the raw irqsave spinlocks needed. Check with Ingo. Cc: mingo@elte.hu Signed-off-by: Andi Kleen --- kernel/module.c | 40 +++++++++++++++++++++++++++++----------- 1 files changed, 29 insertions(+), 11 deletions(-) Index: linux/kernel/module.c =================================================================== --- linux.orig/kernel/module.c +++ linux/kernel/module.c @@ -59,7 +59,25 @@ #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) /* Protects module list */ +#ifdef CONFIG_LOCKDEP +static raw_spinlock_t modlist_lock = __RAW_SPIN_LOCK_UNLOCKED; +#define raw_spin_lock_irqsave(lock, flags) \ + do { \ + raw_local_save_flags(flags); \ + __raw_spin_lock(lock); \ + } while (0) +#define raw_spin_unlock_irqrestore(lock, flags) \ + do { \ + __raw_spin_unlock(lock); \ + raw_local_irq_restore(flags); \ + } while (0) +#else static DEFINE_SPINLOCK(modlist_lock); +#define raw_spin_lock_irqsave(lock, flags) \ + spin_lock_irqsave(lock, flags) +#define raw_spin_unlock_irqrestore(lock, flags) \ + spin_unlock_irqrestore(lock, flags) +#endif /* List of modules, protected by module_mutex AND modlist_lock */ static DEFINE_MUTEX(module_mutex); @@ -751,11 +769,11 @@ void __symbol_put(const char *symbol) unsigned long flags; const unsigned long *crc; - spin_lock_irqsave(&modlist_lock, flags); + raw_spin_lock_irqsave(&modlist_lock, flags); if (!__find_symbol(symbol, &owner, &crc, 1)) BUG(); module_put(owner); - spin_unlock_irqrestore(&modlist_lock, flags); + raw_spin_unlock_irqrestore(&modlist_lock, flags); } EXPORT_SYMBOL(__symbol_put); @@ -1134,11 +1152,11 @@ void *__symbol_get(const char *symbol) unsigned long value, flags; const unsigned long *crc; - spin_lock_irqsave(&modlist_lock, flags); + raw_spin_lock_irqsave(&modlist_lock, flags); value = __find_symbol(symbol, &owner, &crc, 1); if (value && !strong_try_module_get(owner)) value = 0; - spin_unlock_irqrestore(&modlist_lock, flags); + raw_spin_unlock_irqrestore(&modlist_lock, flags); return (void *)value; } @@ -2141,7 +2159,7 @@ const struct exception_table_entry *sear const struct exception_table_entry *e = NULL; struct module *mod; - spin_lock_irqsave(&modlist_lock, flags); + raw_spin_lock_irqsave(&modlist_lock, flags); list_for_each_entry(mod, &modules, list) { if (mod->num_exentries == 0) continue; @@ -2152,7 +2170,7 @@ const struct exception_table_entry *sear if (e) break; } - spin_unlock_irqrestore(&modlist_lock, flags); + raw_spin_unlock_irqrestore(&modlist_lock, flags); /* Now, if we found one, we are running inside it now, hence we cannot unload the module, hence no refcnt needed. */ @@ -2167,16 +2185,16 @@ int is_module_address(unsigned long addr unsigned long flags; struct module *mod; - spin_lock_irqsave(&modlist_lock, flags); + raw_spin_lock_irqsave(&modlist_lock, flags); list_for_each_entry(mod, &modules, list) { if (within(addr, mod->module_core, mod->core_size)) { - spin_unlock_irqrestore(&modlist_lock, flags); + raw_spin_unlock_irqrestore(&modlist_lock, flags); return 1; } } - spin_unlock_irqrestore(&modlist_lock, flags); + raw_spin_unlock_irqrestore(&modlist_lock, flags); return 0; } @@ -2199,9 +2217,9 @@ struct module *module_text_address(unsig struct module *mod; unsigned long flags; - spin_lock_irqsave(&modlist_lock, flags); + raw_spin_lock_irqsave(&modlist_lock, flags); mod = __module_text_address(addr); - spin_unlock_irqrestore(&modlist_lock, flags); + raw_spin_unlock_irqrestore(&modlist_lock, flags); return mod; }