Re: [PATCH for review] [109/145] x86_64: Convert modlist_lock to bea raw spinlock

From: Andrew Morton
Date: Sun Aug 13 2006 - 01:50:02 EST


On Thu, 10 Aug 2006 21:37:07 +0200 (CEST)
Andi Kleen <ak@xxxxxxx> wrote:

> 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.
>

It breaks the build on most architectures.

> ---
> kernel/module.c | 42 ++++++++++++++++++++++++++----------------
> 1 files changed, 26 insertions(+), 16 deletions(-)
>
> Index: linux/kernel/module.c
> ===================================================================
> --- linux.orig/kernel/module.c
> +++ linux/kernel/module.c
> @@ -59,7 +59,7 @@
> #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
>
> /* Protects module list */
> -static DEFINE_SPINLOCK(modlist_lock);
> +static raw_spinlock_t modlist_lock = __RAW_SPIN_LOCK_UNLOCKED;
>
> /* List of modules, protected by module_mutex AND modlist_lock */
> static DEFINE_MUTEX(module_mutex);
> @@ -751,11 +751,13 @@ void __symbol_put(const char *symbol)
> unsigned long flags;
> const unsigned long *crc;
>
> - spin_lock_irqsave(&modlist_lock, flags);
> + raw_local_save_flags(flags);
> + __raw_spin_lock(&modlist_lock);
> if (!__find_symbol(symbol, &owner, &crc, 1))
> BUG();
> module_put(owner);
> - spin_unlock_irqrestore(&modlist_lock, flags);
> + __raw_spin_unlock(&modlist_lock);
> + raw_local_irq_restore(flags);

That looks fairly hacky. Wouldn't it be better to implement
raw_spin_lock_irqsave()?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/