linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Maarten Lankhorst <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	torvalds@linux-foundation.org, peterz@infradead.org,
	akpm@linux-foundation.org, alexander.deucher@amd.com,
	tglx@linutronix.de, maarten.lankhorst@canonical.com
Subject: [tip:core/urgent] mutex: Fix w/w mutex deadlock injection
Date: Wed, 31 Jul 2013 01:55:38 -0700	[thread overview]
Message-ID: <tip-85f4896123d0299128f2c95cc40f3b8b01d4b0f6@git.kernel.org> (raw)
In-Reply-To: <51F775B5.201@canonical.com>

Commit-ID:  85f4896123d0299128f2c95cc40f3b8b01d4b0f6
Gitweb:     http://git.kernel.org/tip/85f4896123d0299128f2c95cc40f3b8b01d4b0f6
Author:     Maarten Lankhorst <maarten.lankhorst@canonical.com>
AuthorDate: Tue, 30 Jul 2013 10:13:41 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 30 Jul 2013 22:16:40 +0200

mutex: Fix w/w mutex deadlock injection

The check needs to be for > 1, because ctx->acquired is already incremented.
This will prevent ww_mutex_lock_slow from returning -EDEADLK and not locking
the mutex. It caused a lot of false gpu lockups on radeon with
CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y because a function that shouldn't be able
to return -EDEADLK did.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/51F775B5.201@canonical.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/mutex.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/mutex.c b/kernel/mutex.c
index ff05f4b..a52ee7bb 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -686,7 +686,7 @@ __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
 	might_sleep();
 	ret =  __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE,
 				   0, &ctx->dep_map, _RET_IP_, ctx);
-	if (!ret && ctx->acquired > 0)
+	if (!ret && ctx->acquired > 1)
 		return ww_mutex_deadlock_injection(lock, ctx);
 
 	return ret;
@@ -702,7 +702,7 @@ __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
 	ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE,
 				  0, &ctx->dep_map, _RET_IP_, ctx);
 
-	if (!ret && ctx->acquired > 0)
+	if (!ret && ctx->acquired > 1)
 		return ww_mutex_deadlock_injection(lock, ctx);
 
 	return ret;

  parent reply	other threads:[~2013-07-31  9:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  8:22 [GIT PULL] core/mutexes changes for v3.11: W/W mutex support Ingo Molnar
2013-07-03  0:54 ` Linus Torvalds
2013-07-03  6:29   ` Maarten Lankhorst
2013-07-05  6:23     ` Ingo Molnar
2013-07-05  7:29       ` [PATCH] mutex: move ww_mutex definitions to ww_mutex.h Maarten Lankhorst
2013-07-12 13:28         ` [tip:core/locking] mutex: Move " tip-bot for Maarten Lankhorst
2013-07-30  8:13       ` [PATCH] mutex: fix deadlock injection Maarten Lankhorst
2013-07-30  8:41         ` Peter Zijlstra
2013-08-07  0:05           ` Dave Airlie
2013-08-07  6:22             ` Maarten Lankhorst
2013-07-30 13:09         ` Alex Deucher
2013-07-31  8:55         ` tip-bot for Maarten Lankhorst [this message]
2013-08-05  7:58         ` 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=tip-85f4896123d0299128f2c95cc40f3b8b01d4b0f6@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.deucher@amd.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=maarten.lankhorst@canonical.com \
    --cc=mingo@kernel.org \
    --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).