summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2022-05-31 08:00:22 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-05-31 08:01:15 -0700
commita4cc270df18b47685e568e01bb5c825493f58d25 (patch)
treef0693fa9c295055365593aaf923fd4d3cd840024 /absl/base
parentea78ded7a5f999f19a12b71f5a4988f6f819f64f (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')
-rw-r--r--absl/base/internal/spinlock_linux.inc7
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)(