Adds a debug mode which allows to switch the brlock into
a big rwlock.
This can be used to verify we don't end up with a BKL kind
of lock with the current brlock implementation.

Signed-off-by: Sasha Levin <[email protected]>
---
 tools/kvm/include/kvm/brlock.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/include/kvm/brlock.h b/tools/kvm/include/kvm/brlock.h
index 2e2e0f8..bd1d882 100644
--- a/tools/kvm/include/kvm/brlock.h
+++ b/tools/kvm/include/kvm/brlock.h
@@ -17,9 +17,25 @@
 #define barrier()              __asm__ __volatile__("": : :"memory")
 #endif
 
+#ifdef KVM_BRLOCK_DEBUG
+
+#include "kvm/rwsem.h"
+
+DECLARE_RWSEM(brlock_sem);
+
+#define br_read_lock()         down_read(&brlock_sem);
+#define br_read_unlock()       up_read(&brlock_sem);
+
+#define br_write_lock()                down_write(&brlock_sem);
+#define br_write_unlock()      up_write(&brlock_sem);
+
+#else
+
 #define br_read_lock()         barrier()
 #define br_read_unlock()       barrier()
 
 #define br_write_lock()                kvm__pause()
 #define br_write_unlock()      kvm__continue()
 #endif
+
+#endif
-- 
1.7.5.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to