Re: [RFC PATCH 11/13] fs/userfaultfd: complete write asynchronously

From: Nadav Amit
Date: Wed Dec 02 2020 - 02:13:49 EST


> On Nov 28, 2020, at 4:45 PM, Nadav Amit <nadav.amit@xxxxxxxxx> wrote:
>
> From: Nadav Amit <namit@xxxxxxxxxx>
>
> Userfaultfd writes can now be used for copy/zeroing. When using iouring
> with userfaultfd, performing the copying/zeroing on the faulting thread
> instead of the handler/iouring thread has several advantages:
>
> (1) The data of the faulting thread will be available on the local
> caches, which would make subsequent memory accesses faster.
>
> (2) find_vma() would be able to use the vma-cache, which cannot be done
> from a different process or io-uring kernel thread.
>
> (3) The page is more likely to be allocated on the correct NUMA node.
>
> To do so, userfaultfd work queue structs are extended to hold the
> information that is required for the faulting thread to copy/zero. The
> handler wakes one of the faulting threads to perform the copy/zero and
> that thread wakes the other threads after the zero/copy is done.

I noticed some bugs of mine in this patch, but more importantly I realized
that the there may be a more performant solution to do the copying on the
faulting thread - without async-writes.

Please do not review this patch and the next one (12/13).

Feedback for the rest of the series is of course welcomed.

Regards,
Nadav