Don���t use MEMBARRIER_CMD_SHARED under any circumstance: its performance hit is potentially catastrophic:
https://lttng.org/blog/2018/01/15/membarrier-system-call-performance-and-use...
Also, dotnet core has code paths for a few more platforms so you might want to pick some of that too.
https://github.com/dotnet/runtime/blob/7be37908e5a1cbb83b1062768c1649827eeac...