Commit 1f35a33d authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

Have YIELD_PROCESSOR sleep for 1ms under TSAN

TSAN intercepts atomic accesses and uses locking. Since YIELD_PROCESSOR
is used in spinlock loops in conjunction with atomic accesses, such
spinlock loops can exhibit starvation in TSAN. To work around the
problem, have YIELD_PROCESSOR sleep the process for 1ms.

Change-Id: I042368cfc6b55abdba5c897a8f23cc633a70ba13
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3651514Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80679}
parent 71fb9809
......@@ -11,6 +11,16 @@
// other hyper-thread on this core. See the following for context:
// https://software.intel.com/en-us/articles/benefitting-power-and-performance-sleep-loops
#if defined(THREAD_SANITIZER)
#include "src/base/platform/platform.h"
// TSAN intercepts atomic accesses and uses locking. Since YIELD_PROCESSOR is
// used in spinlock loops in conjunction with atomic accesses, such spinlock
// loops can exhibit starvation in TSAN. To work around the problem, have
// YIELD_PROCESSOR sleep the process for 1ms.
#define YIELD_PROCESSOR base::OS::Sleep(base::TimeDelta::FromMilliseconds(1))
#else // !THREAD_SANITIZER
#if defined(V8_CC_MSVC)
// MSVC does not support inline assembly via __asm__ and provides compiler
// intrinsics instead. Check if there is a usable intrinsic.
......@@ -48,6 +58,8 @@
#endif // V8_CC_MSVC
#endif // THREAD_SANITIZER
#ifndef YIELD_PROCESSOR
#define YIELD_PROCESSOR ((void)0)
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment