> > > ==> LOCKDEP feature is evidently missing: > > > spin_lock_irq_nested(lock_ptr, lock_class) > > > > This rant is more lines than adding the API :-/ the reason for it not > > being there is simple, it wasn't needed up until now. > > I suspected that was the case, but for all I knew there was some > religious objection.
Does this look about right? Or, I suppose it could just call the _spin_lock_irqsave_nested() routine and discard the result. - Dave ========= CUT HERE Add new spin_lock_irq_nested() call, so that lockdep can work with the code which uses spin_*_irq() calls that don't save/restore flags. Signed-off-by: David Brownell <[EMAIL PROTECTED]> --- Against 2.6.25-rc3 include/linux/spinlock.h | 6 ++++++ include/linux/spinlock_api_smp.h | 2 ++ kernel/spinlock.c | 21 +++++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) --- a/include/linux/spinlock.h 2008-02-24 18:50:50.000000000 -0800 +++ b/include/linux/spinlock.h 2008-02-24 19:02:39.000000000 -0800 @@ -196,9 +196,13 @@ do { \ #define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) #ifdef CONFIG_DEBUG_LOCK_ALLOC +#define spin_lock_irq_nested(lock, subclass) \ + _spin_lock_irq_nested(lock, subclass) #define spin_lock_irqsave_nested(lock, flags, subclass) \ flags = _spin_lock_irqsave_nested(lock, subclass) #else +#define spin_lock_irq_nested(lock, subclass) \ + _spin_lock_irq(lock) #define spin_lock_irqsave_nested(lock, flags, subclass) \ flags = _spin_lock_irqsave(lock) #endif @@ -208,6 +212,8 @@ do { \ #define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags) #define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags) #define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags) +#define spin_lock_irq_nested(lock, subclass) \ + spin_lock_irq(lock) #define spin_lock_irqsave_nested(lock, flags, subclass) \ spin_lock_irqsave(lock, flags) --- a/include/linux/spinlock_api_smp.h 2008-02-24 18:50:50.000000000 -0800 +++ b/include/linux/spinlock_api_smp.h 2008-02-24 19:02:39.000000000 -0800 @@ -28,6 +28,8 @@ void __lockfunc _spin_lock_bh(spinlock_t void __lockfunc _read_lock_bh(rwlock_t *lock) __acquires(lock); void __lockfunc _write_lock_bh(rwlock_t *lock) __acquires(lock); void __lockfunc _spin_lock_irq(spinlock_t *lock) __acquires(lock); +void __lockfunc _spin_lock_irq_nested(spinlock_t *lock, int subclass) + __acquires(lock); void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(lock); void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(lock); unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) --- a/kernel/spinlock.c 2008-02-24 18:50:50.000000000 -0800 +++ b/kernel/spinlock.c 2008-02-24 19:02:39.000000000 -0800 @@ -290,8 +290,26 @@ void __lockfunc _spin_lock_nested(spinlo spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); } - EXPORT_SYMBOL(_spin_lock_nested); + +void __lockfunc _spin_lock_irq_nested(spinlock_t *lock, int subclass) +{ + local_irq_disable(); + preempt_disable(); + spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); + /* + * On lockdep we dont want the hand-coded irq-enable of + * _raw_spin_lock_flags() code, because lockdep assumes + * that interrupts are not re-enabled during lock-acquire: + */ +#ifdef CONFIG_LOCKDEP + LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock); +#else + _raw_spin_lock_flags(lock, &flags); +#endif +} +EXPORT_SYMBOL(_spin_lock_irq_nested); + unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass) { unsigned long flags; @@ -311,7 +329,6 @@ unsigned long __lockfunc _spin_lock_irqs #endif return flags; } - EXPORT_SYMBOL(_spin_lock_irqsave_nested); #endif -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/