All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Chris Wilson <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: paulmck@linux.vnet.ibm.com, nhaehnle@gmail.com,
	peterz@infradead.org, dev@mblankhorst.nl,
	linux-kernel@vger.kernel.org, tglx@linutronix.de,
	torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org,
	akpm@linux-foundation.org, chris@chris-wilson.co.uk
Subject: [tip:locking/core] locking/ww_mutex: Add kselftests for ww_mutex AA deadlock detection
Date: Sat, 14 Jan 2017 04:54:00 -0800	[thread overview]
Message-ID: <tip-c22fb3807fd0a3bdd98c13c4d2190ab064e6c09d@git.kernel.org> (raw)
In-Reply-To: <20161201114711.28697-5-chris@chris-wilson.co.uk>

Commit-ID:  c22fb3807fd0a3bdd98c13c4d2190ab064e6c09d
Gitweb:     http://git.kernel.org/tip/c22fb3807fd0a3bdd98c13c4d2190ab064e6c09d
Author:     Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:07 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:15 +0100

locking/ww_mutex: Add kselftests for ww_mutex AA deadlock detection

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20161201114711.28697-5-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/locking/test-ww_mutex.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 472d5b1..835fa7a 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -118,6 +118,41 @@ static int test_mutex(void)
 	return 0;
 }
 
+static int test_aa(void)
+{
+	struct ww_mutex mutex;
+	struct ww_acquire_ctx ctx;
+	int ret;
+
+	ww_mutex_init(&mutex, &ww_class);
+	ww_acquire_init(&ctx, &ww_class);
+
+	ww_mutex_lock(&mutex, &ctx);
+
+	if (ww_mutex_trylock(&mutex))  {
+		pr_err("%s: trylocked itself!\n", __func__);
+		ww_mutex_unlock(&mutex);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = ww_mutex_lock(&mutex, &ctx);
+	if (ret != -EALREADY) {
+		pr_err("%s: missed deadlock for recursing, ret=%d\n",
+		       __func__, ret);
+		if (!ret)
+			ww_mutex_unlock(&mutex);
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = 0;
+out:
+	ww_mutex_unlock(&mutex);
+	ww_acquire_fini(&ctx);
+	return ret;
+}
+
 static int __init test_ww_mutex_init(void)
 {
 	int ret;
@@ -126,6 +161,10 @@ static int __init test_ww_mutex_init(void)
 	if (ret)
 		return ret;
 
+	ret = test_aa();
+	if (ret)
+		return ret;
+
 	return 0;
 }
 

  reply	other threads:[~2017-01-14 12:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
2016-12-01 11:47 ` [PATCH v2 1/8] locking: Fix compilation of __WW_MUTEX_INITIALIZER Chris Wilson
2016-12-16 14:50   ` Peter Zijlstra
2016-12-16 17:26     ` Chris Wilson
2017-01-14 12:52   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2016-12-01 11:47 ` [PATCH v2 2/8] locking: Add ww_mutex to locktorture test Chris Wilson
2017-01-14 12:52   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2016-12-01 11:47 ` [PATCH v2 3/8] locking: Begin kselftests for ww_mutex Chris Wilson
2017-01-14 12:53   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2016-12-01 11:47 ` [PATCH v2 4/8] locking: Add kselftests for ww_mutex AA deadlock detection Chris Wilson
2017-01-14 12:54   ` tip-bot for Chris Wilson [this message]
2016-12-01 11:47 ` [PATCH v2 5/8] locking: Add kselftests for ww_mutex ABBA " Chris Wilson
2017-01-14 12:54   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2016-12-01 11:47 ` [PATCH v2 6/8] locking: Add kselftests for resolving ww_mutex cyclic deadlocks Chris Wilson
2017-01-14 12:55   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2016-12-01 11:47 ` [PATCH v2 7/8] locking: Add kselftests for ww_mutex stress Chris Wilson
2017-01-14 12:55   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2017-01-19 20:13     ` Peter Zijlstra
2016-12-01 11:47 ` [PATCH v2 8/8] locking: Add ww_mutex to tools/testing/selftests Chris Wilson
2017-01-14 12:56   ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
2017-02-22 14:29 ` locking: Add kselftests for ww_mutex Geert Uytterhoeven

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=tip-c22fb3807fd0a3bdd98c13c4d2190ab064e6c09d@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=dev@mblankhorst.nl \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=nhaehnle@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.