Re: C aggregate passing (Rust kernel policy)

Steven Rostedt
2025-02-26T21:55:41Z

On Wed, 26 Feb 2025 13:42:29 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Wed, 26 Feb 2025 at 13:26, Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > As a bystander here, I just want to ask, do you mean basically to treat all
> > reads as READ_ONCE() and all writes as WRITE_ONCE()?
>
> Absolutely not.
>
> I thought I made that clear:

Sorry, I didn't make myself clear. I shouldn't have said "all reads". What
I meant was the the "initial read".

Basically:

r = READ_ONCE(*p);

and use what 'r' is from then on.

Where the compiler reads the source once and works with what it got.

To keep it from changing:

r = *p;
if (r > 1000)
goto out;
x = r;

to:

if (*p > 1000)
goto out;
x = *p;

-- Steve