Re: [PATCH 0/9] userfaultfd: add minor fault handling

From: Peter Xu
Date: Thu Jan 21 2021 - 14:15:33 EST


On Fri, Jan 15, 2021 at 11:04:42AM -0800, Axel Rasmussen wrote:
> UFFDIO_COPY and UFFDIO_ZEROPAGE cannot be used to resolve minor faults. Without
> modifications, the existing codepath assumes a new page needs to be allocated.
> This is okay, since userspace must have a second non-UFFD-registered mapping
> anyway, thus there isn't much reason to want to use these in any case (just
> memcpy or memset or similar).
>
> - If UFFDIO_COPY is used on a minor fault, -EEXIST is returned.

When minor fault the dst VM will report to src with the address. The src could
checkup whether dst contains the latest data on that (pmd) page and either:

- it's latest, then tells dst, dst does UFFDIO_CONTINUE

- it's not latest, then tells dst (probably along with the page data? if
hugetlbfs doesn't support double map, we'd need to batch all the dirty
small pages in one shot), dst does whatever to replace the page

Then, I'm thinking what would be the way to replace an old page.. is that one
FALLOC_FL_PUNCH_HOLE plus one UFFDIO_COPY at last?

Thanks,

--
Peter Xu