Re: [PATCH 3/4] mm: Add free()

From: Matthew Wilcox
Date: Tue Apr 03 2018 - 07:41:26 EST


On Tue, Apr 03, 2018 at 10:50:59AM +0200, Pavel Machek wrote:
> > gcc already does some nice optimisations around free(). For example, it
> > can eliminate dead stores:
>
> Are we comfortable with that optimalization for kernel?
>
> us: "Hey, let's remove those encryption keys before freeing memory."
> gcc: :-).
>
> us: "Hey, we want to erase lock magic values not to cause confusion
> later."
> gcc: "I like confusion!"
>
> Yes, these probably can be fixed by strategic "volatile" and/or
> barriers, but...

Exactly, we should mark those sites explicitly with volatile so that
they aren't dead stores.