Now that we support recursive read locks, a previously failed case:

 ----------------------------------------------------------------------------
                                  | spin |wlock |rlock |mutex | wsem | rsem |
   --------------------------------------------------------------------------
   mixed read-lock/lock-write ABBA:             |FAILED|             |  ok  |

can be added back. Now we have:

        Good, all 262 testcases passed!

See the case in: e91498589746065e3a ("Add mixed read-write ABBA tests")

It is worth noting that previously for the lock inversion deadlock checks,
the SUCCESS's of _rlock cases are only because the dependencies having
recursive-read locks (rlock) are not included in the graph.

Signed-off-by: Yuyang Du <duyuy...@gmail.com>
---
 lib/locking-selftest.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index a170554..7d14d87 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -462,12 +462,13 @@ static void rwsem_ABBA3(void)
 
 /*
  * ABBA deadlock:
+ *
+ * Should fail except for either A or B is rlock.
  */
-
 #define E()                                    \
                                                \
        LOCK_UNLOCK_2(A, B);                    \
-       LOCK_UNLOCK_2(B, A); /* fail */
+       LOCK_UNLOCK_2(B, A);
 
 /*
  * 6 testcases:
@@ -494,13 +495,15 @@ static void rwsem_ABBA3(void)
 
 /*
  * AB BC CA deadlock:
+ *
+ * Should fail except for rlock.
  */
 
 #define E()                                    \
                                                \
        LOCK_UNLOCK_2(A, B);                    \
        LOCK_UNLOCK_2(B, C);                    \
-       LOCK_UNLOCK_2(C, A); /* fail */
+       LOCK_UNLOCK_2(C, A);
 
 /*
  * 6 testcases:
@@ -527,13 +530,15 @@ static void rwsem_ABBA3(void)
 
 /*
  * AB CA BC deadlock:
+ *
+ * Should fail except for rlock.
  */
 
 #define E()                                    \
                                                \
        LOCK_UNLOCK_2(A, B);                    \
        LOCK_UNLOCK_2(C, A);                    \
-       LOCK_UNLOCK_2(B, C); /* fail */
+       LOCK_UNLOCK_2(B, C);
 
 /*
  * 6 testcases:
@@ -560,6 +565,8 @@ static void rwsem_ABBA3(void)
 
 /*
  * AB BC CD DA deadlock:
+ *
+ * Should fail except for rlock.
  */
 
 #define E()                                    \
@@ -567,7 +574,7 @@ static void rwsem_ABBA3(void)
        LOCK_UNLOCK_2(A, B);                    \
        LOCK_UNLOCK_2(B, C);                    \
        LOCK_UNLOCK_2(C, D);                    \
-       LOCK_UNLOCK_2(D, A); /* fail */
+       LOCK_UNLOCK_2(D, A);
 
 /*
  * 6 testcases:
@@ -594,13 +601,15 @@ static void rwsem_ABBA3(void)
 
 /*
  * AB CD BD DA deadlock:
+ *
+ * Should fail except for rlock.
  */
 #define E()                                    \
                                                \
        LOCK_UNLOCK_2(A, B);                    \
        LOCK_UNLOCK_2(C, D);                    \
        LOCK_UNLOCK_2(B, D);                    \
-       LOCK_UNLOCK_2(D, A); /* fail */
+       LOCK_UNLOCK_2(D, A);
 
 /*
  * 6 testcases:
@@ -627,13 +636,15 @@ static void rwsem_ABBA3(void)
 
 /*
  * AB CD BC DA deadlock:
+ *
+ * Should fail except for rlock.
  */
 #define E()                                    \
                                                \
        LOCK_UNLOCK_2(A, B);                    \
        LOCK_UNLOCK_2(C, D);                    \
        LOCK_UNLOCK_2(B, C);                    \
-       LOCK_UNLOCK_2(D, A); /* fail */
+       LOCK_UNLOCK_2(D, A);
 
 /*
  * 6 testcases:
@@ -2033,13 +2044,6 @@ void locking_selftest(void)
        print_testname("mixed read-lock/lock-write ABBA");
        pr_cont("             |");
        dotest(rlock_ABBA1, FAILURE, LOCKTYPE_RWLOCK);
-#ifdef CONFIG_PROVE_LOCKING
-       /*
-        * Lockdep does indeed fail here, but there's nothing we can do about
-        * that now.  Don't kill lockdep for it.
-        */
-       unexpected_testcase_failures--;
-#endif
 
        pr_cont("             |");
        dotest(rwsem_ABBA1, FAILURE, LOCKTYPE_RWSEM);
-- 
1.8.3.1

Reply via email to