libstdc++: Strengthen memory order for atomic<T>::wait/notify
Commit Message
This patch changes the memory order used in the spin wait code to match
that of libc++.
Comments
On Wed, 9 Feb 2022 at 17:35, Thomas Rodgers via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> This patch changes the memory order used in the spin wait code to match
> that of libc++.
OK for trunk (and gcc-11 if needed).
Committed to trunk, backported to gcc-11.
On Wed, Feb 9, 2022 at 12:37 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> On Wed, 9 Feb 2022 at 17:35, Thomas Rodgers via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > This patch changes the memory order used in the spin wait code to match
> > that of libc++.
>
> OK for trunk (and gcc-11 if needed).
>
>
From 92caa08b272520ec4a272b302b37d8fb47afb2ab Mon Sep 17 00:00:00 2001
From: Thomas Rodgers <rodgert@appliantology.com>
Date: Wed, 9 Feb 2022 09:26:00 -0800
Subject: [PATCH] libstdc++: Strengthen memory order for atomic<T>::wait/notify
(spinning)
This patch changes the memory order used in the spin wait code to match
that of libc++.
libstdc++-v3/ChangeLog:
* includ/bits/atomic_wait.h (__waiter_base::_S_do_spin,
__waiter_base::_S_do_spin_v): Change memory order from relaxed
to acquire.
---
libstdc++-v3/include/bits/atomic_wait.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -332,7 +332,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
else
{
- __atomic_load(__addr, &__val, __ATOMIC_RELAXED);
+ __atomic_load(__addr, &__val, __ATOMIC_ACQUIRE);
}
return __atomic_spin(__pred, __spin);
}
@@ -353,7 +353,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__platform_wait_t& __val,
_Spin __spin = _Spin{ })
{
- __atomic_load(__addr, &__val, __ATOMIC_RELAXED);
+ __atomic_load(__addr, &__val, __ATOMIC_ACQUIRE);
return __atomic_spin(__pred, __spin);
}
--
2.34.1