linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Chris Wilson <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: fengguang.wu@intel.com, tglx@linutronix.de,
	akpm@linux-foundation.org, torvalds@linux-foundation.org,
	mingo@kernel.org, peterz@infradead.org,
	linux-kernel@vger.kernel.org, chris@chris-wilson.co.uk,
	paulmck@linux.vnet.ibm.com, hpa@zytor.com
Subject: [tip:locking/urgent] locking/ww_mutex: Replace cpu_relax() with cond_resched() for tests
Date: Thu, 2 Mar 2017 00:20:30 -0800	[thread overview]
Message-ID: <tip-2b232e0c3b3a09f3e33750aa20e314f1b80e5361@git.kernel.org> (raw)
In-Reply-To: <20170228094011.2595-1-chris@chris-wilson.co.uk>

Commit-ID:  2b232e0c3b3a09f3e33750aa20e314f1b80e5361
Gitweb:     http://git.kernel.org/tip/2b232e0c3b3a09f3e33750aa20e314f1b80e5361
Author:     Chris Wilson <chris@chris-wilson.co.uk>
AuthorDate: Tue, 28 Feb 2017 09:40:11 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 2 Mar 2017 09:00:38 +0100

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>
---
 kernel/locking/test-ww_mutex.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index da6c9a3..3eb39c5 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)
 
 	if (mtx->flags & TEST_MTX_TRY) {
 		while (!ww_mutex_trylock(&mtx->mutex))
-			cpu_relax();
+			cond_resched();
 	} else {
 		ww_mutex_lock(&mtx->mutex, NULL);
 	}
@@ -88,7 +88,7 @@ static int __test_mutex(unsigned int flags)
 				ret = -EINVAL;
 				break;
 			}
-			cpu_relax();
+			cond_resched();
 		} while (time_before(jiffies, timeout));
 	} else {
 		ret = wait_for_completion_timeout(&mtx.done, TIMEOUT);

      parent reply	other threads:[~2017-03-02  8:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-28  3:59 [locking/ww_mutex] f2a5fec173 EIP: __mutex_trylock Fengguang Wu
2017-02-28  8:53 ` Chris Wilson
2017-02-28  9:40 ` [PATCH] locking/ww_mutex: Replace cpu_relax with cond_resched for tests Chris Wilson
2017-02-28  9:48   ` Peter Zijlstra
2017-02-28  9:58     ` Chris Wilson
2017-03-02  8:20   ` tip-bot for Chris Wilson [this message]

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-2b232e0c3b3a09f3e33750aa20e314f1b80e5361@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=fengguang.wu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).