diff options
author | Derek Mauro <dmauro@google.com> | 2022-05-31 08:00:22 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-05-31 08:01:15 -0700 |
commit | a4cc270df18b47685e568e01bb5c825493f58d25 (patch) | |
tree | f0693fa9c295055365593aaf923fd4d3cd840024 /absl/base/internal/spinlock_linux.inc | |
parent | ea78ded7a5f999f19a12b71f5a4988f6f819f64f (diff) |
Stop using sleep timeouts for Linux futex-based SpinLock
Timeouts were once necessary when the SpinLock Unlock used an atomic
store and could therefore have a race and a missed wakeup, however,
the Unlock path now uses an atomic exchange, so the missed wakeup
cannot happen.
Fixes #1179
PiperOrigin-RevId: 452047517
Change-Id: I844944879b51b7f7ddac148e063a376cddd0d05a
Diffstat (limited to 'absl/base/internal/spinlock_linux.inc')
-rw-r--r-- | absl/base/internal/spinlock_linux.inc | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/absl/base/internal/spinlock_linux.inc b/absl/base/internal/spinlock_linux.inc index 202f7cdf..fe8ba674 100644 --- a/absl/base/internal/spinlock_linux.inc +++ b/absl/base/internal/spinlock_linux.inc @@ -57,13 +57,10 @@ static_assert(sizeof(std::atomic<uint32_t>) == sizeof(int), extern "C" { ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)( - std::atomic<uint32_t> *w, uint32_t value, int loop, + std::atomic<uint32_t> *w, uint32_t value, int, absl::base_internal::SchedulingMode) { absl::base_internal::ErrnoSaver errno_saver; - struct timespec tm; - tm.tv_sec = 0; - tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop); - syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, &tm); + syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, nullptr); } ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockWake)( |