Re: C aggregate passing (Rust kernel policy)
From: Linus Torvalds
Date: Wed Feb 26 2025 - 19:04:49 EST
On Wed, 26 Feb 2025 at 15:27, Steven Rostedt <rostedt@xxxxxxxxxxx> 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