Re: [PATCH v1 2/3] mm/gup: use gup_can_follow_protnone() also in GUP-fast
From: Jason Gunthorpe
Date: Tue Aug 30 2022 - 18:39:30 EST
On Tue, Aug 30, 2022 at 01:12:53PM -0700, John Hubbard wrote:
> As long as we continue to sort-of-accidentally use atomic_add_unless(),
> which returns a value, instead of atomic_add(), which does not. :)
I should say I didn't have time to carefully check what put_page was
doing, but IIRC it is an atomic_dec_return to decide if it should free
the page.
The conditional is pretty much inherent to the model, because 0 is
special it always has to be checked. Not so accidental
But you might make the case that these could be the relaxed versions
of the atomic...
> Likewise on the put_page() side: we are depending on the somewhat
> accidental (from the perspective of memory barriers) use of
> atomics that return values.
>
> Maybe it would be good to add a little note at each site, to that
> effect?
It would be fantastic if things that are required to be
acquire/releases are documented as acquire/release :)
It is incredibly subtle stuff and all carefully inlined for maximum
performance.
Jason