Skip to contentSkip to conversation

Factor out #ifdefs from kernel/spinlock.c to LOCK_CONTENDED_FLAGS

PATCH In review [email protected] 2 participants 3 messages Apr 2, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Factor out #ifdefs from kernel/spinlock.c to LOCK_CONTENDED_FLAGS

From: Robin Holt <[email protected]>

SGI has observed that on large systems, interrupts are not serviced for a long period of time when waiting for a rwlock. The following patch series re-enables irqs while waiting for the lock, resembling the code which is already there for spinlocks.

I only made the ia64 version, because the patch adds some overhead to the fast path. I assume there is currently no demand to have this for other architectures, because the systems are not so large. Of course, the possibility to implement raw_{read|write}_lock_flags for any architecture is still there.

This patch:

The new macro LOCK_CONTENDED_FLAGS expands to the correct implementation depending on the config options, so that IRQ's are re-enabled when possible, but they remain disabled if CONFIG_LOCKDEP is set.

---

 include/linux/lockdep.h |   17 +++++++++++++++++
 kernel/spinlock.c       |   12 ++----------
 2 files changed, 19 insertions(+), 10 deletions(-)
include/linux/lockdep.h renamed from include/linux/lockdep.h~factor-out-ifdefs-from-kernel-spinlockc-to-lock_contended_flags +17 -0
diff -puN include/linux/lockdep.h~factor-out-ifdefs-from-kernel-spinlockc-to-lock_contended_flags include/linux/lockdep.h
@@ -364,6 +364,23 @@ do {								\
 
 #endif /* CONFIG_LOCK_STAT */
 
+#ifdef CONFIG_LOCKDEP
+
+/*
+ * On lockdep we dont want the hand-coded irq-enable of
+ * _raw_*_lock_flags() code, because lockdep assumes
+ * that interrupts are not re-enabled during lock-acquire:
+ */
+#define LOCK_CONTENDED_FLAGS(_lock, try, lock, lockfl, flags) \
+	LOCK_CONTENDED((_lock), (try), (lock))
+
+#else /* CONFIG_LOCKDEP */
+
+#define LOCK_CONTENDED_FLAGS(_lock, try, lock, lockfl, flags) \
+	lockfl((_lock), (flags))
+
+#endif /* CONFIG_LOCKDEP */
+
 #ifdef CONFIG_GENERIC_HARDIRQS
 extern void early_init_irq_lock_class(void);
 #else
kernel/spinlock.c renamed from kernel/spinlock.c~factor-out-ifdefs-from-kernel-spinlockc-to-lock_contended_flags +2 -10
diff -puN kernel/spinlock.c~factor-out-ifdefs-from-kernel-spinlockc-to-lock_contended_flags kernel/spinlock.c
@@ -299,16 +299,8 @@ unsigned long __lockfunc _spin_lock_irqs
 	local_irq_save(flags);
 	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
+	LOCK_CONTENDED_FLAGS(lock, _raw_spin_trylock, _raw_spin_lock,
+				_raw_spin_lock_flags, &flags);
 	return flags;
 }
 EXPORT_SYMBOL(_spin_lock_irqsave_nested);

_

#1 lore raw

Isnt this an old patchset with a sizable -mm track record?

In that case i'd suggest sending this to Linus now. The only arch it affects non-trivially is ia64 and that bit has been acked by Tony.

And if it breaks lockdep everyone will notice quickly ;-)

Ingo

#2 lore raw
Quoted 2 lines · On Fri, 3 Apr 2009 00:30:56 +0200 Ingo Molnar <[email protected]> wrote:

Isnt this an old patchset with a sizable -mm track record?

It is.

Quoted 4 lines

In that case i'd suggest sending this to Linus now. The only arch it affects non-trivially is ia64 and that bit has been acked by Tony.

And if it breaks lockdep everyone will notice quickly ;-)

OK.