linux/include/asm-generic
Will Deacon 0bce9c46bf 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.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Chris Mason <chris.mason@fusionio.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: <stable@vger.kernel.org>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-6e9lrw2avczr0617fzl5vqb8@git.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2012-08-13 18:46:54 +02:00
..
bitops
4level-fixup.h
atomic64.h
atomic-long.h
atomic.h
audit_change_attr.h
audit_dir_write.h
audit_read.h
audit_signal.h
audit_write.h
auxvec.h
barrier.h
bitops.h
bitsperlong.h
bug.h
bugs.h
cache.h
cacheflush.h
checksum.h
cmpxchg-local.h
cmpxchg.h
cputime.h
current.h
delay.h
device.h
div64.h
dma-coherent.h
dma-contiguous.h
dma-mapping-broken.h
dma-mapping-common.h
dma.h
emergency-restart.h
errno-base.h
errno.h
exec.h
fb.h
fcntl.h
ftrace.h
futex.h
getorder.h
gpio.h
hardirq.h
hw_irq.h
ide_iops.h
int-l64.h
int-ll64.h
io-64-nonatomic-hi-lo.h
io-64-nonatomic-lo-hi.h
io.h
ioctl.h
ioctls.h
iomap.h [PARISC] fix compile break caused by iomap: make IOPORT/PCI mapping functions conditional 2012-02-27 09:43:30 -06:00
ipcbuf.h
irq_regs.h
irq.h
irqflags.h
Kbuild
Kbuild.asm
kdebug.h
kmap_types.h
kvm_para.h
libata-portmap.h
linkage.h
local64.h
local.h
memory_model.h
mm_hooks.h
mman-common.h
mman.h
mmu_context.h
mmu.h
module.h
msgbuf.h
mutex-dec.h
mutex-null.h
mutex-xchg.h mutex: Place lock in contended state after fastpath_lock failure 2012-08-13 18:46:54 +02:00
mutex.h
page.h
param.h
parport.h
pci_iomap.h
pci-bridge.h
pci-dma-compat.h
pci.h
percpu.h
pgalloc.h
pgtable-nopmd.h
pgtable-nopud.h
pgtable.h
poll.h
posix_types.h
ptrace.h
resource.h
rtc.h
rwsem.h
scatterlist.h
sections.h
segment.h
sembuf.h
serial.h
setup.h
shmbuf.h
shmparam.h
siginfo.h
signal-defs.h
signal.h
sizes.h
socket.h
sockios.h
spinlock.h
stat.h
statfs.h
string.h
swab.h
switch_to.h
syscall.h
syscalls.h
termbits.h
termios-base.h
termios.h
timex.h
tlb.h
tlbflush.h
topology.h
types.h
uaccess-unaligned.h
uaccess.h
ucontext.h
unaligned.h
unistd.h
user.h
vga.h
vmlinux.lds.h
word-at-a-time.h
xor.h