# Memory Ordering Model Gaps (WIP) _first please notice that almost all the gaps are probably theorical gaps, in other words, they won't cause problems given current implementation of compilers_ This is a follow-up of the discussion [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/348). Basically, Rust (also C after C11) uses a different memory (ordering) model than Linux kernel, known gaps are: * atomics are not volatile in Rust: https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/volatile.20atomic.20in.20Rust.3F * but you can always use `compiler_fence`? * However even `compiler_fence` is known broken or unclear: https://github.com/rust-lang/unsafe-code-guidelines/issues/347 * People (LLVM) ["optimizes"](https://reviews.llvm.org/D141277) atomics * No `consume` ordering * TODO Which memory should be used (case-by-case): * Rust sync with Rust: using either Rust memory model or LKMM * Rust sync with C (maybe always unsound): * Use LKMM (need to implement all Linux atomics or use cross-language LTO) * Introduce a smp_mb() in Rust-for-Linux side, and use it whenever sync with C side.