On 02.05.23 20:59, Peter Zijlstra wrote:
On Tue, May 02, 2023 at 07:34:06PM +0200, David Hildenbrand wrote:
Now, if we read folio->mapping after checking if the page we pinned is still
mapped (PTE unchanged), at least the page we pinned cannot be reused in the
meantime. I suspect that we can still read "NULL" on the second read. But
whatever we dereference from the first read should still be valid, even if
the second read would have returned NULL ("rcu freeing").
Right, but given it's the compiler adding loads we're not sure what if
anything it uses and it gets very hard to reason about the code.
This is where READ_ONCE() helps, we instruct the compiler to only do a
single load and we can still reason about the code.
I completely agree, and I think we should fix that in
page_is_secretmem() as well.
--
Thanks,
David / dhildenb