From 13e14ca0e038827fccf54291ac114a7acb0d2c85 Mon Sep 17 00:00:00 2001 From: Lokesh Gidra Date: Thu, 13 May 2021 05:10:09 -0700 Subject: [PATCH] Revert "FROMGIT: userfaultfd/selftests: use memfd_create for shmem test type" This reverts commit 94f1573615148a252263b52952fd690b06efbb2b as an updated version of the patch-set will be merged later. Signed-off-by: Lokesh Gidra Bug: 187930641 Change-Id: I808f6c58429c83f03eae2ad2cbe65a232b2505c8 --- tools/testing/selftests/vm/userfaultfd.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 6c14c0126271..45d0407d39d6 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -83,7 +83,6 @@ static bool test_uffdio_wp = false; static bool test_uffdio_minor = false; static bool map_shared; -static int shm_fd; static int huge_fd; static char *huge_fd_off0; static unsigned long long *count_verify; @@ -277,11 +276,8 @@ static void shmem_release_pages(char *rel_area) static void shmem_allocate_area(void **alloc_area) { - unsigned long offset = - alloc_area == (void **)&area_src ? 0 : nr_pages * page_size; - *alloc_area = mmap(NULL, nr_pages * page_size, PROT_READ | PROT_WRITE, - MAP_SHARED, shm_fd, offset); + MAP_ANONYMOUS | MAP_SHARED, -1, 0); if (*alloc_area == MAP_FAILED) err("mmap of memfd failed"); } @@ -1441,16 +1437,6 @@ int main(int argc, char **argv) err("Open of %s failed", argv[4]); if (ftruncate(huge_fd, 0)) err("ftruncate %s to size 0 failed", argv[4]); - } else if (test_type == TEST_SHMEM) { - shm_fd = memfd_create(argv[0], 0); - if (shm_fd < 0) - err("memfd_create"); - if (ftruncate(shm_fd, nr_pages * page_size * 2)) - err("ftruncate"); - if (fallocate(shm_fd, - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, - nr_pages * page_size * 2)) - err("fallocate"); } printf("nr_pages: %lu, nr_pages_per_cpu: %lu\n", nr_pages, nr_pages_per_cpu);