linux-kernel-test/arch
Hirokazu Takata 91f4ab056d [PATCH] m32r: Fix sys_tas() syscall
This patch fixes a deadlock problem of the m32r SMP kernel.

In the m32r kernel, sys_tas() system call is provided as a test-and-set
function for userspace, for backward compatibility.

In some multi-threading application program, deadlocks were rarely caused
at sys_tas() funcion.  Such a deadlock was caused due to a collision of
__pthread_lock() and __pthread_unlock() operations.

The "tas" syscall is repeatedly called by pthread_mutex_lock() to get a
lock, while a lock variable's value is not 0.  On the other hand,
pthead_mutex_unlock() sets the lock variable to 0 for unlocking.

In the previous implementation of sys_tas() routine, there was a
possibility that a unlock operation was ignored in the following case:

- Assume a lock variable (*addr) was equal to 1 before sys_tas() execution.
- __pthread_unlock() operation is executed by the other processor
  and the lock variable (*addr) is set to 0, between a read operation
  ("oldval = *addr;") and the following write operation ("*addr = 1;")
  during a execution of sys_tas().

In this case, the following write operation ("*addr = 1;") overwrites the
__pthread_unlock() result, and sys_tas() fails to get a lock in the next
turn and after that.

According to the attatched patch, sys_tas() returns 0 value in the next
turn and deadlocks never happen.

Signed-off-by: Hitoshi Yamamoto <Yamamoto.Hitoshi@ap.MitsubishiElectric.co.jp>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-11-28 14:42:24 -08:00
..
alpha [PATCH] sched: resched and cpu_idle rework 2005-11-09 07:56:33 -08:00
arm [ARM] Shut up gcc warning in clps7500 core.c 2005-11-21 17:03:15 +00:00
arm26 [PATCH] sched: disable preempt in idle tasks 2005-11-09 07:56:33 -08:00
cris [PATCH] sched: disable preempt in idle tasks 2005-11-09 07:56:33 -08:00
frv [PATCH] FRV: Make the FRV arch work again 2005-11-28 14:42:23 -08:00
h8300 [PATCH] sched: disable preempt in idle tasks 2005-11-09 07:56:33 -08:00
i386 [PATCH] PCI: direct.c: DBG 2005-11-23 23:04:27 -08:00
ia64 [PATCH] kprobes: Fix return probes on sys_execve 2005-11-23 16:08:39 -08:00
m32r [PATCH] m32r: Fix sys_tas() syscall 2005-11-28 14:42:24 -08:00
m68k [PATCH] m68k: convert thread flags to use bit fields 2005-11-13 18:14:14 -08:00
m68knommu [PATCH] m68knommu: move some platform irq support out of irq.h 2005-11-07 08:00:47 -08:00
mips [MIPS] Update defconfigs 2005-11-17 16:23:58 +00:00
parisc [PARISC] Remove unused variable in signal.c 2005-11-17 16:43:52 -05:00
powerpc mm: re-architect the VM_UNPAGED logic 2005-11-28 14:34:23 -08:00
ppc powerpc: Fix a couple of compile warnings for 32-bit compiles 2005-11-18 15:54:12 +11:00
s390 [PATCH] sched: resched and cpu_idle rework 2005-11-09 07:56:33 -08:00
sh [PATCH] sched: resched and cpu_idle rework 2005-11-09 07:56:33 -08:00
sh64 [PATCH] sched: resched and cpu_idle rework 2005-11-09 07:56:33 -08:00
sparc [PATCH] sparc: convert IO remapping to VM_PFNMAP 2005-11-28 14:35:36 -08:00
sparc64 [PATCH] sparc: convert IO remapping to VM_PFNMAP 2005-11-28 14:35:36 -08:00
um [PATCH] uml: eliminate use of libc PAGE_SIZE 2005-11-22 09:13:41 -08:00
v850 [PATCH] v850: use generic hardirq code 2005-11-15 08:59:20 -08:00
x86_64 [PATCH] kprobes: Fix return probes on sys_execve 2005-11-23 16:08:39 -08:00
xtensa Merge master.kernel.org:/home/rmk/linux-2.6-drvmodel 2005-11-11 09:24:26 -08:00