Re: [PATCH v2 5/9] userfaultfd/selftests: use memfd_create for shmem test type

From: Peter Xu
Date: Tue Apr 13 2021 - 16:16:59 EST


On Mon, Apr 12, 2021 at 10:17:17PM -0700, Axel Rasmussen wrote:
> This is a preparatory commit. In the future, we want to be able to setup
> alias mappings for area_src and area_dst in the shmem test, like we do
> in the hugetlb_shared test. With a VMA obtained via
> mmap(MAP_ANONYMOUS | MAP_SHARED), it isn't clear how to do this.
>
> So, mmap() with an fd, so we can create alias mappings. Use memfd_create
> instead of actually passing in a tmpfs path like hugetlb does, since
> it's more convenient / simpler to run, and works just as well.
>
> Future commits will:
>
> 1. Setup the alias mappings.
> 2. Extend our tests to actually take advantage of this, to test new
> userfaultfd behavior being introduced in this series.
>
> Also, a small fix in the area we're changing: when the hugetlb setup
> fails in main(), pass in the right argv[] so we actually print out the
> hugetlb file path.
>
> Signed-off-by: Axel Rasmussen <axelrasmussen@xxxxxxxxxx>

Reviewed-by: Peter Xu <peterx@xxxxxxxxxx>

--
Peter Xu