On Fri, Dec 17, 2021 at 09:15:45PM +0000, Nadav Amit wrote:
I think that there is an assumption that once a page is COW-broken, it would never have another write-fault that might lead to COW breaking later.
Yes, that is what Linus has been explaining, AFAICT
AFAIK at least after userfaultfd-WP followed by userfaultfd-write-unprotect a page might be write-protected and go through do_wp_page() a second time to be COW-broken again. In such case, I think the FOLL_FORCE|FOLL_WRITE would not help.
Right, and this is a good reason why refcount is running into trouble, it COW's too much in cases like that because userfaultfd-WP doesn't align to the first assumption.
Jason