[libc-commits] [libc] 9ffde19 - [libc] Add PAUSE instruction for the RPC spin loop
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Fri Jul 28 16:09:10 PDT 2023
Author: Joseph Huber
Date: 2023-07-28T18:09:01-05:00
New Revision: 9ffde19d112e71ac5716d07f48fa20d85232adf9
URL: https://github.com/llvm/llvm-project/commit/9ffde19d112e71ac5716d07f48fa20d85232adf9
DIFF: https://github.com/llvm/llvm-project/commit/9ffde19d112e71ac5716d07f48fa20d85232adf9.diff
LOG: [libc] Add PAUSE instruction for the RPC spin loop
The other architectures use a brief sleep to defer work during this spin
loop that checks the RPC mailboxes. This patch adds one for x64 to
improve usage when running the server.
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D156566
Added:
Modified:
libc/src/__support/RPC/rpc_util.h
Removed:
################################################################################
diff --git a/libc/src/__support/RPC/rpc_util.h b/libc/src/__support/RPC/rpc_util.h
index 910eceece12887..f4f5a9a4573777 100644
--- a/libc/src/__support/RPC/rpc_util.h
+++ b/libc/src/__support/RPC/rpc_util.h
@@ -26,6 +26,8 @@ LIBC_INLINE void sleep_briefly() {
LIBC_INLINE_ASM("nanosleep.u32 64;" ::: "memory");
#elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
__builtin_amdgcn_s_sleep(2);
+#elif defined(LIBC_TARGET_ARCH_IS_X86)
+ __builtin_ia32_pause();
#else
// Simply do nothing if sleeping isn't supported on this platform.
#endif
More information about the libc-commits
mailing list