On Wed, May 28, 2025 at 05:45:42PM +0200, Oscar Salvador wrote:
I thought the main reason was because PageLock protects us against writes, so when copying (in case of copying the underlying file), we want the file to be stable throughout the copy?
The folio can already been mapped writable in other VM_SHARED vmas.. which means the userspace is free to write whatever while kernel copying, right?
IIUC there's no way to make sure the folio content is stable as long as it can be mapped, CoW should just happen and the result of the copied page is unpredictable if there're concurrent writes.
IMHO it's the userspace's job if it wants to make sure the folio (when triggering CoW) copies a stable piece of content.
That's also why I was thinking maybe we don't need the folio lock at all. We still will need a refcount though for the pagecache to make sure it wont' get freed concurrently.
Thanks,