[PATCH 21/29] locking, tsx: Protect assert_spin_locked() with _xtest()

From: Andi Kleen
Date: Fri Mar 22 2013 - 21:27:13 EST


From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

lock_is_locked aborts with lock elision. Some code does a lot of lock asserts,
which causes a lot of aborts. Add a _xtest() here so that the checking is only
done when the lock is not elided. This always happens occasionally due to
fallbacks, so there is still enough assert coverage.

Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
---
include/linux/spinlock_api_smp.h | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
index cf9bf3b..cd9269b 100644
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -5,6 +5,8 @@
# error "please don't include this file directly"
#endif

+#include <linux/rtm.h>
+
/*
* include/linux/spinlock_api_smp.h
*
@@ -17,7 +19,10 @@

int in_lock_functions(unsigned long addr);

-#define assert_raw_spin_locked(x) BUG_ON(!raw_spin_is_locked(x))
+#define assert_raw_spin_locked(x) do { \
+ if (!_xtest()) \
+ BUG_ON(!raw_spin_is_locked(x)); \
+ } while (0)

void __lockfunc _raw_spin_lock(raw_spinlock_t *lock) __acquires(lock);
void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
--
1.7.7.6

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