Re: C aggregate passing (Rust kernel policy)

From: Linus Torvalds
Date: Wed Feb 26 2025 - 18:19:17 EST


On Wed, 26 Feb 2025 at 14:34, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> Correct, but if the variable had some other protection, like a lock held
> when this function was called, it is fine to do and the compiler may
> optimize it or not and still have the same result.

Sure.

But locking isn't always there. And shouldn't always be there. Lots of
lockless algorithms exist, and some of them are very simple indeed ("I
set a flag, you read a flag, you get one or the other value")

Linus