[patch] pthread_mutex asserts on s390(x)
Michael Matz
matz@suse.de
Mon Nov 3 14:39:00 GMT 2008
Hi,
the attached testcase (reduced from one in libapr) frequently triggers the
mutex->__data.__owner == 0 assert. It turns out the problem are missing
memory clobbers in the inline asm versions of atomic cmp-and-swap. As
they are also used to implement the low-level-locks they need to act as
barrier. With the patch the load is not reordered anymore and the
testcase survices.
Ciao,
Michael.
--
* sysdeps/s390/bits/atomic.h
(__arch_compare_and_exchange_val_32_acq,
__arch_compare_and_exchange_val_64_acq): Add "memory" clobber.
Index: sysdeps/s390/bits/atomic.h
===================================================================
--- sysdeps/s390/bits/atomic.h.orig
+++ sysdeps/s390/bits/atomic.h
@@ -56,7 +56,7 @@ typedef uintmax_t uatomic_max_t;
__typeof (*mem) __archold = (oldval); \
__asm __volatile ("cs %0,%2,%1" \
: "+d" (__archold), "=Q" (*__archmem) \
- : "d" (newval), "m" (*__archmem) : "cc" ); \
+ : "d" (newval), "m" (*__archmem) : "cc", "memory" ); \
__archold; })
#ifdef __s390x__
@@ -65,7 +65,7 @@ typedef uintmax_t uatomic_max_t;
__typeof (*mem) __archold = (oldval); \
__asm __volatile ("csg %0,%2,%1" \
: "+d" (__archold), "=Q" (*__archmem) \
- : "d" ((long) (newval)), "m" (*__archmem) : "cc" ); \
+ : "d" ((long) (newval)), "m" (*__archmem) : "cc", "memory" ); \
__archold; })
#else
/* For 31 bit we do not really need 64-bit compare-and-exchange. We can
-------------- next part --------------
A non-text attachment was scrubbed...
Name: blathread.c
Type: text/x-csrc
Size: 2402 bytes
Desc:
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20081103/4757092d/attachment.bin>
More information about the Libc-alpha
mailing list