Skip to contentSkip to conversation

locking/lockdep/selftests: Add mixed read-write ABBA tests

tip:locking/core Peter Zijlstra 2 participants 2 messages Aug 28, 2017 – Aug 29, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Peter Zijlstra

author maintainer
#1 lore raw
Quoted 17 lines · tip-bot for Peter Zijlstra
Commit-ID:  e91498589746065e3ae95d9a00b068e525eec34f
Gitweb:     http://git.kernel.org/tip/e91498589746065e3ae95d9a00b068e525eec34f
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 23 Aug 2017 13:13:11 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 25 Aug 2017 11:06:31 +0200

locking/lockdep/selftests: Add mixed read-write ABBA tests

Currently lockdep has limited support for recursive readers, add a few mixed read-write ABBA selftests to show the extend of these limitations.

  [    0.000000] ----------------------------------------------------------------------------
  [    0.000000]                                  | spin |wlock |rlock |mutex | wsem | rsem |
  [    0.000000]   --------------------------------------------------------------------------
Quoted 7 lines
  [    0.000000]   mixed read-lock/lock-write ABBA:             |FAILED|             |  ok  |
  [    0.000000]    mixed read-lock/lock-read ABBA:             |  ok  |             |  ok  |
  [    0.000000]  mixed write-lock/lock-write ABBA:             |  ok  |             |  ok  |

This clearly illustrates the case where lockdep fails to find a deadlock.

I'm an idiot... this patch kills lockdep.

We want something like so on top.

---
 lib/locking-selftest.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/locking-selftest.c +6 -0
index 3c7151a6cd98..cd0b5c964bd0 100644
@@ -2031,6 +2031,12 @@ void locking_selftest(void)
 	print_testname("mixed read-lock/lock-write ABBA");
 	pr_cont("             |");
 	dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK);
+	/*
+	 * Lockdep does indeed fail here, but there's nothing we can do about
+	 * that now.  Don't kill lockdep for it.
+	 */
+	unexpected_testcase_failures--;
+
 	pr_cont("             |");
 	dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM);
 
#2 lore raw

[tip:locking/core] locking/lockdep/selftests: Fix mixed read-write ABBA tests

locking/lockdep/selftests: Fix mixed read-write ABBA tests
Commit-ID:  d82fed75294229abc9d757f08a4817febae6c4f4
Gitweb:     http://git.kernel.org/tip/d82fed75294229abc9d757f08a4817febae6c4f4
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Mon, 28 Aug 2017 14:42:45 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 29 Aug 2017 15:15:17 +0200

locking/lockdep/selftests: Fix mixed read-write ABBA tests

Commit:

e91498589746 ("locking/lockdep/selftests: Add mixed read-write ABBA tests")

adds an explicit FAILURE to the locking selftest but overlooked the fact that this kills lockdep. Fudge the test to avoid this.

---
 lib/locking-selftest.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/locking-selftest.c +6 -0
index 3c7151a..cd0b5c9 100644
@@ -2031,6 +2031,12 @@ void locking_selftest(void)
 	print_testname("mixed read-lock/lock-write ABBA");
 	pr_cont("             |");
 	dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK);
+	/*
+	 * Lockdep does indeed fail here, but there's nothing we can do about
+	 * that now.  Don't kill lockdep for it.
+	 */
+	unexpected_testcase_failures--;
+
 	pr_cont("             |");
 	dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM);