On Thu, Jan 28, 2021 at 02:48:19PM -0800, Axel Rasmussen wrote: > Fix a dormant bug in userfaultfd_events_test(), where we did > `return faulting_process(0)` instead of `exit(faulting_process(0))`. > This caused the forked process to keep running, trying to execute any > further test cases after the events test in parallel with the "real" > process. > > Add a simple test case which exercises minor faults. In short, it does > the following: > > 1. "Sets up" an area (area_dst) and a second shared mapping to the same > underlying pages (area_dst_alias). > > 2. Register one of these areas with userfaultfd, in minor fault mode. > > 3. Start a second thread to handle any minor faults. > > 4. Populate the underlying pages with the non-UFFD-registered side of > the mapping. Basically, memset() each page with some arbitrary > contents. > > 5. Then, using the UFFD-registered mapping, read all of the page > contents, asserting that the contents match expectations (we expect > the minor fault handling thread can modify the page contents before > resolving the fault). > > The minor fault handling thread, upon receiving an event, flips all the > bits (~) in that page, just to prove that it can modify it in some > arbitrary way. Then it issues a UFFDIO_CONTINUE ioctl, to setup the > mapping and resolve the fault. The reading thread should wake up and see > this modification. > > Currently the minor fault test is only enabled in hugetlb_shared mode, > as this is the only configuration the kernel feature supports. > > Signed-off-by: Axel Rasmussen <axelrasmussen@xxxxxxxxxx> Reviewed-by: Peter Xu <peterx@xxxxxxxxxx> -- Peter Xu