public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/2] lockdep: add support for queued rwlock
@ 2014-08-06 17:22 Waiman Long
  2014-08-06 17:22 ` [PATCH v7 1/2] locking/lockdep: Restrict the use of recursive read_lock() with qrwlock Waiman Long
  2014-08-06 17:22 ` [PATCH v7 2/2] locking/selftest: Support queued rwlock Waiman Long
  0 siblings, 2 replies; 7+ messages in thread
From: Waiman Long @ 2014-08-06 17:22 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Maarten Lankhorst, Rik van Riel
  Cc: linux-kernel, Scott J Norton, Fengguang Wu, Waiman Long

v6->v7:
 - Add recursive read-lock with interrupt test in locking-selftest.c.

v5->v6:
 - Unconditionally disallow the use of recursive read-lock in process
   context.
 - Promote read state 3 to 2 when in interrupt context instead of
   doing additional check in check_deadlock().
 - Fix some comments in locking-selftest.c.

v4->v5:
 - Add patch 2 to update the locking selftest code to handle recursive
   read_lock correctly. Patch 1 has no change.

v3->v4:
 - Document the new read state and move the conditional compilation code
   to lockdep.h.

v2->v3:
 - Add a new read mode (3) for rwlock (used in
   lock_acquire_shared_cond_recursive()) to avoid conflict with other
   use cases of lock_acquire_shared_recursive().

v1->v2:
 - Use less conditional & make it easier to read

With the merging of qrwlock into 3.16, it was found that the btrfs
filesystem hanged readily. A fix was devised and merged into rc2 and
the use of recursive read_lock call was part of the problem.

This patch series addes code to the lockdep subsystem to catch this
kind of recursive read_lock calls in kernel code. It also updates
the locking selftest to handle recursive read_lock correctly so that
it won't complain about test failures.

Waiman Long (2):
  locking/lockdep: Restrict the use of recursive read_lock() with
    qrwlock
  locking/selftest: Support queued rwlock

 include/linux/lockdep.h  |   10 +++++++-
 kernel/locking/lockdep.c |    6 +++++
 lib/locking-selftest.c   |   56 ++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 64 insertions(+), 8 deletions(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH v5 2/2] locking-selftest: Support queue rwlock
@ 2014-06-26 17:39 Waiman Long
  2014-07-17 11:00 ` [tip:locking/core] locking/selftest: Support queued rwlock tip-bot for Waiman Long
  0 siblings, 1 reply; 7+ messages in thread
From: Waiman Long @ 2014-06-26 17:39 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Maarten Lankhorst, Rik van Riel
  Cc: linux-kernel, Scott J Norton, Fengguang Wu, Waiman Long

The queue rwlock does not support the use of recursive read-lock in
the process context. With changes in the lockdep code to check and
disallow recursive read-lock when queue rwlock is configured, it
is also necessary for the locking selftest to be updated to change
the process context recursive read locking results from SUCCESS to
FAILURE for queue rwlock.

Signed-off-by: Waiman Long <Waiman.Long@hp.com>
---
 lib/locking-selftest.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 872a15a..0ba8816 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -940,6 +940,16 @@ GENERATE_PERMUTATIONS_3_EVENTS(irq_read_recursion_soft)
 		init_rwsem(&rwsem_##x);		\
 	} while (0)
 
+/*
+ * If queue rwlock is used, recursive read-lock is not allowed in the
+ * process context. It is allowed in the interrupt context.
+ */
+#ifdef CONFIG_QUEUE_RWLOCK
+#define RRLOCK_RESULT	FAILURE
+#else
+#define RRLOCK_RESULT	SUCCESS
+#endif
+
 static void reset_locks(void)
 {
 	local_irq_disable();
@@ -1069,7 +1079,7 @@ static inline void print_testname(const char *testname)
 	print_testname(desc);					\
 	dotest(name##_spin, FAILURE, LOCKTYPE_SPIN);		\
 	dotest(name##_wlock, FAILURE, LOCKTYPE_RWLOCK);		\
-	dotest(name##_rlock, SUCCESS, LOCKTYPE_RWLOCK);		\
+	dotest(name##_rlock, RRLOCK_RESULT, LOCKTYPE_RWLOCK);	\
 	dotest(name##_mutex, FAILURE, LOCKTYPE_MUTEX);		\
 	dotest(name##_wsem, FAILURE, LOCKTYPE_RWSEM);		\
 	dotest(name##_rsem, FAILURE, LOCKTYPE_RWSEM);		\
@@ -1830,14 +1840,14 @@ void locking_selftest(void)
 	printk("  --------------------------------------------------------------------------\n");
 	print_testname("recursive read-lock");
 	printk("             |");
-	dotest(rlock_AA1, SUCCESS, LOCKTYPE_RWLOCK);
+	dotest(rlock_AA1, RRLOCK_RESULT, LOCKTYPE_RWLOCK);
 	printk("             |");
 	dotest(rsem_AA1, FAILURE, LOCKTYPE_RWSEM);
 	printk("\n");
 
 	print_testname("recursive read-lock #2");
 	printk("             |");
-	dotest(rlock_AA1B, SUCCESS, LOCKTYPE_RWLOCK);
+	dotest(rlock_AA1B, RRLOCK_RESULT, LOCKTYPE_RWLOCK);
 	printk("             |");
 	dotest(rsem_AA1B, FAILURE, LOCKTYPE_RWSEM);
 	printk("\n");
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-13 10:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-06 17:22 [PATCH v7 0/2] lockdep: add support for queued rwlock Waiman Long
2014-08-06 17:22 ` [PATCH v7 1/2] locking/lockdep: Restrict the use of recursive read_lock() with qrwlock Waiman Long
2014-08-13 10:56   ` [tip:locking/core] " tip-bot for Waiman Long
2014-08-06 17:22 ` [PATCH v7 2/2] locking/selftest: Support queued rwlock Waiman Long
2014-08-07  9:58   ` Peter Zijlstra
2014-08-13 10:57   ` [tip:locking/core] " tip-bot for Waiman Long
  -- strict thread matches above, loose matches on Subject: below --
2014-06-26 17:39 [PATCH v5 2/2] locking-selftest: Support queue rwlock Waiman Long
2014-07-17 11:00 ` [tip:locking/core] locking/selftest: Support queued rwlock tip-bot for Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox