Summary:
Original sys_membarrier call supported an EXPEDITED flag, that was much faster than the current version, at some extra CPU cost.
The basic idea was a normal one would be used in a background thread, while EXPEDITED would be useful inline in foreground threads.
Add the flag here, and use the mprotect hack until sys_membarrier supports both.
Reviewed By: magedm
Differential Revision:
D5292680
fbshipit-source-id:
30edf27514976991bbaa8e776a7138eb815ade36
}
static void* get() {
- static auto ptr =
- kIsLinux && !detail::sysMembarrierAvailable() ? create() : nullptr;
+ static auto ptr = kIsLinux ? create() : nullptr;
return ptr;
}
}
}
-void asymmetricHeavyBarrier() {
+void asymmetricHeavyBarrier(AMBFlags flags) {
if (kIsLinux) {
static const bool useSysMembarrier = detail::sysMembarrierAvailable();
- if (useSysMembarrier) {
+ // sys_membarrier currently does not support EXPEDITED
+ if (useSysMembarrier && flags != AMBFlags::EXPEDITED) {
auto r = detail::sysMembarrier();
checkUnixError(r, "membarrier");
} else {
namespace folly {
+enum class AMBFlags {
+ NORMAL,
+ EXPEDITED,
+};
+
FOLLY_ALWAYS_INLINE void asymmetricLightBarrier() {
if (kIsLinux) {
asm_volatile_memory();
}
}
-void asymmetricHeavyBarrier();
+void asymmetricHeavyBarrier(AMBFlags flags = AMBFlags::NORMAL);
}