On Wed, Sep 01, 2021 at 06:19:03PM +0200, David Hildenbrand wrote:
I wouldn't think it works everywhere, bit it works in a lot of places,
and it is a heck of a lot better than what is proposed here. I'd
rather see the places that can use it be moved, and the few places
that can't be opencoded.
Well, I used ptep_get_map_lock() and friends. But hacking directly into
ptep_map_lock() and friends wasn't possible due to all the corner cases.
Sure, I'm not surprised you can't get every single case, but that just
suggest we need two API families, today's to support the special cases
and a different one for the other regular simple cases.
A new function family pte_try_map/_locked() and paired unmap that can
internally do the recounting and THP trickery and convert the easy
Very rough counting suggest at least half of the pte_offset_map_lock()
call sites can trivially use the simpler API.
The other cases can stay as is and get open coded refcounts, or maybe
someone will have a better idea once they are more clearly identified.
But I don't think we should take a performance hit of additional
atomics in cases like GUP where this is trivially delt with by using a