public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Strengthen memory order for atomic<T>::wait/notify
@ 2022-02-09 17:35 Thomas Rodgers
  2022-02-09 20:36 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Rodgers @ 2022-02-09 17:35 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc Patches

[-- Attachment #1: Type: text/plain, Size: 88 bytes --]

This patch changes the memory order used in the spin wait code to match
that of libc++.

[-- Attachment #2: 0001-libstdc-Strengthen-memory-order-for-atomic-T-wait-no.patch --]
[-- Type: text/x-patch, Size: 1373 bytes --]

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(-)

diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index 6ce7f9343cf..125b1cad886 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libstdc++: Strengthen memory order for atomic<T>::wait/notify
  2022-02-09 17:35 [PATCH] libstdc++: Strengthen memory order for atomic<T>::wait/notify Thomas Rodgers
@ 2022-02-09 20:36 ` Jonathan Wakely
  2022-02-10 18:22   ` Thomas Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2022-02-09 20:36 UTC (permalink / raw)
  To: Thomas Rodgers; +Cc: libstdc++, gcc Patches

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).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libstdc++: Strengthen memory order for atomic<T>::wait/notify
  2022-02-09 20:36 ` Jonathan Wakely
@ 2022-02-10 18:22   ` Thomas Rodgers
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Rodgers @ 2022-02-10 18:22 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc Patches

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).
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-10 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 17:35 [PATCH] libstdc++: Strengthen memory order for atomic<T>::wait/notify Thomas Rodgers
2022-02-09 20:36 ` Jonathan Wakely
2022-02-10 18:22   ` Thomas Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).