diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-02-28 04:40:11 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-03-02 03:00:38 -0500 |
commit | 2b232e0c3b3a09f3e33750aa20e314f1b80e5361 (patch) | |
tree | 14dbb66a5e79dd4083f79040b208411dcba8a442 | |
parent | e2679aecf1060063b97bf187ba1c61430aab0701 (diff) |
locking/ww_mutex: Replace cpu_relax() with cond_resched() for tests
When busy-spinning on a ww_mutex_trylock(), we depend upon the other
thread advancing and releasing the lock. This can not happen on a single
CPU unless we relinquish it:
[ ] NMI watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [kworker/0:1:18]
...
[ ] Call Trace:
[ ] mutex_trylock()
[ ] test_mutex_work+0x31/0x56
[ ] process_one_work+0x1b4/0x2f9
[ ] worker_thread+0x1b0/0x27c
[ ] kthread+0xd1/0xd3
[ ] ret_from_fork+0x19/0x30
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
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: Thomas Gleixner <tglx@linutronix.de>
Fixes: f2a5fec17395 ("locking/ww_mutex: Begin kselftests for ww_mutex")
Link: http://lkml.kernel.org/r/20170228094011.2595-1-chris@chris-wilson.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/locking/test-ww_mutex.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index da6c9a34f62f..3eb39c588397 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c | |||
@@ -50,7 +50,7 @@ static void test_mutex_work(struct work_struct *work) | |||
50 | 50 | ||
51 | if (mtx->flags & TEST_MTX_TRY) { | 51 | if (mtx->flags & TEST_MTX_TRY) { |
52 | while (!ww_mutex_trylock(&mtx->mutex)) | 52 | while (!ww_mutex_trylock(&mtx->mutex)) |
53 | cpu_relax(); | 53 | cond_resched(); |
54 | } else { | 54 | } else { |
55 | ww_mutex_lock(&mtx->mutex, NULL); | 55 | ww_mutex_lock(&mtx->mutex, NULL); |
56 | } | 56 | } |
@@ -88,7 +88,7 @@ static int __test_mutex(unsigned int flags) | |||
88 | ret = -EINVAL; | 88 | ret = -EINVAL; |
89 | break; | 89 | break; |
90 | } | 90 | } |
91 | cpu_relax(); | 91 | cond_resched(); |
92 | } while (time_before(jiffies, timeout)); | 92 | } while (time_before(jiffies, timeout)); |
93 | } else { | 93 | } else { |
94 | ret = wait_for_completion_timeout(&mtx.done, TIMEOUT); | 94 | ret = wait_for_completion_timeout(&mtx.done, TIMEOUT); |