Re: [tip:locking/core] locking/lockdep/selftests: Add mixed read-write ABBA tests
From: Peter Zijlstra
Date: Mon Aug 28 2017 - 08:42:56 EST
On Fri, Aug 25, 2017 at 04:55:48AM -0700, tip-bot for Peter Zijlstra wrote:
> Commit-ID: e91498589746065e3ae95d9a00b068e525eec34f
> Gitweb: http://git.kernel.org/tip/e91498589746065e3ae95d9a00b068e525eec34f
> Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> AuthorDate: Wed, 23 Aug 2017 13:13:11 +0200
> Committer: Ingo Molnar <mingo@xxxxxxxxxx>
> 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] --------------------------------------------------------------------------
>
> [ 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(+)
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 3c7151a6cd98..cd0b5c964bd0 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -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);