From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH] lockdep/selftest: Add tests for the mixed read-write case.
Date: Tue, 26 Mar 2013 17:14:03 +0100 [thread overview]
Message-ID: <5151C94B.7000407@canonical.com> (raw)
rlock_AA5 will pass unexpectedly, marking the test as FAILED and breaking lockdep for everyone.
The following test should make lockdep complain, but currently doesn't:
lock(a); readlock(x);
writelock(x); lock(a);
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
---
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 8a1a230..d0d2540 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -301,6 +301,51 @@ static void rsem_AA3(void)
RSL(X2); // this one should fail
}
+static void rlock_AA4(void)
+{
+ ML(A);
+ RL(X1);
+ RU(X1);
+ MU(A);
+
+ RL(X1);
+ ML(A);
+}
+
+static void rsem_AA4(void)
+{
+ ML(A);
+ RSL(X1);
+ RSU(X1);
+ MU(A);
+
+ RSL(X1);
+ ML(A);
+}
+
+static void rlock_AA5(void)
+{
+ ML(A);
+ RL(X1);
+ RU(X1);
+ MU(A);
+
+ WL(X1);
+ ML(A);
+}
+
+static void rsem_AA5(void)
+{
+ ML(A);
+ RSL(X1);
+ RSU(X1);
+ MU(A);
+
+ WSL(X1);
+ ML(A);
+}
+
+
/*
* ABBA deadlock:
*/
@@ -1661,6 +1706,21 @@ void locking_selftest(void)
dotest(rsem_AA3, FAILURE, LOCKTYPE_RWSEM);
printk("\n");
+ print_testname("mixed normal-read-lock");
+ printk(" |");
+ dotest(rlock_AA4, SUCCESS, LOCKTYPE_RWLOCK);
+ printk(" |");
+ dotest(rsem_AA4, FAILURE, LOCKTYPE_RWSEM);
+ printk("\n");
+
+ print_testname("mixed normal-r/w-lock");
+ printk(" |");
+ dotest(rlock_AA5, FAILURE, LOCKTYPE_RWLOCK);
+ printk(" |");
+ dotest(rsem_AA5, FAILURE, LOCKTYPE_RWSEM);
+ printk("\n");
+
+
printk(" --------------------------------------------------------------------------\n");
/*
next reply other threads:[~2013-03-26 16:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 16:14 Maarten Lankhorst [this message]
2013-03-26 16:20 ` [PATCH] lockdep/selftest: Add tests for the mixed read-write case Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5151C94B.7000407@canonical.com \
--to=maarten.lankhorst@canonical.com \
--cc=a.p.zijlstra@chello.nl \
--cc=daniel.vetter@ffwll.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox