lkml.org 
[lkml]   [2013]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 21/29] locking, tsx: Protect assert_spin_locked() with _xtest()
Date
From: Andi Kleen <ak@linux.intel.com>

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@linux.intel.com>
---
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


\
 
 \ /
  Last update: 2013-03-23 02:41    [W:0.156 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site