On Mon, Oct 20, 2025 at 09:00:50PM +0200, David Hildenbrand wrote:
Just FYI, because it might be interesting in this context.
For anonymous memory we have this working by only writing the folio out if
it is completely unmapped and there are no unexpected folio references/pins
(see pageout()), and only allowing to write to such a folio ("reuse") if
SWP_STABLE_WRITES is not set (see do_swap_page()).
So once we start writeback the folio has no writable page table mappings
(unmapped) and no GUP pins. Consequently, when trying to write to it we can
just fallback to creating a page copy without causing trouble with GUP pins.
Yeah. But anonymous is the easy case, the pain is direct I/O to file
mappings. Mapping the right answer is to just fail pinning them and fall
back to (dontcache) buffered I/O.