didn't find threads that regarding "clarify APIs semantics", but kernel docs are indeed not in a very good condition. Since C does not provide same level of soundness that Rust does, there are many hidden traps.
asahi developer had a good discuss about this https://threadreaderapp.com/thread/1829852697107055047.html
These are part of the type system, so they need to be defined precisely. The answer to these questions can't be just "it depends". If there are run-time or config-dependent conditions when the same data is owned or not or immutable or not, Rust has enums, unions and unsafe escape hatches to guard access to it.
For a long time, the memory model, formally speaking, was underspecified. Both C and C++ agreed on and added a memory model in C11 and C++11.
> fencing
You can add a fence via this API: https://en.cppreference.com/w/c/atomic/atomic_thread_fence
> This varies per arch
Right, so what assembly this API will emit depends on the underlying architecture details.
Notably, the Linux kernel does not use the standard C memory model, it uses its own.
Regardless, this isn’t a slight against C. Most languages don’t have an explicit memory model at all.
However Op used “memory behavior”. The C standard definitely has defined and defined and undefined memory behaviors even pre C11. For example, dereferencing null is an undefined single threaded memory behavior that bit the kernel when the compilers started optimizing from assumptions about never reaching UB code. But for example there’s lots of defined behaviors like what happens when you dereference an aliased pointer.
And the Linux kernel definitely defined a memory model for itself before C and made all architectures conform to that.
Rust is different. The kernel Rust teams are trying to encode some safety invariant. If any of those mismatch with the C side, it breaks. Those invariant need some non trivial knowledge of rust to understand