Skip to content

Commit

Permalink
[libc] Add PAUSE instruction for the RPC spin loop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jhuber6 committed Jul 28, 2023
1 parent 4f52210 commit 9ffde19
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc/src/__support/RPC/rpc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ffde19

Please sign in to comment.