Protecting control dependencies with volatile_if()
Protecting control dependencies with volatile_if()
Posted Jun 19, 2021 22:52 UTC (Sat) by itsmycpu (guest, #139639)Parent article: Protecting control dependencies with volatile_if()
However it seems to me that this isn't really about if-statements, but about order two specific memory accesses without impacting other compiler or hardware optimizations.
So perhaps a construct like ORDER_ACCESS( A, B ) would better reflect the original intentions, and be applicable to a much larger group of use cases.
This would specifically instruct the compiler to generate code that completes previous memory accesses to A before initiating following memory accesses to B.
(And perhaps be best implemented as a compiler primitive or general language construct like barriers, and the code generation be informed by kernel engineers who have the practical experience across architectures and ideas regarding optimal code to be generated, such as using conditional branch instructions to create a hardware barrier.)
So:
tmp = READ_ONCE(A);
ORDER_ACCESS( A, B );
WRITE_ONCE(B, 1);