* [PATCH] Adjust wait logic to limit spurious evalution of wait predicate.
@ 2020-05-24 22:06 Thomas Rodgers
2020-05-25 2:17 ` Thomas Rodgers
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Rodgers @ 2020-05-24 22:06 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: Thomas Rodgers
* include/bits/atomic_wait.h (__waiters::_M_do_wait): adjust wakeup logic.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Adjust wait logic to limit spurious evalution of wait predicate.
2020-05-24 22:06 [PATCH] Adjust wait logic to limit spurious evalution of wait predicate Thomas Rodgers
@ 2020-05-25 2:17 ` Thomas Rodgers
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Rodgers @ 2020-05-25 2:17 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: Thomas Rodgers
[-- Attachment #1: Type: text/plain, Size: 28 bytes --]
And this time, with patch.
[-- Attachment #2: wake_up_fix.patch --]
[-- Type: application/octet-stream, Size: 1509 bytes --]
commit fe8959f61a0945662c2521b3ea47fbc2b751e881
Author: Thomas Rodgers <rodgert@appliantology.com>
Date: Sun May 24 15:00:13 2020 -0700
Adjust wait logic to limit spurious evalution of wait predicate.
* include/bits/atomic_wait.h (__waiters::_M_do_wait): adjust wakeup
logic.
diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h
index 92c1e2526ed..cce11ae1cf5 100644
--- a/libstdc++-v3/include/bits/atomic_wait.h
+++ b/libstdc++-v3/include/bits/atomic_wait.h
@@ -138,24 +138,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
void
- _M_do_wait(__platform_wait_t __version) noexcept
+ _M_do_wait(__platform_wait_t __old) noexcept
{
-#ifdef _GLIBCXX_HAVE_LINUX_FUTEX
- __platform_wait(&_M_ver, __version);
-#else
- __platform_wait_t __cur = 0;
- while (__cur <= __version)
+ __platform_wait_t __cur;
+ __atomic_load(&_M_ver, &__cur, __ATOMIC_ACQUIRE);
+ while (__cur == __old)
{
+#ifdef _GLIBCXX_HAVE_LINUX_FUTEX
+ __platform_wait(&_M_ver, __cur);
+#else
__waiters::__lock_t __l(_M_mtx);
auto __e = __gthread_cond_wait(&_M_cv, __l.mutex()->native_handle());
if (__e)
std::terminate();
- __platform_wait_t __last = __cur;
- __atomic_load(&_M_ver, &__cur, __ATOMIC_ACQUIRE);
- if (__cur < __last)
- break; // break the loop if version overflows
- }
#endif
+ __atomic_load(&_M_ver, &__cur, __ATOMIC_ACQUIRE);
+ }
}
__platform_wait_t
[-- Attachment #3: Type: text/plain, Size: 171 bytes --]
> On May 24, 2020, at 3:06 PM, Thomas Rodgers <rodgert@appliantology.com> wrote:
>
> * include/bits/atomic_wait.h (__waiters::_M_do_wait): adjust wakeup logic.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-25 2:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24 22:06 [PATCH] Adjust wait logic to limit spurious evalution of wait predicate Thomas Rodgers
2020-05-25 2:17 ` 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).