On Thu, Aug 11, 2022 at 12:34:35PM +0200, David Hildenbrand wrote:
Reason is that uffd-wp doesn't clear the uffd-wp PTE bit when unregistering and consequently keeps the PTE writeprotected. Reason for this is to avoid the additional overhead when unregistering. Note that this is the case also for !hugetlb and that we will end up with writable PTEs that still have the uffd-wp PTE bit set once we return from hugetlb_wp(). I'm not touching the uffd-wp PTE bit for now, because it seems to be a generic thing -- wp_page_reuse() also doesn't clear it.
This may justify that lazy reset of ptes may not really be a good idea, including anonymous. I'm indeed not aware of any app that do frequent reg/unreg at least.
I'll prepare a patch to change it from uffd side too.
Thanks again for finding this problem.