Description
Follow-ups on the discussion, since:
- At least in short term, Rust will continue using C++ memory ordering model (i.e. no new memory model)
- Using two different memory models for communication via shared memory causes issues of verification, reasoning, etc.
it makes sense trying to use the existing memory model instead of Rust own one when using Rust to communicate with a different memory ordering model. In other words, for example when using Rust for Linux kernel development, following the below suggestion makes lots of sense in the short term.
so, just literally translate whatever C does. C doesnt guarantee anything about address dependencies or whatever. Rust doesnt, either. It's not getting worse. It's not getting better, either, but this is an area where doing better is really hard and where it can only be done with a global change to the Linux kernel to adopt a new memory model that is then used by both the C and Rust code in the kernel.
(original message from Ralf)
Of course, this means that the project using a different model may have UBs in the Rust code (due to data races defined by C++ memory model), but in practice, with careful usage of data races, these UBs unlikely cause any real issue.
Having this recommendation documented somewhere will help resolve issues like #348, and unblock experiment projects like Rust-for-Linux on which synchronization primitives to use.