1 http://sourceware.org/ml/libc-alpha/2012-01/msg00002.html
4 Has been reported as causing numerous problems in Fedora & Debian. I
5 don't think anyone has done any serious analysis of the issue, but the
6 patch has been pulled from both distributions because of the
7 instability it's introduced.
9 https://bugzilla.redhat.com/show_bug.cgi?id=769421
10 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=651899
13 commit c5a0802a682dba23f92d47f0f99775aebfbe2539
14 Author: Andreas Schwab <schwab@redhat.com>
15 Date: Mon Nov 28 13:38:19 2011 +0100
17 Handle EAGAIN from FUTEX_WAIT_REQUEUE_PI
19 2011-11-28 Andreas Schwab <schwab@redhat.com>
21 * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Handle
22 EAGAIN from FUTEX_WAIT_REQUEUE_PI.
23 * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
25 diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
26 index 54590b7..53970d7 100644
27 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
28 +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
29 @@ -134,7 +134,6 @@ __pthread_cond_wait:
34 movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %ecx
37 @@ -148,9 +147,6 @@ __pthread_cond_wait:
44 /* Normal and PI futexes dont mix. Use normal futex functions only
45 if the kernel does not support the PI futex functions. */
47 @@ -395,78 +391,6 @@ __pthread_cond_wait:
49 call __lll_unlock_wake
54 - /* FUTEX_WAIT_REQUEUE_PI returned EAGAIN. We need to
57 - /* Get internal lock. */
62 - cmpxchgl %edx, (%ebx)
64 - cmpxchgl %edx, cond_lock(%ebx)
71 - leal cond_lock(%ebx), %edx
73 -#if (LLL_SHARED-LLL_PRIVATE) > 255
76 - cmpl $-1, dep_mutex(%ebx)
79 - andl $(LLL_SHARED-LLL_PRIVATE), %ecx
81 - addl $LLL_PRIVATE, %ecx
83 - call __lll_lock_wait
86 - /* Increment the cond_futex value again, so it can be used as a new
88 - addl $1, cond_futex(%ebx)
89 - movl cond_futex(%ebx), %ebp
96 - subl $1, cond_lock(%ebx)
102 - leal cond_lock(%ebx), %eax
104 -#if (LLL_SHARED-LLL_PRIVATE) > 255
107 - cmpl $-1, dep_mutex(%ebx)
110 - andl $(LLL_SHARED-LLL_PRIVATE), %ecx
111 -#if LLL_PRIVATE != 0
112 - addl $LLL_PRIVATE, %ecx
114 - call __lll_unlock_wake
117 - /* Set the rest of SYS_futex args for FUTEX_WAIT_REQUEUE_PI. */
119 - movl dep_mutex(%ebx), %edi
123 .size __pthread_cond_wait, .-__pthread_cond_wait
124 versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait,
126 @@ -639,10 +563,6 @@ __condvar_w_cleanup:
127 .long .LcleanupEND-.Lsub_cond_futex
128 .long __condvar_w_cleanup-.LSTARTCODE
130 - .long .LcleanupSTART2-.LSTARTCODE
131 - .long .LcleanupEND2-.LcleanupSTART2
132 - .long __condvar_w_cleanup-.LSTARTCODE
134 .long .LcallUR-.LSTARTCODE
135 .long .LENDCODE-.LcallUR
137 diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
138 index d837d15..7535baa 100644
139 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
140 +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
142 #include <lowlevelcond.h>
143 #include <tcb-offsets.h>
144 #include <pthread-pi-defines.h>
145 -#include <pthread-errnos.h>
146 #include <stap-probe.h>
148 #include <kernel-features.h>
149 @@ -134,14 +133,11 @@ __pthread_cond_wait:
154 movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
155 movl $SYS_futex, %eax
159 - cmpq $-EAGAIN, %rax
161 #ifdef __ASSUME_REQUEUE_PI
164 @@ -328,70 +324,6 @@ __pthread_cond_wait:
171 - /* FUTEX_WAIT_REQUEUE_PI returned EAGAIN. We need to
175 - /* Get internal lock. */
180 - cmpxchgl %esi, (%rdi)
182 - cmpxchgl %esi, cond_lock(%rdi)
187 - addq $cond_lock, %rdi
189 - LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi)
190 - movl $LLL_PRIVATE, %eax
191 - movl $LLL_SHARED, %esi
193 - callq __lll_lock_wait
195 - subq $cond_lock, %rdi
198 - /* Increment the cond_futex value again, so it can be used as a new
200 - incl cond_futex(%rdi)
201 - movl cond_futex(%rdi), %edx
203 - /* Release internal lock. */
208 - decl cond_lock(%rdi)
213 - addq $cond_lock, %rdi
215 - LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi)
216 - movl $LLL_PRIVATE, %eax
217 - movl $LLL_SHARED, %esi
219 - /* The call preserves %rdx. */
220 - callq __lll_unlock_wake
222 - subq $cond_lock, %rdi
225 - /* Set the rest of SYS_futex args for FUTEX_WAIT_REQUEUE_PI. */
227 - mov dep_mutex(%rdi), %R8_LP
228 - leaq cond_futex(%rdi), %rdi
232 .size __pthread_cond_wait, .-__pthread_cond_wait
233 versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait,
235 @@ -544,15 +476,11 @@ __condvar_cleanup1:
236 .uleb128 .LcleanupSTART-.LSTARTCODE
237 .uleb128 .LcleanupEND-.LcleanupSTART
238 .uleb128 __condvar_cleanup1-.LSTARTCODE
240 - .uleb128 .LcleanupSTART2-.LSTARTCODE
241 - .uleb128 .LcleanupEND2-.LcleanupSTART2
242 - .uleb128 __condvar_cleanup1-.LSTARTCODE
245 .uleb128 .LcallUR-.LSTARTCODE
246 .uleb128 .LENDCODE-.LcallUR