[PATCH 1/3] SELinux scalability - add spin_trylock_irq andspin_trylock_irqsave

From: James Morris
Date: Mon Nov 15 2004 - 14:51:57 EST


This patch from Kaigai Kohei <kaigai@xxxxxxxxxxxxx> adds irq and irqsave
trylock spinlock variants for use by the SELinux AVC RCU patch.

Please apply.

Signed-off-by: Kaigai Kohei <kaigai@xxxxxxxxxxxxx>
Signed-off-by: Stephen Smalley <sds@xxxxxxxxxxxxxx>
Signed-off-by: James Morris <jmorris@xxxxxxxxxx>

---

include/linux/spinlock.h | 14 ++++++++++++++
1 files changed, 14 insertions(+)

diff -purN -X dontdiff linux-2.6.10-rc2.p/include/linux/spinlock.h linux-2.6.10-rc2.w/include/linux/spinlock.h
--- linux-2.6.10-rc2.p/include/linux/spinlock.h 2004-11-15 13:18:55.000000000 -0500
+++ linux-2.6.10-rc2.w/include/linux/spinlock.h 2004-11-15 13:36:12.572317408 -0500
@@ -468,6 +468,20 @@ do { \

#define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock))

+#define spin_trylock_irq(lock) \
+({ \
+ local_irq_disable(); \
+ _spin_trylock(lock) ? \
+ 1 : ({local_irq_enable(); 0; }); \
+})
+
+#define spin_trylock_irqsave(lock, flags) \
+({ \
+ local_irq_save(flags); \
+ _spin_trylock(lock) ? \
+ 1 : ({local_irq_restore(flags); 0;}); \
+})
+
#ifdef CONFIG_LOCKMETER
extern void _metered_spin_lock (spinlock_t *lock);
extern void _metered_spin_unlock (spinlock_t *lock);



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