Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yield logic for ARM processor #1325

Merged
merged 3 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions api/include/opentelemetry/common/spin_lock_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ class SpinLockMutex
__builtin_ia32_pause();
# endif
#elif defined(__arm__)
// This intrinsic should fail to be found if YIELD is not supported on the current
// processor.
__yield();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way (e.g. macro or something) to determine if __yield is available?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious where this pattern comes from.

BTW, do we need add CI for arm?

Copy link
Member Author

@lalitb lalitb Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way (e.g. macro or something) to determine if __yield is available?

There is no standard approach to do this. ARM vendors may choose not to implement these extensions.

Curious where this pattern comes from.

This patten of yielding ? It was written by Josh. I would prefer to let these platform specific code go away as long term solution, and rely on yield provided by standard C++ library.

BTW, do we need add CI for arm?

Yes we need it. @esigo has done some initial work #1165, but seems builds are very slow, as there is no ARM virtual machines provided by github.

__asm__ volatile("yield" ::: "memory");
#else
// TODO: Issue PAGE/YIELD on other architectures.
#endif
Expand Down
2 changes: 1 addition & 1 deletion api/test/common/spinlock_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void BM_ProcYieldSpinLockThrashing(benchmark::State &s)
__builtin_ia32_pause();
# endif
#elif defined(__arm__)
__yield();
__asm__ volatile("yield" ::: "memory");
#endif
}
},
Expand Down