• Axel Rasmussen's avatar
    userfaultfd/selftests: use memfd_create for shmem test type · fa2c2b58
    Axel Rasmussen authored
    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.
    
    Link: https://lkml.kernel.org/r/20210503180737.2487560-8-axelrasmussen@google.comSigned-off-by: default avatarAxel Rasmussen <axelrasmussen@google.com>
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Brian Geffon <bgeffon@google.com>
    Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Jerome Glisse <jglisse@redhat.com>
    Cc: Joe Perches <joe@perches.com>
    Cc: Kirill A. Shutemov <kirill@shutemov.name>
    Cc: Lokesh Gidra <lokeshgidra@google.com>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Cc: Mina Almasry <almasrymina@google.com>
    Cc: Oliver Upton <oupton@google.com>
    Cc: Shaohua Li <shli@fb.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Stephen Rothwell <sfr@canb.auug.org.au>
    Cc: Wang Qing <wangqing@vivo.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    fa2c2b58
userfaultfd.c 43.1 KB