* locking: Add kselftests for ww_mutex
@ 2016-12-01 11:47 Chris Wilson
2016-12-01 11:47 ` [PATCH v2 1/8] locking: Fix compilation of __WW_MUTEX_INITIALIZER Chris Wilson
` (8 more replies)
0 siblings, 9 replies; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Nicolai Hähnle was looking into a deadlock within ww_mutexes (that has
been fixed by Peter's mutex rewrite) and to support his changes, I
thought it was be useful to have a small validation suite for ww_mutex.
-Chris
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 1/8] locking: Fix compilation of __WW_MUTEX_INITIALIZER
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
@ 2016-12-01 11:47 ` Chris Wilson
2016-12-16 14:50 ` Peter Zijlstra
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
` (7 subsequent siblings)
8 siblings, 2 replies; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel; +Cc: Chris Wilson, Maarten Lankhorst, Peter Zijlstra, Ingo Molnar
>From conflicting macro parameters, passing the wrong name to
__MUTEX_INITIALIZER and a stray '\', #define __WW_MUTEX_INITIALIZER was
very unhappy.
One unnecessary change was to choose to pass &ww_class instead of
implicitly taking the address of the class within the macro.
Fixes: 1b375dc30710 ("mutex: Move ww_mutex definitions to ww_mutex.h")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@redhat.com>
---
include/linux/ww_mutex.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h
index 2bb5deb0012e..941df8c8b90e 100644
--- a/include/linux/ww_mutex.h
+++ b/include/linux/ww_mutex.h
@@ -51,10 +51,10 @@ struct ww_mutex {
};
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class) \
- , .ww_class = &ww_class
+# define __WW_CLASS_MUTEX_INITIALIZER(lockname, class) \
+ , .ww_class = class
#else
-# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class)
+# define __WW_CLASS_MUTEX_INITIALIZER(lockname, class)
#endif
#define __WW_CLASS_INITIALIZER(ww_class) \
@@ -63,7 +63,7 @@ struct ww_mutex {
, .mutex_name = #ww_class "_mutex" }
#define __WW_MUTEX_INITIALIZER(lockname, class) \
- { .base = { \__MUTEX_INITIALIZER(lockname) } \
+ { .base = __MUTEX_INITIALIZER(lockname.base) \
__WW_CLASS_MUTEX_INITIALIZER(lockname, class) }
#define DEFINE_WW_CLASS(classname) \
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 2/8] locking: Add ww_mutex to locktorture test
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-01 11:47 ` 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
` (6 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Cc: Chris Wilson, Peter Zijlstra, Ingo Molnar, Maarten Lankhorst,
Nicolai Hähnle
Although ww_mutexes degenerate into mutexes, it would be useful to
torture the deadlock handling between multiple ww_mutexes in addition to
torturing the regular mutexes.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
---
kernel/locking/locktorture.c | 73 ++++++++++++++++++++++
.../selftests/rcutorture/configs/lock/CFLIST | 1 +
.../selftests/rcutorture/configs/lock/LOCK07 | 6 ++
.../selftests/rcutorture/configs/lock/LOCK07.boot | 1 +
4 files changed, 81 insertions(+)
create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK07
create mode 100644 tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index f8c5af52a131..9bffedd82884 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -372,6 +372,78 @@ static struct lock_torture_ops mutex_lock_ops = {
.name = "mutex_lock"
};
+#include <linux/ww_mutex.h>
+static DEFINE_WW_CLASS(torture_ww_class);
+static DEFINE_WW_MUTEX(torture_ww_mutex_0, &torture_ww_class);
+static DEFINE_WW_MUTEX(torture_ww_mutex_1, &torture_ww_class);
+static DEFINE_WW_MUTEX(torture_ww_mutex_2, &torture_ww_class);
+
+static int torture_ww_mutex_lock(void)
+__acquires(torture_ww_mutex_0)
+__acquires(torture_ww_mutex_1)
+__acquires(torture_ww_mutex_2)
+{
+ LIST_HEAD(list);
+ struct reorder_lock {
+ struct list_head link;
+ struct ww_mutex *lock;
+ } locks[3], *ll, *ln;
+ struct ww_acquire_ctx ctx;
+
+ locks[0].lock = &torture_ww_mutex_0;
+ list_add(&locks[0].link, &list);
+
+ locks[1].lock = &torture_ww_mutex_1;
+ list_add(&locks[1].link, &list);
+
+ locks[2].lock = &torture_ww_mutex_2;
+ list_add(&locks[2].link, &list);
+
+ ww_acquire_init(&ctx, &torture_ww_class);
+
+ list_for_each_entry(ll, &list, link) {
+ int err;
+
+ err = ww_mutex_lock(ll->lock, &ctx);
+ if (!err)
+ continue;
+
+ ln = ll;
+ list_for_each_entry_continue_reverse(ln, &list, link)
+ ww_mutex_unlock(ln->lock);
+
+ if (err != -EDEADLK)
+ return err;
+
+ ww_mutex_lock_slow(ll->lock, &ctx);
+ list_move(&ll->link, &list);
+ }
+
+ ww_acquire_fini(&ctx);
+ return 0;
+}
+
+static void torture_ww_mutex_unlock(void)
+__releases(torture_ww_mutex_0)
+__releases(torture_ww_mutex_1)
+__releases(torture_ww_mutex_2)
+{
+ ww_mutex_unlock(&torture_ww_mutex_0);
+ ww_mutex_unlock(&torture_ww_mutex_1);
+ ww_mutex_unlock(&torture_ww_mutex_2);
+}
+
+static struct lock_torture_ops ww_mutex_lock_ops = {
+ .writelock = torture_ww_mutex_lock,
+ .write_delay = torture_mutex_delay,
+ .task_boost = torture_boost_dummy,
+ .writeunlock = torture_ww_mutex_unlock,
+ .readlock = NULL,
+ .read_delay = NULL,
+ .readunlock = NULL,
+ .name = "ww_mutex_lock"
+};
+
#ifdef CONFIG_RT_MUTEXES
static DEFINE_RT_MUTEX(torture_rtmutex);
@@ -793,6 +865,7 @@ static int __init lock_torture_init(void)
&spin_lock_ops, &spin_lock_irq_ops,
&rw_lock_ops, &rw_lock_irq_ops,
&mutex_lock_ops,
+ &ww_mutex_lock_ops,
#ifdef CONFIG_RT_MUTEXES
&rtmutex_lock_ops,
#endif
diff --git a/tools/testing/selftests/rcutorture/configs/lock/CFLIST b/tools/testing/selftests/rcutorture/configs/lock/CFLIST
index b9611c523723..41bae5824339 100644
--- a/tools/testing/selftests/rcutorture/configs/lock/CFLIST
+++ b/tools/testing/selftests/rcutorture/configs/lock/CFLIST
@@ -4,3 +4,4 @@ LOCK03
LOCK04
LOCK05
LOCK06
+LOCK07
diff --git a/tools/testing/selftests/rcutorture/configs/lock/LOCK07 b/tools/testing/selftests/rcutorture/configs/lock/LOCK07
new file mode 100644
index 000000000000..1d1da1477fc3
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/lock/LOCK07
@@ -0,0 +1,6 @@
+CONFIG_SMP=y
+CONFIG_NR_CPUS=4
+CONFIG_HOTPLUG_CPU=y
+CONFIG_PREEMPT_NONE=n
+CONFIG_PREEMPT_VOLUNTARY=n
+CONFIG_PREEMPT=y
diff --git a/tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot b/tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot
new file mode 100644
index 000000000000..97dadd1a9e45
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot
@@ -0,0 +1 @@
+locktorture.torture_type=ww_mutex_lock
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 3/8] locking: Begin kselftests for ww_mutex
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-01 11:47 ` [PATCH v2 2/8] locking: Add ww_mutex to locktorture test Chris Wilson
@ 2016-12-01 11:47 ` 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
` (5 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Cc: Chris Wilson, Peter Zijlstra, Ingo Molnar, Maarten Lankhorst,
Nicolai Hähnle
v2: Add a couple more variations for degenerate ww_mutex, decrease
timeouts
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
---
kernel/locking/Makefile | 1 +
kernel/locking/test-ww_mutex.c | 140 +++++++++++++++++++++++++++++++++++++++++
lib/Kconfig.debug | 12 ++++
3 files changed, 153 insertions(+)
create mode 100644 kernel/locking/test-ww_mutex.c
diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile
index 6f88e352cd4f..760158d9d98d 100644
--- a/kernel/locking/Makefile
+++ b/kernel/locking/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem-xadd.o
obj-$(CONFIG_QUEUED_RWLOCKS) += qrwlock.o
obj-$(CONFIG_LOCK_TORTURE_TEST) += locktorture.o
+obj-$(CONFIG_WW_MUTEX_SELFTEST) += test-ww_mutex.o
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
new file mode 100644
index 000000000000..472d5b1f303f
--- /dev/null
+++ b/kernel/locking/test-ww_mutex.c
@@ -0,0 +1,140 @@
+/*
+ * Module-based API test facility for ww_mutexes
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+#include <linux/kernel.h>
+
+#include <linux/completion.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+#include <linux/ww_mutex.h>
+
+static DEFINE_WW_CLASS(ww_class);
+
+struct test_mutex {
+ struct work_struct work;
+ struct ww_mutex mutex;
+ struct completion ready, go, done;
+ unsigned int flags;
+};
+
+#define TEST_MTX_SPIN BIT(0)
+#define TEST_MTX_TRY BIT(1)
+#define TEST_MTX_CTX BIT(2)
+#define __TEST_MTX_LAST BIT(3)
+
+static void test_mutex_work(struct work_struct *work)
+{
+ struct test_mutex *mtx = container_of(work, typeof(*mtx), work);
+
+ complete(&mtx->ready);
+ wait_for_completion(&mtx->go);
+
+ if (mtx->flags & TEST_MTX_TRY) {
+ while (!ww_mutex_trylock(&mtx->mutex))
+ cpu_relax();
+ } else {
+ ww_mutex_lock(&mtx->mutex, NULL);
+ }
+ complete(&mtx->done);
+ ww_mutex_unlock(&mtx->mutex);
+}
+
+static int __test_mutex(unsigned int flags)
+{
+#define TIMEOUT (HZ / 16)
+ struct test_mutex mtx;
+ struct ww_acquire_ctx ctx;
+ int ret;
+
+ ww_mutex_init(&mtx.mutex, &ww_class);
+ ww_acquire_init(&ctx, &ww_class);
+
+ INIT_WORK_ONSTACK(&mtx.work, test_mutex_work);
+ init_completion(&mtx.ready);
+ init_completion(&mtx.go);
+ init_completion(&mtx.done);
+ mtx.flags = flags;
+
+ schedule_work(&mtx.work);
+
+ wait_for_completion(&mtx.ready);
+ ww_mutex_lock(&mtx.mutex, (flags & TEST_MTX_CTX) ? &ctx : NULL);
+ complete(&mtx.go);
+ if (flags & TEST_MTX_SPIN) {
+ unsigned long timeout = jiffies + TIMEOUT;
+
+ ret = 0;
+ do {
+ if (completion_done(&mtx.done)) {
+ ret = -EINVAL;
+ break;
+ }
+ cpu_relax();
+ } while (time_before(jiffies, timeout));
+ } else {
+ ret = wait_for_completion_timeout(&mtx.done, TIMEOUT);
+ }
+ ww_mutex_unlock(&mtx.mutex);
+ ww_acquire_fini(&ctx);
+
+ if (ret) {
+ pr_err("%s(flags=%x): mutual exclusion failure\n",
+ __func__, flags);
+ ret = -EINVAL;
+ }
+
+ flush_work(&mtx.work);
+ destroy_work_on_stack(&mtx.work);
+ return ret;
+#undef TIMEOUT
+}
+
+static int test_mutex(void)
+{
+ int ret;
+ int i;
+
+ for (i = 0; i < __TEST_MTX_LAST; i++) {
+ ret = __test_mutex(i);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int __init test_ww_mutex_init(void)
+{
+ int ret;
+
+ ret = test_mutex();
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static void __exit test_ww_mutex_exit(void)
+{
+}
+
+module_init(test_ww_mutex_init);
+module_exit(test_ww_mutex_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Intel Corporation");
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a6c8db1d62f6..cf8f3e942b46 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1161,6 +1161,18 @@ config LOCK_TORTURE_TEST
Say M if you want these torture tests to build as a module.
Say N if you are unsure.
+config WW_MUTEX_SELFTEST
+ tristate "Wait/wound mutex selftests"
+ help
+ This option provides a kernel module that runs tests on the
+ on the struct ww_mutex locking API.
+
+ It is recommended to enable DEBUG_WW_MUTEX_SLOWPATH in conjunction
+ with this test harness.
+
+ Say M if you want these self tests to build as a module.
+ Say N if you are unsure.
+
endmenu # lock debugging
config TRACE_IRQFLAGS
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 4/8] locking: Add kselftests for ww_mutex AA deadlock detection
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
` (2 preceding siblings ...)
2016-12-01 11:47 ` [PATCH v2 3/8] locking: Begin kselftests for ww_mutex Chris Wilson
@ 2016-12-01 11:47 ` 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 5/8] locking: Add kselftests for ww_mutex ABBA " Chris Wilson
` (4 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Cc: Chris Wilson, Peter Zijlstra, Ingo Molnar, Maarten Lankhorst,
Nicolai Hähnle
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
---
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 472d5b1f303f..835fa7a1036e 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;
}
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 5/8] locking: Add kselftests for ww_mutex ABBA deadlock detection
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
` (3 preceding siblings ...)
2016-12-01 11:47 ` [PATCH v2 4/8] locking: Add kselftests for ww_mutex AA deadlock detection Chris Wilson
@ 2016-12-01 11:47 ` 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
` (3 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Cc: Chris Wilson, Peter Zijlstra, Ingo Molnar, Maarten Lankhorst,
Nicolai Hähnle
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
---
kernel/locking/test-ww_mutex.c | 98 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 835fa7a1036e..5a643ba2b020 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -153,6 +153,96 @@ static int test_aa(void)
return ret;
}
+struct test_abba {
+ struct work_struct work;
+ struct ww_mutex a_mutex;
+ struct ww_mutex b_mutex;
+ struct completion a_ready;
+ struct completion b_ready;
+ bool resolve;
+ int result;
+};
+
+static void test_abba_work(struct work_struct *work)
+{
+ struct test_abba *abba = container_of(work, typeof(*abba), work);
+ struct ww_acquire_ctx ctx;
+ int err;
+
+ ww_acquire_init(&ctx, &ww_class);
+ ww_mutex_lock(&abba->b_mutex, &ctx);
+
+ complete(&abba->b_ready);
+ wait_for_completion(&abba->a_ready);
+
+ err = ww_mutex_lock(&abba->a_mutex, &ctx);
+ if (abba->resolve && err == -EDEADLK) {
+ ww_mutex_unlock(&abba->b_mutex);
+ ww_mutex_lock_slow(&abba->a_mutex, &ctx);
+ err = ww_mutex_lock(&abba->b_mutex, &ctx);
+ }
+
+ if (!err)
+ ww_mutex_unlock(&abba->a_mutex);
+ ww_mutex_unlock(&abba->b_mutex);
+ ww_acquire_fini(&ctx);
+
+ abba->result = err;
+}
+
+static int test_abba(bool resolve)
+{
+ struct test_abba abba;
+ struct ww_acquire_ctx ctx;
+ int err, ret;
+
+ ww_mutex_init(&abba.a_mutex, &ww_class);
+ ww_mutex_init(&abba.b_mutex, &ww_class);
+ INIT_WORK_ONSTACK(&abba.work, test_abba_work);
+ init_completion(&abba.a_ready);
+ init_completion(&abba.b_ready);
+ abba.resolve = resolve;
+
+ schedule_work(&abba.work);
+
+ ww_acquire_init(&ctx, &ww_class);
+ ww_mutex_lock(&abba.a_mutex, &ctx);
+
+ complete(&abba.a_ready);
+ wait_for_completion(&abba.b_ready);
+
+ err = ww_mutex_lock(&abba.b_mutex, &ctx);
+ if (resolve && err == -EDEADLK) {
+ ww_mutex_unlock(&abba.a_mutex);
+ ww_mutex_lock_slow(&abba.b_mutex, &ctx);
+ err = ww_mutex_lock(&abba.a_mutex, &ctx);
+ }
+
+ if (!err)
+ ww_mutex_unlock(&abba.b_mutex);
+ ww_mutex_unlock(&abba.a_mutex);
+ ww_acquire_fini(&ctx);
+
+ flush_work(&abba.work);
+ destroy_work_on_stack(&abba.work);
+
+ ret = 0;
+ if (resolve) {
+ if (err || abba.result) {
+ pr_err("%s: failed to resolve ABBA deadlock, A err=%d, B err=%d\n",
+ __func__, err, abba.result);
+ ret = -EINVAL;
+ }
+ } else {
+ if (err != -EDEADLK && abba.result != -EDEADLK) {
+ pr_err("%s: missed ABBA deadlock, A err=%d, B err=%d\n",
+ __func__, err, abba.result);
+ ret = -EINVAL;
+ }
+ }
+ return ret;
+}
+
static int __init test_ww_mutex_init(void)
{
int ret;
@@ -165,6 +255,14 @@ static int __init test_ww_mutex_init(void)
if (ret)
return ret;
+ ret = test_abba(false);
+ if (ret)
+ return ret;
+
+ ret = test_abba(true);
+ if (ret)
+ return ret;
+
return 0;
}
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 6/8] locking: Add kselftests for resolving ww_mutex cyclic deadlocks
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
` (4 preceding siblings ...)
2016-12-01 11:47 ` [PATCH v2 5/8] locking: Add kselftests for ww_mutex ABBA " Chris Wilson
@ 2016-12-01 11:47 ` 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
` (2 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Cc: Chris Wilson, Peter Zijlstra, Ingo Molnar, Maarten Lankhorst,
Nicolai Hähnle
Check that ww_mutexes can detect cyclic deadlocks (generalised ABBA
cycles) and resolve them by lock reordering.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
---
kernel/locking/test-ww_mutex.c | 115 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 5a643ba2b020..84da738e57d1 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -21,9 +21,11 @@
#include <linux/completion.h>
#include <linux/kthread.h>
#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/ww_mutex.h>
static DEFINE_WW_CLASS(ww_class);
+struct workqueue_struct *wq;
struct test_mutex {
struct work_struct work;
@@ -243,10 +245,118 @@ static int test_abba(bool resolve)
return ret;
}
+struct test_cycle {
+ struct work_struct work;
+ struct ww_mutex a_mutex;
+ struct ww_mutex *b_mutex;
+ struct completion *a_signal;
+ struct completion b_signal;
+ int result;
+};
+
+static void test_cycle_work(struct work_struct *work)
+{
+ struct test_cycle *cycle = container_of(work, typeof(*cycle), work);
+ struct ww_acquire_ctx ctx;
+ int err;
+
+ ww_acquire_init(&ctx, &ww_class);
+ ww_mutex_lock(&cycle->a_mutex, &ctx);
+
+ complete(cycle->a_signal);
+ wait_for_completion(&cycle->b_signal);
+
+ err = ww_mutex_lock(cycle->b_mutex, &ctx);
+ if (err == -EDEADLK) {
+ ww_mutex_unlock(&cycle->a_mutex);
+ ww_mutex_lock_slow(cycle->b_mutex, &ctx);
+ err = ww_mutex_lock(&cycle->a_mutex, &ctx);
+ }
+
+ if (!err)
+ ww_mutex_unlock(cycle->b_mutex);
+ ww_mutex_unlock(&cycle->a_mutex);
+ ww_acquire_fini(&ctx);
+
+ cycle->result = err;
+}
+
+static int __test_cycle(unsigned int nthreads)
+{
+ struct test_cycle *cycles;
+ unsigned int n, last = nthreads - 1;
+ int ret;
+
+ cycles = kmalloc_array(nthreads, sizeof(*cycles), GFP_KERNEL);
+ if (!cycles)
+ return -ENOMEM;
+
+ for (n = 0; n < nthreads; n++) {
+ struct test_cycle *cycle = &cycles[n];
+
+ ww_mutex_init(&cycle->a_mutex, &ww_class);
+ if (n == last)
+ cycle->b_mutex = &cycles[0].a_mutex;
+ else
+ cycle->b_mutex = &cycles[n + 1].a_mutex;
+
+ if (n == 0)
+ cycle->a_signal = &cycles[last].b_signal;
+ else
+ cycle->a_signal = &cycles[n - 1].b_signal;
+ init_completion(&cycle->b_signal);
+
+ INIT_WORK(&cycle->work, test_cycle_work);
+ cycle->result = 0;
+ }
+
+ for (n = 0; n < nthreads; n++)
+ queue_work(wq, &cycles[n].work);
+
+ flush_workqueue(wq);
+
+ ret = 0;
+ for (n = 0; n < nthreads; n++) {
+ struct test_cycle *cycle = &cycles[n];
+
+ if (!cycle->result)
+ continue;
+
+ pr_err("cylic deadlock not resolved, ret[%d/%d] = %d\n",
+ n, nthreads, cycle->result);
+ ret = -EINVAL;
+ break;
+ }
+
+ for (n = 0; n < nthreads; n++)
+ ww_mutex_destroy(&cycles[n].a_mutex);
+ kfree(cycles);
+ return ret;
+}
+
+static int test_cycle(unsigned int ncpus)
+{
+ unsigned int n;
+ int ret;
+
+ for (n = 2; n <= ncpus + 1; n++) {
+ ret = __test_cycle(n);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int __init test_ww_mutex_init(void)
{
+ int ncpus = num_online_cpus();
int ret;
+ wq = alloc_workqueue("test-ww_mutex", WQ_UNBOUND, 0);
+ if (!wq)
+ return -ENOMEM;
+
ret = test_mutex();
if (ret)
return ret;
@@ -263,11 +373,16 @@ static int __init test_ww_mutex_init(void)
if (ret)
return ret;
+ ret = test_cycle(ncpus);
+ if (ret)
+ return ret;
+
return 0;
}
static void __exit test_ww_mutex_exit(void)
{
+ destroy_workqueue(wq);
}
module_init(test_ww_mutex_init);
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 7/8] locking: Add kselftests for ww_mutex stress
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
` (5 preceding siblings ...)
2016-12-01 11:47 ` [PATCH v2 6/8] locking: Add kselftests for resolving ww_mutex cyclic deadlocks Chris Wilson
@ 2016-12-01 11:47 ` 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 8/8] locking: Add ww_mutex to tools/testing/selftests Chris Wilson
2017-02-22 14:29 ` locking: Add kselftests for ww_mutex Geert Uytterhoeven
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel
Cc: Chris Wilson, Peter Zijlstra, Ingo Molnar, Maarten Lankhorst,
Nicolai Hähnle
v2: Use both inorder and reorder locking strategies
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Maarten Lankhorst <dev@mblankhorst.nl>
Cc: Nicolai Hähnle <nhaehnle@gmail.com>
---
kernel/locking/test-ww_mutex.c | 254 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 254 insertions(+)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 84da738e57d1..da6c9a34f62f 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -19,8 +19,10 @@
#include <linux/kernel.h>
#include <linux/completion.h>
+#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/module.h>
+#include <linux/random.h>
#include <linux/slab.h>
#include <linux/ww_mutex.h>
@@ -348,6 +350,246 @@ static int test_cycle(unsigned int ncpus)
return 0;
}
+struct stress {
+ struct work_struct work;
+ struct ww_mutex *locks;
+ int nlocks;
+ int nloops;
+};
+
+static int *get_random_order(int count)
+{
+ int *order;
+ int n, r, tmp;
+
+ order = kmalloc_array(count, sizeof(*order), GFP_TEMPORARY);
+ if (!order)
+ return order;
+
+ for (n = 0; n < count; n++)
+ order[n] = n;
+
+ for (n = count - 1; n > 1; n--) {
+ r = get_random_int() % (n + 1);
+ if (r != n) {
+ tmp = order[n];
+ order[n] = order[r];
+ order[r] = tmp;
+ }
+ }
+
+ return order;
+}
+
+static void dummy_load(struct stress *stress)
+{
+ usleep_range(1000, 2000);
+}
+
+static void stress_inorder_work(struct work_struct *work)
+{
+ struct stress *stress = container_of(work, typeof(*stress), work);
+ const int nlocks = stress->nlocks;
+ struct ww_mutex *locks = stress->locks;
+ struct ww_acquire_ctx ctx;
+ int *order;
+
+ order = get_random_order(nlocks);
+ if (!order)
+ return;
+
+ ww_acquire_init(&ctx, &ww_class);
+
+ do {
+ int contended = -1;
+ int n, err;
+
+retry:
+ err = 0;
+ for (n = 0; n < nlocks; n++) {
+ if (n == contended)
+ continue;
+
+ err = ww_mutex_lock(&locks[order[n]], &ctx);
+ if (err < 0)
+ break;
+ }
+ if (!err)
+ dummy_load(stress);
+
+ if (contended > n)
+ ww_mutex_unlock(&locks[order[contended]]);
+ contended = n;
+ while (n--)
+ ww_mutex_unlock(&locks[order[n]]);
+
+ if (err == -EDEADLK) {
+ ww_mutex_lock_slow(&locks[order[contended]], &ctx);
+ goto retry;
+ }
+
+ if (err) {
+ pr_err_once("stress (%s) failed with %d\n",
+ __func__, err);
+ break;
+ }
+ } while (--stress->nloops);
+
+ ww_acquire_fini(&ctx);
+
+ kfree(order);
+ kfree(stress);
+}
+
+struct reorder_lock {
+ struct list_head link;
+ struct ww_mutex *lock;
+};
+
+static void stress_reorder_work(struct work_struct *work)
+{
+ struct stress *stress = container_of(work, typeof(*stress), work);
+ LIST_HEAD(locks);
+ struct ww_acquire_ctx ctx;
+ struct reorder_lock *ll, *ln;
+ int *order;
+ int n, err;
+
+ order = get_random_order(stress->nlocks);
+ if (!order)
+ return;
+
+ for (n = 0; n < stress->nlocks; n++) {
+ ll = kmalloc(sizeof(*ll), GFP_KERNEL);
+ if (!ll)
+ goto out;
+
+ ll->lock = &stress->locks[order[n]];
+ list_add(&ll->link, &locks);
+ }
+ kfree(order);
+ order = NULL;
+
+ ww_acquire_init(&ctx, &ww_class);
+
+ do {
+ list_for_each_entry(ll, &locks, link) {
+ err = ww_mutex_lock(ll->lock, &ctx);
+ if (!err)
+ continue;
+
+ ln = ll;
+ list_for_each_entry_continue_reverse(ln, &locks, link)
+ ww_mutex_unlock(ln->lock);
+
+ if (err != -EDEADLK) {
+ pr_err_once("stress (%s) failed with %d\n",
+ __func__, err);
+ break;
+ }
+
+ ww_mutex_lock_slow(ll->lock, &ctx);
+ list_move(&ll->link, &locks); /* restarts iteration */
+ }
+
+ dummy_load(stress);
+ list_for_each_entry(ll, &locks, link)
+ ww_mutex_unlock(ll->lock);
+ } while (--stress->nloops);
+
+ ww_acquire_fini(&ctx);
+
+out:
+ list_for_each_entry_safe(ll, ln, &locks, link)
+ kfree(ll);
+ kfree(order);
+ kfree(stress);
+}
+
+static void stress_one_work(struct work_struct *work)
+{
+ struct stress *stress = container_of(work, typeof(*stress), work);
+ const int nlocks = stress->nlocks;
+ struct ww_mutex *lock = stress->locks + (get_random_int() % nlocks);
+ int err;
+
+ do {
+ err = ww_mutex_lock(lock, NULL);
+ if (!err) {
+ dummy_load(stress);
+ ww_mutex_unlock(lock);
+ } else {
+ pr_err_once("stress (%s) failed with %d\n",
+ __func__, err);
+ break;
+ }
+ } while (--stress->nloops);
+
+ kfree(stress);
+}
+
+#define STRESS_INORDER BIT(0)
+#define STRESS_REORDER BIT(1)
+#define STRESS_ONE BIT(2)
+#define STRESS_ALL (STRESS_INORDER | STRESS_REORDER | STRESS_ONE)
+
+static int stress(int nlocks, int nthreads, int nloops, unsigned int flags)
+{
+ struct ww_mutex *locks;
+ int n;
+
+ locks = kmalloc_array(nlocks, sizeof(*locks), GFP_KERNEL);
+ if (!locks)
+ return -ENOMEM;
+
+ for (n = 0; n < nlocks; n++)
+ ww_mutex_init(&locks[n], &ww_class);
+
+ for (n = 0; nthreads; n++) {
+ struct stress *stress;
+ void (*fn)(struct work_struct *work);
+
+ fn = NULL;
+ switch (n & 3) {
+ case 0:
+ if (flags & STRESS_INORDER)
+ fn = stress_inorder_work;
+ break;
+ case 1:
+ if (flags & STRESS_REORDER)
+ fn = stress_reorder_work;
+ break;
+ case 2:
+ if (flags & STRESS_ONE)
+ fn = stress_one_work;
+ break;
+ }
+
+ if (!fn)
+ continue;
+
+ stress = kmalloc(sizeof(*stress), GFP_KERNEL);
+ if (!stress)
+ break;
+
+ INIT_WORK(&stress->work, fn);
+ stress->locks = locks;
+ stress->nlocks = nlocks;
+ stress->nloops = nloops;
+
+ queue_work(wq, &stress->work);
+ nthreads--;
+ }
+
+ flush_workqueue(wq);
+
+ for (n = 0; n < nlocks; n++)
+ ww_mutex_destroy(&locks[n]);
+ kfree(locks);
+
+ return 0;
+}
+
static int __init test_ww_mutex_init(void)
{
int ncpus = num_online_cpus();
@@ -377,6 +619,18 @@ static int __init test_ww_mutex_init(void)
if (ret)
return ret;
+ ret = stress(16, 2*ncpus, 1<<10, STRESS_INORDER);
+ if (ret)
+ return ret;
+
+ ret = stress(16, 2*ncpus, 1<<10, STRESS_REORDER);
+ if (ret)
+ return ret;
+
+ ret = stress(4096, hweight32(STRESS_ALL)*ncpus, 1<<12, STRESS_ALL);
+ if (ret)
+ return ret;
+
return 0;
}
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 8/8] locking: Add ww_mutex to tools/testing/selftests
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
` (6 preceding siblings ...)
2016-12-01 11:47 ` [PATCH v2 7/8] locking: Add kselftests for ww_mutex stress Chris Wilson
@ 2016-12-01 11:47 ` 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
8 siblings, 1 reply; 21+ messages in thread
From: Chris Wilson @ 2016-12-01 11:47 UTC (permalink / raw)
To: linux-kernel; +Cc: Chris Wilson, Shuah Khan, Peter Zijlstra, Ingo Molnar
Add the minimal test running (modprobe test-ww_mutex) to the kselftests
CI framework.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
---
tools/testing/selftests/locking/ww_mutex.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
create mode 100755 tools/testing/selftests/locking/ww_mutex.sh
diff --git a/tools/testing/selftests/locking/ww_mutex.sh b/tools/testing/selftests/locking/ww_mutex.sh
new file mode 100755
index 000000000000..6905da965f3b
--- /dev/null
+++ b/tools/testing/selftests/locking/ww_mutex.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Runs API tests for struct ww_mutex (Wait/Wound mutexes)
+
+if /sbin/modprobe -q test-ww_mutex; then
+ /sbin/modprobe -q -r test-ww_mutex
+ echo "locking/ww_mutex: ok"
+else
+ echo "locking/ww_mutex: [FAIL]"
+ exit 1
+fi
--
2.10.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/8] locking: Fix compilation of __WW_MUTEX_INITIALIZER
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
1 sibling, 1 reply; 21+ messages in thread
From: Peter Zijlstra @ 2016-12-16 14:50 UTC (permalink / raw)
To: Chris Wilson; +Cc: linux-kernel, Maarten Lankhorst, Ingo Molnar
Chris, did this series at all depend on the other ww_mutex patches?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/8] locking: Fix compilation of __WW_MUTEX_INITIALIZER
2016-12-16 14:50 ` Peter Zijlstra
@ 2016-12-16 17:26 ` Chris Wilson
0 siblings, 0 replies; 21+ messages in thread
From: Chris Wilson @ 2016-12-16 17:26 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: linux-kernel, Maarten Lankhorst, Ingo Molnar
On Fri, Dec 16, 2016 at 03:50:40PM +0100, Peter Zijlstra wrote:
>
>
> Chris, did this series at all depend on the other ww_mutex patches?
It is independent. My goal was to try and hit the bugs Nicolai reported.
Most of it should be covered by locktorture if we add ww_mutex support
to it.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Fix compilation of __WW_MUTEX_INITIALIZER
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
@ 2017-01-14 12:52 ` tip-bot for Chris Wilson
1 sibling, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:52 UTC (permalink / raw)
To: linux-tip-commits
Cc: akpm, tglx, hpa, mingo, peterz, torvalds, maarten.lankhorst,
paulmck, chris, linux-kernel
Commit-ID: af2e859edd477fa1ea3d1d106f41a595cff3d162
Gitweb: http://git.kernel.org/tip/af2e859edd477fa1ea3d1d106f41a595cff3d162
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:04 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:13 +0100
locking/ww_mutex: Fix compilation of __WW_MUTEX_INITIALIZER
>From conflicting macro parameters, passing the wrong name to
__MUTEX_INITIALIZER and a stray '\', #define __WW_MUTEX_INITIALIZER was
very unhappy.
One unnecessary change was to choose to pass &ww_class instead of
implicitly taking the address of the class within the macro.
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 <maarten.lankhorst@canonical.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 1b375dc30710 ("mutex: Move ww_mutex definitions to ww_mutex.h")
Link: http://lkml.kernel.org/r/20161201114711.28697-2-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/ww_mutex.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h
index c075285..083950f 100644
--- a/include/linux/ww_mutex.h
+++ b/include/linux/ww_mutex.h
@@ -51,10 +51,10 @@ struct ww_mutex {
};
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class) \
- , .ww_class = &ww_class
+# define __WW_CLASS_MUTEX_INITIALIZER(lockname, class) \
+ , .ww_class = class
#else
-# define __WW_CLASS_MUTEX_INITIALIZER(lockname, ww_class)
+# define __WW_CLASS_MUTEX_INITIALIZER(lockname, class)
#endif
#define __WW_CLASS_INITIALIZER(ww_class) \
@@ -63,7 +63,7 @@ struct ww_mutex {
, .mutex_name = #ww_class "_mutex" }
#define __WW_MUTEX_INITIALIZER(lockname, class) \
- { .base = { \__MUTEX_INITIALIZER(lockname) } \
+ { .base = __MUTEX_INITIALIZER(lockname.base) \
__WW_CLASS_MUTEX_INITIALIZER(lockname, class) }
#define DEFINE_WW_CLASS(classname) \
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Add ww_mutex to locktorture test
2016-12-01 11:47 ` [PATCH v2 2/8] locking: Add ww_mutex to locktorture test Chris Wilson
@ 2017-01-14 12:52 ` tip-bot for Chris Wilson
0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:52 UTC (permalink / raw)
To: linux-tip-commits
Cc: dev, paulmck, linux-kernel, mingo, akpm, peterz, chris, nhaehnle,
tglx, hpa, torvalds
Commit-ID: 0186a6cbdc6287fde65858e5d9c714dc167b8ace
Gitweb: http://git.kernel.org/tip/0186a6cbdc6287fde65858e5d9c714dc167b8ace
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:05 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:14 +0100
locking/ww_mutex: Add ww_mutex to locktorture test
Although ww_mutexes degenerate into mutexes, it would be useful to
torture the deadlock handling between multiple ww_mutexes in addition to
torturing the regular mutexes.
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-3-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/locktorture.c | 73 ++++++++++++++++++++++
.../selftests/rcutorture/configs/lock/CFLIST | 1 +
.../rcutorture/configs/lock/{LOCK06 => LOCK07} | 0
.../selftests/rcutorture/configs/lock/LOCK07.boot | 1 +
4 files changed, 75 insertions(+)
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index f8c5af5..9bffedd 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -372,6 +372,78 @@ static struct lock_torture_ops mutex_lock_ops = {
.name = "mutex_lock"
};
+#include <linux/ww_mutex.h>
+static DEFINE_WW_CLASS(torture_ww_class);
+static DEFINE_WW_MUTEX(torture_ww_mutex_0, &torture_ww_class);
+static DEFINE_WW_MUTEX(torture_ww_mutex_1, &torture_ww_class);
+static DEFINE_WW_MUTEX(torture_ww_mutex_2, &torture_ww_class);
+
+static int torture_ww_mutex_lock(void)
+__acquires(torture_ww_mutex_0)
+__acquires(torture_ww_mutex_1)
+__acquires(torture_ww_mutex_2)
+{
+ LIST_HEAD(list);
+ struct reorder_lock {
+ struct list_head link;
+ struct ww_mutex *lock;
+ } locks[3], *ll, *ln;
+ struct ww_acquire_ctx ctx;
+
+ locks[0].lock = &torture_ww_mutex_0;
+ list_add(&locks[0].link, &list);
+
+ locks[1].lock = &torture_ww_mutex_1;
+ list_add(&locks[1].link, &list);
+
+ locks[2].lock = &torture_ww_mutex_2;
+ list_add(&locks[2].link, &list);
+
+ ww_acquire_init(&ctx, &torture_ww_class);
+
+ list_for_each_entry(ll, &list, link) {
+ int err;
+
+ err = ww_mutex_lock(ll->lock, &ctx);
+ if (!err)
+ continue;
+
+ ln = ll;
+ list_for_each_entry_continue_reverse(ln, &list, link)
+ ww_mutex_unlock(ln->lock);
+
+ if (err != -EDEADLK)
+ return err;
+
+ ww_mutex_lock_slow(ll->lock, &ctx);
+ list_move(&ll->link, &list);
+ }
+
+ ww_acquire_fini(&ctx);
+ return 0;
+}
+
+static void torture_ww_mutex_unlock(void)
+__releases(torture_ww_mutex_0)
+__releases(torture_ww_mutex_1)
+__releases(torture_ww_mutex_2)
+{
+ ww_mutex_unlock(&torture_ww_mutex_0);
+ ww_mutex_unlock(&torture_ww_mutex_1);
+ ww_mutex_unlock(&torture_ww_mutex_2);
+}
+
+static struct lock_torture_ops ww_mutex_lock_ops = {
+ .writelock = torture_ww_mutex_lock,
+ .write_delay = torture_mutex_delay,
+ .task_boost = torture_boost_dummy,
+ .writeunlock = torture_ww_mutex_unlock,
+ .readlock = NULL,
+ .read_delay = NULL,
+ .readunlock = NULL,
+ .name = "ww_mutex_lock"
+};
+
#ifdef CONFIG_RT_MUTEXES
static DEFINE_RT_MUTEX(torture_rtmutex);
@@ -793,6 +865,7 @@ static int __init lock_torture_init(void)
&spin_lock_ops, &spin_lock_irq_ops,
&rw_lock_ops, &rw_lock_irq_ops,
&mutex_lock_ops,
+ &ww_mutex_lock_ops,
#ifdef CONFIG_RT_MUTEXES
&rtmutex_lock_ops,
#endif
diff --git a/tools/testing/selftests/rcutorture/configs/lock/CFLIST b/tools/testing/selftests/rcutorture/configs/lock/CFLIST
index b9611c5..41bae58 100644
--- a/tools/testing/selftests/rcutorture/configs/lock/CFLIST
+++ b/tools/testing/selftests/rcutorture/configs/lock/CFLIST
@@ -4,3 +4,4 @@ LOCK03
LOCK04
LOCK05
LOCK06
+LOCK07
diff --git a/tools/testing/selftests/rcutorture/configs/lock/LOCK06 b/tools/testing/selftests/rcutorture/configs/lock/LOCK07
similarity index 100%
copy from tools/testing/selftests/rcutorture/configs/lock/LOCK06
copy to tools/testing/selftests/rcutorture/configs/lock/LOCK07
diff --git a/tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot b/tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot
new file mode 100644
index 0000000..97dadd1
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/lock/LOCK07.boot
@@ -0,0 +1 @@
+locktorture.torture_type=ww_mutex_lock
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Begin kselftests for ww_mutex
2016-12-01 11:47 ` [PATCH v2 3/8] locking: Begin kselftests for ww_mutex Chris Wilson
@ 2017-01-14 12:53 ` tip-bot for Chris Wilson
0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:53 UTC (permalink / raw)
To: linux-tip-commits
Cc: torvalds, chris, dev, nhaehnle, paulmck, tglx, akpm, peterz,
linux-kernel, mingo, hpa
Commit-ID: f2a5fec17395f259d54daa8833d81b00cceb15c3
Gitweb: http://git.kernel.org/tip/f2a5fec17395f259d54daa8833d81b00cceb15c3
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:06 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:14 +0100
locking/ww_mutex: Begin kselftests for ww_mutex
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-4-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/Makefile | 1 +
kernel/locking/test-ww_mutex.c | 140 +++++++++++++++++++++++++++++++++++++++++
lib/Kconfig.debug | 12 ++++
3 files changed, 153 insertions(+)
diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile
index 6f88e35..760158d 100644
--- a/kernel/locking/Makefile
+++ b/kernel/locking/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem-xadd.o
obj-$(CONFIG_QUEUED_RWLOCKS) += qrwlock.o
obj-$(CONFIG_LOCK_TORTURE_TEST) += locktorture.o
+obj-$(CONFIG_WW_MUTEX_SELFTEST) += test-ww_mutex.o
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
new file mode 100644
index 0000000..472d5b1
--- /dev/null
+++ b/kernel/locking/test-ww_mutex.c
@@ -0,0 +1,140 @@
+/*
+ * Module-based API test facility for ww_mutexes
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ */
+
+#include <linux/kernel.h>
+
+#include <linux/completion.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+#include <linux/ww_mutex.h>
+
+static DEFINE_WW_CLASS(ww_class);
+
+struct test_mutex {
+ struct work_struct work;
+ struct ww_mutex mutex;
+ struct completion ready, go, done;
+ unsigned int flags;
+};
+
+#define TEST_MTX_SPIN BIT(0)
+#define TEST_MTX_TRY BIT(1)
+#define TEST_MTX_CTX BIT(2)
+#define __TEST_MTX_LAST BIT(3)
+
+static void test_mutex_work(struct work_struct *work)
+{
+ struct test_mutex *mtx = container_of(work, typeof(*mtx), work);
+
+ complete(&mtx->ready);
+ wait_for_completion(&mtx->go);
+
+ if (mtx->flags & TEST_MTX_TRY) {
+ while (!ww_mutex_trylock(&mtx->mutex))
+ cpu_relax();
+ } else {
+ ww_mutex_lock(&mtx->mutex, NULL);
+ }
+ complete(&mtx->done);
+ ww_mutex_unlock(&mtx->mutex);
+}
+
+static int __test_mutex(unsigned int flags)
+{
+#define TIMEOUT (HZ / 16)
+ struct test_mutex mtx;
+ struct ww_acquire_ctx ctx;
+ int ret;
+
+ ww_mutex_init(&mtx.mutex, &ww_class);
+ ww_acquire_init(&ctx, &ww_class);
+
+ INIT_WORK_ONSTACK(&mtx.work, test_mutex_work);
+ init_completion(&mtx.ready);
+ init_completion(&mtx.go);
+ init_completion(&mtx.done);
+ mtx.flags = flags;
+
+ schedule_work(&mtx.work);
+
+ wait_for_completion(&mtx.ready);
+ ww_mutex_lock(&mtx.mutex, (flags & TEST_MTX_CTX) ? &ctx : NULL);
+ complete(&mtx.go);
+ if (flags & TEST_MTX_SPIN) {
+ unsigned long timeout = jiffies + TIMEOUT;
+
+ ret = 0;
+ do {
+ if (completion_done(&mtx.done)) {
+ ret = -EINVAL;
+ break;
+ }
+ cpu_relax();
+ } while (time_before(jiffies, timeout));
+ } else {
+ ret = wait_for_completion_timeout(&mtx.done, TIMEOUT);
+ }
+ ww_mutex_unlock(&mtx.mutex);
+ ww_acquire_fini(&ctx);
+
+ if (ret) {
+ pr_err("%s(flags=%x): mutual exclusion failure\n",
+ __func__, flags);
+ ret = -EINVAL;
+ }
+
+ flush_work(&mtx.work);
+ destroy_work_on_stack(&mtx.work);
+ return ret;
+#undef TIMEOUT
+}
+
+static int test_mutex(void)
+{
+ int ret;
+ int i;
+
+ for (i = 0; i < __TEST_MTX_LAST; i++) {
+ ret = __test_mutex(i);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int __init test_ww_mutex_init(void)
+{
+ int ret;
+
+ ret = test_mutex();
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static void __exit test_ww_mutex_exit(void)
+{
+}
+
+module_init(test_ww_mutex_init);
+module_exit(test_ww_mutex_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Intel Corporation");
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index eb9e9a7..5b37821 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1180,6 +1180,18 @@ config LOCK_TORTURE_TEST
Say M if you want these torture tests to build as a module.
Say N if you are unsure.
+config WW_MUTEX_SELFTEST
+ tristate "Wait/wound mutex selftests"
+ help
+ This option provides a kernel module that runs tests on the
+ on the struct ww_mutex locking API.
+
+ It is recommended to enable DEBUG_WW_MUTEX_SLOWPATH in conjunction
+ with this test harness.
+
+ Say M if you want these self tests to build as a module.
+ Say N if you are unsure.
+
endmenu # lock debugging
config TRACE_IRQFLAGS
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Add kselftests for ww_mutex AA deadlock detection
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
0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: paulmck, nhaehnle, peterz, dev, linux-kernel, tglx, torvalds,
hpa, mingo, akpm, chris
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;
}
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Add kselftests for ww_mutex ABBA deadlock detection
2016-12-01 11:47 ` [PATCH v2 5/8] locking: Add kselftests for ww_mutex ABBA " Chris Wilson
@ 2017-01-14 12:54 ` tip-bot for Chris Wilson
0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: tglx, akpm, peterz, chris, linux-kernel, dev, hpa, nhaehnle,
torvalds, mingo, paulmck
Commit-ID: 70207686e492fb97c11d88ae7d8ebce7d2d080aa
Gitweb: http://git.kernel.org/tip/70207686e492fb97c11d88ae7d8ebce7d2d080aa
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:08 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:16 +0100
locking/ww_mutex: Add kselftests for ww_mutex ABBA 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-6-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/test-ww_mutex.c | 98 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 835fa7a..5a643ba 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -153,6 +153,96 @@ out:
return ret;
}
+struct test_abba {
+ struct work_struct work;
+ struct ww_mutex a_mutex;
+ struct ww_mutex b_mutex;
+ struct completion a_ready;
+ struct completion b_ready;
+ bool resolve;
+ int result;
+};
+
+static void test_abba_work(struct work_struct *work)
+{
+ struct test_abba *abba = container_of(work, typeof(*abba), work);
+ struct ww_acquire_ctx ctx;
+ int err;
+
+ ww_acquire_init(&ctx, &ww_class);
+ ww_mutex_lock(&abba->b_mutex, &ctx);
+
+ complete(&abba->b_ready);
+ wait_for_completion(&abba->a_ready);
+
+ err = ww_mutex_lock(&abba->a_mutex, &ctx);
+ if (abba->resolve && err == -EDEADLK) {
+ ww_mutex_unlock(&abba->b_mutex);
+ ww_mutex_lock_slow(&abba->a_mutex, &ctx);
+ err = ww_mutex_lock(&abba->b_mutex, &ctx);
+ }
+
+ if (!err)
+ ww_mutex_unlock(&abba->a_mutex);
+ ww_mutex_unlock(&abba->b_mutex);
+ ww_acquire_fini(&ctx);
+
+ abba->result = err;
+}
+
+static int test_abba(bool resolve)
+{
+ struct test_abba abba;
+ struct ww_acquire_ctx ctx;
+ int err, ret;
+
+ ww_mutex_init(&abba.a_mutex, &ww_class);
+ ww_mutex_init(&abba.b_mutex, &ww_class);
+ INIT_WORK_ONSTACK(&abba.work, test_abba_work);
+ init_completion(&abba.a_ready);
+ init_completion(&abba.b_ready);
+ abba.resolve = resolve;
+
+ schedule_work(&abba.work);
+
+ ww_acquire_init(&ctx, &ww_class);
+ ww_mutex_lock(&abba.a_mutex, &ctx);
+
+ complete(&abba.a_ready);
+ wait_for_completion(&abba.b_ready);
+
+ err = ww_mutex_lock(&abba.b_mutex, &ctx);
+ if (resolve && err == -EDEADLK) {
+ ww_mutex_unlock(&abba.a_mutex);
+ ww_mutex_lock_slow(&abba.b_mutex, &ctx);
+ err = ww_mutex_lock(&abba.a_mutex, &ctx);
+ }
+
+ if (!err)
+ ww_mutex_unlock(&abba.b_mutex);
+ ww_mutex_unlock(&abba.a_mutex);
+ ww_acquire_fini(&ctx);
+
+ flush_work(&abba.work);
+ destroy_work_on_stack(&abba.work);
+
+ ret = 0;
+ if (resolve) {
+ if (err || abba.result) {
+ pr_err("%s: failed to resolve ABBA deadlock, A err=%d, B err=%d\n",
+ __func__, err, abba.result);
+ ret = -EINVAL;
+ }
+ } else {
+ if (err != -EDEADLK && abba.result != -EDEADLK) {
+ pr_err("%s: missed ABBA deadlock, A err=%d, B err=%d\n",
+ __func__, err, abba.result);
+ ret = -EINVAL;
+ }
+ }
+ return ret;
+}
+
static int __init test_ww_mutex_init(void)
{
int ret;
@@ -165,6 +255,14 @@ static int __init test_ww_mutex_init(void)
if (ret)
return ret;
+ ret = test_abba(false);
+ if (ret)
+ return ret;
+
+ ret = test_abba(true);
+ if (ret)
+ return ret;
+
return 0;
}
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Add kselftests for resolving ww_mutex cyclic deadlocks
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-bot for Chris Wilson
0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:55 UTC (permalink / raw)
To: linux-tip-commits
Cc: dev, chris, linux-kernel, hpa, mingo, nhaehnle, tglx, paulmck,
torvalds, peterz, akpm
Commit-ID: d1b42b800e5d09dcee52812b4396aca3a3696ba9
Gitweb: http://git.kernel.org/tip/d1b42b800e5d09dcee52812b4396aca3a3696ba9
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:09 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:16 +0100
locking/ww_mutex: Add kselftests for resolving ww_mutex cyclic deadlocks
Check that ww_mutexes can detect cyclic deadlocks (generalised ABBA
cycles) and resolve them by lock reordering.
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-7-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/test-ww_mutex.c | 115 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 5a643ba..84da738 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -21,9 +21,11 @@
#include <linux/completion.h>
#include <linux/kthread.h>
#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/ww_mutex.h>
static DEFINE_WW_CLASS(ww_class);
+struct workqueue_struct *wq;
struct test_mutex {
struct work_struct work;
@@ -243,10 +245,118 @@ static int test_abba(bool resolve)
return ret;
}
+struct test_cycle {
+ struct work_struct work;
+ struct ww_mutex a_mutex;
+ struct ww_mutex *b_mutex;
+ struct completion *a_signal;
+ struct completion b_signal;
+ int result;
+};
+
+static void test_cycle_work(struct work_struct *work)
+{
+ struct test_cycle *cycle = container_of(work, typeof(*cycle), work);
+ struct ww_acquire_ctx ctx;
+ int err;
+
+ ww_acquire_init(&ctx, &ww_class);
+ ww_mutex_lock(&cycle->a_mutex, &ctx);
+
+ complete(cycle->a_signal);
+ wait_for_completion(&cycle->b_signal);
+
+ err = ww_mutex_lock(cycle->b_mutex, &ctx);
+ if (err == -EDEADLK) {
+ ww_mutex_unlock(&cycle->a_mutex);
+ ww_mutex_lock_slow(cycle->b_mutex, &ctx);
+ err = ww_mutex_lock(&cycle->a_mutex, &ctx);
+ }
+
+ if (!err)
+ ww_mutex_unlock(cycle->b_mutex);
+ ww_mutex_unlock(&cycle->a_mutex);
+ ww_acquire_fini(&ctx);
+
+ cycle->result = err;
+}
+
+static int __test_cycle(unsigned int nthreads)
+{
+ struct test_cycle *cycles;
+ unsigned int n, last = nthreads - 1;
+ int ret;
+
+ cycles = kmalloc_array(nthreads, sizeof(*cycles), GFP_KERNEL);
+ if (!cycles)
+ return -ENOMEM;
+
+ for (n = 0; n < nthreads; n++) {
+ struct test_cycle *cycle = &cycles[n];
+
+ ww_mutex_init(&cycle->a_mutex, &ww_class);
+ if (n == last)
+ cycle->b_mutex = &cycles[0].a_mutex;
+ else
+ cycle->b_mutex = &cycles[n + 1].a_mutex;
+
+ if (n == 0)
+ cycle->a_signal = &cycles[last].b_signal;
+ else
+ cycle->a_signal = &cycles[n - 1].b_signal;
+ init_completion(&cycle->b_signal);
+
+ INIT_WORK(&cycle->work, test_cycle_work);
+ cycle->result = 0;
+ }
+
+ for (n = 0; n < nthreads; n++)
+ queue_work(wq, &cycles[n].work);
+
+ flush_workqueue(wq);
+
+ ret = 0;
+ for (n = 0; n < nthreads; n++) {
+ struct test_cycle *cycle = &cycles[n];
+
+ if (!cycle->result)
+ continue;
+
+ pr_err("cylic deadlock not resolved, ret[%d/%d] = %d\n",
+ n, nthreads, cycle->result);
+ ret = -EINVAL;
+ break;
+ }
+
+ for (n = 0; n < nthreads; n++)
+ ww_mutex_destroy(&cycles[n].a_mutex);
+ kfree(cycles);
+ return ret;
+}
+
+static int test_cycle(unsigned int ncpus)
+{
+ unsigned int n;
+ int ret;
+
+ for (n = 2; n <= ncpus + 1; n++) {
+ ret = __test_cycle(n);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int __init test_ww_mutex_init(void)
{
+ int ncpus = num_online_cpus();
int ret;
+ wq = alloc_workqueue("test-ww_mutex", WQ_UNBOUND, 0);
+ if (!wq)
+ return -ENOMEM;
+
ret = test_mutex();
if (ret)
return ret;
@@ -263,11 +373,16 @@ static int __init test_ww_mutex_init(void)
if (ret)
return ret;
+ ret = test_cycle(ncpus);
+ if (ret)
+ return ret;
+
return 0;
}
static void __exit test_ww_mutex_exit(void)
{
+ destroy_workqueue(wq);
}
module_init(test_ww_mutex_init);
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Add kselftests for ww_mutex stress
2016-12-01 11:47 ` [PATCH v2 7/8] locking: Add kselftests for ww_mutex stress Chris Wilson
@ 2017-01-14 12:55 ` tip-bot for Chris Wilson
2017-01-19 20:13 ` Peter Zijlstra
0 siblings, 1 reply; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:55 UTC (permalink / raw)
To: linux-tip-commits
Cc: dev, tglx, nhaehnle, chris, linux-kernel, akpm, hpa, torvalds,
peterz, paulmck, mingo
Commit-ID: 2a0c11282881875dc44f166a20eedf0d866dd0ef
Gitweb: http://git.kernel.org/tip/2a0c11282881875dc44f166a20eedf0d866dd0ef
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:10 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:17 +0100
locking/ww_mutex: Add kselftests for ww_mutex stress
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-8-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/test-ww_mutex.c | 254 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 254 insertions(+)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 84da738..da6c9a3 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -19,8 +19,10 @@
#include <linux/kernel.h>
#include <linux/completion.h>
+#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/module.h>
+#include <linux/random.h>
#include <linux/slab.h>
#include <linux/ww_mutex.h>
@@ -348,6 +350,246 @@ static int test_cycle(unsigned int ncpus)
return 0;
}
+struct stress {
+ struct work_struct work;
+ struct ww_mutex *locks;
+ int nlocks;
+ int nloops;
+};
+
+static int *get_random_order(int count)
+{
+ int *order;
+ int n, r, tmp;
+
+ order = kmalloc_array(count, sizeof(*order), GFP_TEMPORARY);
+ if (!order)
+ return order;
+
+ for (n = 0; n < count; n++)
+ order[n] = n;
+
+ for (n = count - 1; n > 1; n--) {
+ r = get_random_int() % (n + 1);
+ if (r != n) {
+ tmp = order[n];
+ order[n] = order[r];
+ order[r] = tmp;
+ }
+ }
+
+ return order;
+}
+
+static void dummy_load(struct stress *stress)
+{
+ usleep_range(1000, 2000);
+}
+
+static void stress_inorder_work(struct work_struct *work)
+{
+ struct stress *stress = container_of(work, typeof(*stress), work);
+ const int nlocks = stress->nlocks;
+ struct ww_mutex *locks = stress->locks;
+ struct ww_acquire_ctx ctx;
+ int *order;
+
+ order = get_random_order(nlocks);
+ if (!order)
+ return;
+
+ ww_acquire_init(&ctx, &ww_class);
+
+ do {
+ int contended = -1;
+ int n, err;
+
+retry:
+ err = 0;
+ for (n = 0; n < nlocks; n++) {
+ if (n == contended)
+ continue;
+
+ err = ww_mutex_lock(&locks[order[n]], &ctx);
+ if (err < 0)
+ break;
+ }
+ if (!err)
+ dummy_load(stress);
+
+ if (contended > n)
+ ww_mutex_unlock(&locks[order[contended]]);
+ contended = n;
+ while (n--)
+ ww_mutex_unlock(&locks[order[n]]);
+
+ if (err == -EDEADLK) {
+ ww_mutex_lock_slow(&locks[order[contended]], &ctx);
+ goto retry;
+ }
+
+ if (err) {
+ pr_err_once("stress (%s) failed with %d\n",
+ __func__, err);
+ break;
+ }
+ } while (--stress->nloops);
+
+ ww_acquire_fini(&ctx);
+
+ kfree(order);
+ kfree(stress);
+}
+
+struct reorder_lock {
+ struct list_head link;
+ struct ww_mutex *lock;
+};
+
+static void stress_reorder_work(struct work_struct *work)
+{
+ struct stress *stress = container_of(work, typeof(*stress), work);
+ LIST_HEAD(locks);
+ struct ww_acquire_ctx ctx;
+ struct reorder_lock *ll, *ln;
+ int *order;
+ int n, err;
+
+ order = get_random_order(stress->nlocks);
+ if (!order)
+ return;
+
+ for (n = 0; n < stress->nlocks; n++) {
+ ll = kmalloc(sizeof(*ll), GFP_KERNEL);
+ if (!ll)
+ goto out;
+
+ ll->lock = &stress->locks[order[n]];
+ list_add(&ll->link, &locks);
+ }
+ kfree(order);
+ order = NULL;
+
+ ww_acquire_init(&ctx, &ww_class);
+
+ do {
+ list_for_each_entry(ll, &locks, link) {
+ err = ww_mutex_lock(ll->lock, &ctx);
+ if (!err)
+ continue;
+
+ ln = ll;
+ list_for_each_entry_continue_reverse(ln, &locks, link)
+ ww_mutex_unlock(ln->lock);
+
+ if (err != -EDEADLK) {
+ pr_err_once("stress (%s) failed with %d\n",
+ __func__, err);
+ break;
+ }
+
+ ww_mutex_lock_slow(ll->lock, &ctx);
+ list_move(&ll->link, &locks); /* restarts iteration */
+ }
+
+ dummy_load(stress);
+ list_for_each_entry(ll, &locks, link)
+ ww_mutex_unlock(ll->lock);
+ } while (--stress->nloops);
+
+ ww_acquire_fini(&ctx);
+
+out:
+ list_for_each_entry_safe(ll, ln, &locks, link)
+ kfree(ll);
+ kfree(order);
+ kfree(stress);
+}
+
+static void stress_one_work(struct work_struct *work)
+{
+ struct stress *stress = container_of(work, typeof(*stress), work);
+ const int nlocks = stress->nlocks;
+ struct ww_mutex *lock = stress->locks + (get_random_int() % nlocks);
+ int err;
+
+ do {
+ err = ww_mutex_lock(lock, NULL);
+ if (!err) {
+ dummy_load(stress);
+ ww_mutex_unlock(lock);
+ } else {
+ pr_err_once("stress (%s) failed with %d\n",
+ __func__, err);
+ break;
+ }
+ } while (--stress->nloops);
+
+ kfree(stress);
+}
+
+#define STRESS_INORDER BIT(0)
+#define STRESS_REORDER BIT(1)
+#define STRESS_ONE BIT(2)
+#define STRESS_ALL (STRESS_INORDER | STRESS_REORDER | STRESS_ONE)
+
+static int stress(int nlocks, int nthreads, int nloops, unsigned int flags)
+{
+ struct ww_mutex *locks;
+ int n;
+
+ locks = kmalloc_array(nlocks, sizeof(*locks), GFP_KERNEL);
+ if (!locks)
+ return -ENOMEM;
+
+ for (n = 0; n < nlocks; n++)
+ ww_mutex_init(&locks[n], &ww_class);
+
+ for (n = 0; nthreads; n++) {
+ struct stress *stress;
+ void (*fn)(struct work_struct *work);
+
+ fn = NULL;
+ switch (n & 3) {
+ case 0:
+ if (flags & STRESS_INORDER)
+ fn = stress_inorder_work;
+ break;
+ case 1:
+ if (flags & STRESS_REORDER)
+ fn = stress_reorder_work;
+ break;
+ case 2:
+ if (flags & STRESS_ONE)
+ fn = stress_one_work;
+ break;
+ }
+
+ if (!fn)
+ continue;
+
+ stress = kmalloc(sizeof(*stress), GFP_KERNEL);
+ if (!stress)
+ break;
+
+ INIT_WORK(&stress->work, fn);
+ stress->locks = locks;
+ stress->nlocks = nlocks;
+ stress->nloops = nloops;
+
+ queue_work(wq, &stress->work);
+ nthreads--;
+ }
+
+ flush_workqueue(wq);
+
+ for (n = 0; n < nlocks; n++)
+ ww_mutex_destroy(&locks[n]);
+ kfree(locks);
+
+ return 0;
+}
+
static int __init test_ww_mutex_init(void)
{
int ncpus = num_online_cpus();
@@ -377,6 +619,18 @@ static int __init test_ww_mutex_init(void)
if (ret)
return ret;
+ ret = stress(16, 2*ncpus, 1<<10, STRESS_INORDER);
+ if (ret)
+ return ret;
+
+ ret = stress(16, 2*ncpus, 1<<10, STRESS_REORDER);
+ if (ret)
+ return ret;
+
+ ret = stress(4096, hweight32(STRESS_ALL)*ncpus, 1<<12, STRESS_ALL);
+ if (ret)
+ return ret;
+
return 0;
}
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [tip:locking/core] locking/ww_mutex: Add ww_mutex to tools/testing/selftests
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-bot for Chris Wilson
0 siblings, 0 replies; 21+ messages in thread
From: tip-bot for Chris Wilson @ 2017-01-14 12:56 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, tglx, mingo, shuah, torvalds, akpm, peterz,
paulmck, chris, hpa
Commit-ID: 2b0b211134a65401ed874ce0d5d48844f4f6f341
Gitweb: http://git.kernel.org/tip/2b0b211134a65401ed874ce0d5d48844f4f6f341
Author: Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Thu, 1 Dec 2016 11:47:11 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 14 Jan 2017 11:37:17 +0100
locking/ww_mutex: Add ww_mutex to tools/testing/selftests
Add the minimal test running (modprobe test-ww_mutex) to the kselftests
CI framework.
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: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20161201114711.28697-9-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/testing/selftests/locking/ww_mutex.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/testing/selftests/locking/ww_mutex.sh b/tools/testing/selftests/locking/ww_mutex.sh
new file mode 100644
index 0000000..6905da9
--- /dev/null
+++ b/tools/testing/selftests/locking/ww_mutex.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Runs API tests for struct ww_mutex (Wait/Wound mutexes)
+
+if /sbin/modprobe -q test-ww_mutex; then
+ /sbin/modprobe -q -r test-ww_mutex
+ echo "locking/ww_mutex: ok"
+else
+ echo "locking/ww_mutex: [FAIL]"
+ exit 1
+fi
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [tip:locking/core] locking/ww_mutex: Add kselftests for ww_mutex stress
2017-01-14 12:55 ` [tip:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
@ 2017-01-19 20:13 ` Peter Zijlstra
0 siblings, 0 replies; 21+ messages in thread
From: Peter Zijlstra @ 2017-01-19 20:13 UTC (permalink / raw)
To: mingo, paulmck, torvalds, akpm, hpa, chris, nhaehnle,
linux-kernel, dev, tglx
Cc: linux-tip-commits
Hi Chris,
I got me this... I'm still trying to wrap my head around what exactly
the test does.
=====================================
[ BUG: bad unlock balance detected! ]
4.10.0-rc4-00122-g6edad167-dirty #608 Not tainted
-------------------------------------
kworker/u81:37/330 is trying to release lock (ww_class_mutex) at:
[<ffffffff8115260a>] stress_inorder_work+0x15a/0x330
but there are no more locks to release!
other info that might help us debug this:
4 locks held by kworker/u81:37/330:
#0: ("test-ww_mutex"){++++.+}, at: [<ffffffff81111d62>] process_one_work+0x1f2/0x710
#1: ((&stress->work)){+.+.+.}, at: [<ffffffff81111d62>] process_one_work+0x1f2/0x710
#2: (ww_class_acquire){+.+...}, at: [<ffffffff81111ddd>] process_one_work+0x26d/0x710
#3: (ww_class_mutex){+.+...}, at: [<ffffffff811525ba>] stress_inorder_work+0x10a/0x330
stack backtrace:
CPU: 22 PID: 330 Comm: kworker/u81:37 Not tainted 4.10.0-rc4-00122-g6edad167-dirty #608
Hardware name: Intel Corporation S2600GZ/S2600GZ, BIOS SE5C600.86B.02.02.0002.122320131210 12/23/2013
Workqueue: test-ww_mutex stress_inorder_work
Call Trace:
dump_stack+0x86/0xc3
? stress_inorder_work+0x15a/0x330
print_unlock_imbalance_bug+0xd8/0xe0
? stress_inorder_work+0x15a/0x330
lock_release+0x374/0x4b0
? schedule_hrtimeout_range_clock+0xda/0x270
__mutex_unlock_slowpath+0x43/0x2e0
ww_mutex_unlock+0x47/0xb0
stress_inorder_work+0x15a/0x330
? process_one_work+0x26d/0x710
process_one_work+0x26d/0x710
? process_one_work+0x1f2/0x710
worker_thread+0x48/0x4e0
kthread+0x101/0x140
? process_one_work+0x710/0x710
? kthread_create_on_node+0x40/0x40
ret_from_fork+0x31/0x40
INFO: task swapper/0:1 blocked for more than 120 seconds.
Not tainted 4.10.0-rc4-00122-g6edad167-dirty #608
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
swapper/0 D 0 1 0 0x00000000
Call Trace:
__schedule+0x30a/0xc60
schedule+0x40/0x90
schedule_timeout+0x30a/0x670
? wait_for_completion+0x23/0x100
? trace_hardirqs_on_caller+0x100/0x1c0
wait_for_completion+0x97/0x100
? wake_up_q+0x70/0x70
flush_workqueue+0x1f6/0x6b0
? flush_workqueue+0xe8/0x6b0
stress+0x1b3/0x203
test_ww_mutex_init+0x30a/0x324
? __pv_init_lock_hash+0x59/0x59
? set_debug_rodata+0x12/0x12
do_one_initcall+0x43/0x180
? set_debug_rodata+0x12/0x12
kernel_init_freeable+0x1d9/0x266
? rest_init+0x140/0x140
kernel_init+0xe/0x100
ret_from_fork+0x31/0x40
INFO: lockdep is turned off. +
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: locking: Add kselftests for ww_mutex
2016-12-01 11:47 locking: Add kselftests for ww_mutex Chris Wilson
` (7 preceding siblings ...)
2016-12-01 11:47 ` [PATCH v2 8/8] locking: Add ww_mutex to tools/testing/selftests Chris Wilson
@ 2017-02-22 14:29 ` Geert Uytterhoeven
8 siblings, 0 replies; 21+ messages in thread
From: Geert Uytterhoeven @ 2017-02-22 14:29 UTC (permalink / raw)
To: Chris Wilson; +Cc: linux-kernel
Hi Chris,
On Thu, Dec 1, 2016 at 12:47 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Nicolai Hähnle was looking into a deadlock within ww_mutexes (that has
> been fixed by Peter's mutex rewrite) and to support his changes, I
> thought it was be useful to have a small validation suite for ww_mutex.
How long do these selftests typically take?
Do they need multiple CPU cores, lots of memory?
I.e. after how much time without any output should I start to worry
(on an emulated
Atari running Linux/m68k ;-)?
Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2017-02-22 14:29 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:locking/core] locking/ww_mutex: " tip-bot for Chris Wilson
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
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.