Re: C aggregate passing (Rust kernel policy)

Linus Torvalds
2025-02-27T00:04:39Z

On Wed, 26 Feb 2025 at 15:27, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> My point is that the compiler is free to turn that into:
>
> r = READ_ONCE(global);
> if (r > 1000)
> goto out;
> x = r;
>
> and not change the expected result.

Yes.

It is safe to *combine* reads - it's what the CPU will effectively do
anyway (modulo MMIO, which as mentioned is why volatile is so special
and so different).

It's just not safe to split them.

Linus