Revert "FROMGIT: userfaultfd/selftests: use memfd_create for shmem test type"

This reverts commit 94f1573615 as an
updated version of the patch-set will be merged later.

Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Bug: 187930641
Change-Id: I808f6c58429c83f03eae2ad2cbe65a232b2505c8
This commit is contained in:
Lokesh Gidra
2021-05-13 05:10:09 -07:00
committed by Suren Baghdasaryan
parent 72a3f935ad
commit 13e14ca0e0

View File

@@ -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);