From: a.p.zijlstra@chello.nl (Peter Zijlstra)
To: linux-arm-kernel@lists.infradead.org
Subject: RFC: mutex: hung tasks on SMP platforms with asm-generic/mutex-xchg.h
Date: Mon, 13 Aug 2012 16:05:17 +0200 [thread overview]
Message-ID: <1344866717.31459.32.camel@twins> (raw)
In-Reply-To: <alpine.LFD.2.02.1208130931530.5231@xanadu.home>
On Mon, 2012-08-13 at 09:35 -0400, Nicolas Pitre wrote:
> Date: Fri, 10 Aug 2012 15:22:09 +0100
> From: Will Deacon <will.deacon@arm.com>
> Subject: [PATCH] mutex: place lock in contended state after fastpath_lock failure
>
> ARM recently moved to asm-generic/mutex-xchg.h for its mutex
> implementation after the previous implementation was found to be missing
> some crucial memory barriers. However, this has revealed some problems
> running hackbench on SMP platforms due to the way in which the
> MUTEX_SPIN_ON_OWNER code operates.
>
> The symptoms are that a bunch of hackbench tasks are left waiting on an
> unlocked mutex and therefore never get woken up to claim it. This boils
> down to the following sequence of events:
>
> Task A Task B Task C Lock value
> 0 1
> 1 lock() 0
> 2 lock() 0
> 3 spin(A) 0
> 4 unlock() 1
> 5 lock() 0
> 6 cmpxchg(1,0) 0
> 7 contended() -1
> 8 lock() 0
> 9 spin(C) 0
> 10 unlock() 1
> 11 cmpxchg(1,0) 0
> 12 unlock() 1
>
> At this point, the lock is unlocked, but Task B is in an uninterruptible
> sleep with nobody to wake it up.
>
> This patch fixes the problem by ensuring we put the lock into the
> contended state if we fail to acquire it on the fastpath, ensuring that
> any blocked waiters are woken up when the mutex is released.
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Mason <chris.mason@fusionio.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> Reviewed-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Will you carry this through the ARM tree or do you want me/Ingo to take
it?
next prev parent reply other threads:[~2012-08-13 14:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-07 11:56 RFC: mutex: hung tasks on SMP platforms with asm-generic/mutex-xchg.h Will Deacon
2012-08-07 13:48 ` Peter Zijlstra
2012-08-07 14:04 ` Will Deacon
2012-08-07 17:14 ` Nicolas Pitre
2012-08-07 17:33 ` Will Deacon
2012-08-07 17:38 ` Will Deacon
2012-08-07 18:28 ` Nicolas Pitre
2012-08-09 5:12 ` Nicolas Pitre
2012-08-09 14:49 ` Will Deacon
2012-08-09 16:17 ` Nicolas Pitre
2012-08-09 16:57 ` Nicolas Pitre
2012-08-09 17:50 ` Will Deacon
2012-08-09 18:09 ` Nicolas Pitre
2012-08-09 18:17 ` Will Deacon
2012-08-09 20:05 ` Nicolas Pitre
2012-08-13 8:15 ` Peter Zijlstra
2012-08-13 9:13 ` Will Deacon
2012-08-13 13:35 ` Nicolas Pitre
2012-08-13 14:05 ` Peter Zijlstra [this message]
2012-08-13 14:11 ` Will Deacon
2012-08-13 14:45 ` Peter Zijlstra
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=1344866717.31459.32.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=linux-arm-kernel@lists.infradead.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).