[BZ,#16892] Check value of futex before updating in __lll_timedlock

Message ID 1407767208-20900-1-git-send-email-bernie.ogden@linaro.org
State New
Headers show

Commit Message

Bernie Ogden Aug. 11, 2014, 2:26 p.m.
Retrying with git send-email. Patch unchanged other than whitespace fix.

2014-08-07  Bernard Ogden  <bernie.ogden@linaro.org>
	[BZ #16892]
	* sysdeps/nptl/lowlevellock.h (__lll_timedlock): Use
	atomic_compare_and_exchange_bool_acq rather than atomic_exchange_acq.

---

Comments

Roland McGrath Aug. 12, 2014, 1:39 a.m. | #1
Looks fine.
Bernie Ogden Aug. 12, 2014, 7:53 a.m. | #2
Thanks both for review. I'm not a committer - would someone commit for me?

On 12 August 2014 02:39, Roland McGrath <roland@hack.frob.com> wrote:
> Looks fine.
Will Newton Aug. 12, 2014, 8:08 a.m. | #3
On 12 August 2014 08:53, Bernie Ogden <bernie.ogden@linaro.org> wrote:
> Thanks both for review. I'm not a committer - would someone commit for me?
>
> On 12 August 2014 02:39, Roland McGrath <roland@hack.frob.com> wrote:
>> Looks fine.

I'm happy to apply it but I'm not sure if it is allowable within the
terms of the freeze. Are we too late? This change fixes a regression
on MIPS at least.
Allan McRae Aug. 12, 2014, 11:54 a.m. | #4
On 12/08/14 18:08, Will Newton wrote:
> On 12 August 2014 08:53, Bernie Ogden <bernie.ogden@linaro.org> wrote:
>> Thanks both for review. I'm not a committer - would someone commit for me?
>>
>> On 12 August 2014 02:39, Roland McGrath <roland@hack.frob.com> wrote:
>>> Looks fine.
> 
> I'm happy to apply it but I'm not sure if it is allowable within the
> terms of the freeze. Are we too late? This change fixes a regression
> on MIPS at least.
> 

OK to apply.

Allan
Will Newton Aug. 12, 2014, 11:58 a.m. | #5
On 12 August 2014 12:54, Allan McRae <allan@archlinux.org> wrote:
> On 12/08/14 18:08, Will Newton wrote:
>> On 12 August 2014 08:53, Bernie Ogden <bernie.ogden@linaro.org> wrote:
>>> Thanks both for review. I'm not a committer - would someone commit for me?
>>>
>>> On 12 August 2014 02:39, Roland McGrath <roland@hack.frob.com> wrote:
>>>> Looks fine.
>>
>> I'm happy to apply it but I'm not sure if it is allowable within the
>> terms of the freeze. Are we too late? This change fixes a regression
>> on MIPS at least.
>>
>
> OK to apply.

Thanks, pushed.

Patch

diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h
index 548a9c8..28f4ba3 100644
--- a/sysdeps/nptl/lowlevellock.h
+++ b/sysdeps/nptl/lowlevellock.h
@@ -88,12 +88,15 @@  extern int __lll_timedlock_wait (int *futex, const struct timespec *,
 extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
 					int private) attribute_hidden;
 
+/* Take futex if it is untaken.
+   Otherwise block until either we get the futex or abstime runs out.  */
 #define __lll_timedlock(futex, abstime, private)                \
   ({                                                            \
     int *__futex = (futex);                                     \
     int __val = 0;                                              \
                                                                 \
-    if (__glibc_unlikely (atomic_exchange_acq (__futex, 1)))    \
+    if (__glibc_unlikely                                        \
+        (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
       __val = __lll_timedlock_wait (__futex, abstime, private); \
     __val;                                                      \
   })