Re: [PATCH v11 1/7] userfaultfd: Add UFFD WP Async support

Muhammad Usama Anjum
2023-03-17T14:01:43Z

Thanks you for sending. I'll perform testing and share results next.

On 3/17/23 12:20 AM, Peter Xu wrote:
> Hello, Muhammad,
>
> On Thu, Mar 09, 2023 at 06:57:12PM +0500, Muhammad Usama Anjum wrote:
>> Add new WP Async mode (UFFD_FEATURE_WP_ASYNC) which resolves the page
>> faults on its own. It can be used to track that which pages have been
>> written-to from the time the pages were write-protected. It is very
>> efficient way to track the changes as uffd is by nature pte/pmd based.
>>
>> UFFD synchronous WP sends the page faults to the userspace where the
>> pages which have been written-to can be tracked. But it is not efficient.
>> This is why this asynchronous version is being added. After setting the
>> WP Async, the pages which have been written to can be found in the pagemap
>> file or information can be obtained from the PAGEMAP_IOCTL.
>>
>> Suggested-by: Peter Xu <peterx@redhat.com>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>
> Here's the patch that can enable WP_ASYNC for all kinds of memories (as I
> promised..). Currently I only tested btrfs (besides the common three)
> which is the major fs I use locally, but I guess it'll also enable the rest
> no matter what's underneath, just like soft-dirty.
>
> As I mentioned, I just feel it very unfortunate to have a lot of suffixes
> for the UFFD_FEATURE_* on types of memory, and I hope we get rid of it for
> this WP_ASYNC from the start because the workflow should really be similar
> to anon/shmem handling for most of the rest, just a few tweaks here and
> there.
>
> I had a feeling that some type of special VMA will work weirdly, but let's
> see.. so far I don't come up with any.
>
> If the patch looks fine to you, please consider replace this patch with
> patch 1 of mine where I attached. Then patch 1 can be reviewed alongside
> with your series.
>
> Logically patch 1 can be reviewed separately too, because it works
> perfectly afaiu without the atomic version of pagemap already. But on my
> side I don't think it justifies anything really matters, so unless someone
> thinks it a good idea to post / review / merge it separately, you can keep
> that with your new pagemap ioctl.
>
> Patch 2 is only for your reference. It's not for merging quality so please
> don't put it into your series. I do plan to cleanup the userfaultfd
> selftests in the near future first (when I wrote this I am more eager to do
> so..). I also think your final pagemap test cases can cover quite a bit.
>
> Thanks,
>

--
BR,
Muhammad Usama Anjum