From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E73BC433ED for ; Fri, 9 Apr 2021 02:40:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3495A610FC for ; Fri, 9 Apr 2021 02:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232692AbhDICke (ORCPT ); Thu, 8 Apr 2021 22:40:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:58188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbhDICkd (ORCPT ); Thu, 8 Apr 2021 22:40:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4B76610C8; Fri, 9 Apr 2021 02:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1617936021; bh=ONi5JFQsnjmCEB+xQg9JClm7EwnmYFd4QQ7boQz0zQE=; h=Date:From:To:Subject:From; b=OVPucbAxSmDGzDvbZdJsINOFLSZlSJSp8PEQoesnXfUA2WX8SlIjp1T9YxQBJSpkh 2kCiwsUmCSUAud8MMTZK040VYLEaGI0JO/lpLXHxvZYDiYJI2BxSom/oNSVrEMBYmM YoSAQ/GX3qnd5TfzN8BEa95bnQjksnPdKRat+GYA= Date: Thu, 08 Apr 2021 19:40:20 -0700 From: akpm@linux-foundation.org To: aarcange@redhat.com, almasrymina@google.com, axelrasmussen@google.com, bgeffon@google.com, cannonmatthews@google.com, dgilbert@redhat.com, hughd@google.com, jglisse@redhat.com, joe@perches.com, lokeshgidra@google.com, mm-commits@vger.kernel.org, oupton@google.com, peterx@redhat.com, rientjes@google.com, rppt@linux.vnet.ibm.com, shli@fb.com, shuah@kernel.org, viro@zeniv.linux.org.uk, walken@google.com, wangqing@vivo.com Subject: [to-be-updated] userfaultfd-selftests-use-memfd_create-for-shmem-test-type.patch removed from -mm tree Message-ID: <20210409024020.HDysOw45Z%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: userfaultfd/selftests: use memfd_create for shmem test type has been removed from the -mm tree. Its filename was userfaultfd-selftests-use-memfd_create-for-shmem-test-type.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Axel Rasmussen Subject: userfaultfd/selftests: use memfd_create for shmem test type 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/20210302000133.272579-3-axelrasmussen@google.com Signed-off-by: Axel Rasmussen Cc: Alexander Viro Cc: Andrea Arcangeli Cc: Brian Geffon Cc: Cannon Matthews Cc: David Rientjes Cc: "Dr . David Alan Gilbert" Cc: Hugh Dickins Cc: Jerome Glisse Cc: Joe Perches Cc: Lokesh Gidra Cc: Michel Lespinasse Cc: Mike Rapoport Cc: Mina Almasry Cc: Oliver Upton Cc: Peter Xu Cc: Shaohua Li Cc: Shuah Khan Cc: Wang Qing Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/userfaultfd.c | 35 ++++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) --- a/tools/testing/selftests/vm/userfaultfd.c~userfaultfd-selftests-use-memfd_create-for-shmem-test-type +++ a/tools/testing/selftests/vm/userfaultfd.c @@ -85,6 +85,7 @@ 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; @@ -297,12 +298,20 @@ static int shmem_release_pages(char *rel 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_ANONYMOUS | MAP_SHARED, -1, 0); + MAP_SHARED, shm_fd, offset); if (*alloc_area == MAP_FAILED) { - fprintf(stderr, "shared memory mmap failed\n"); - *alloc_area = NULL; + perror("mmap of memfd failed"); + goto fail; } + + return; + +fail: + *alloc_area = NULL; } struct uffd_test_ops { @@ -1685,15 +1694,31 @@ int main(int argc, char **argv) usage(); huge_fd = open(argv[4], O_CREAT | O_RDWR, 0755); if (huge_fd < 0) { - fprintf(stderr, "Open of %s failed", argv[3]); + fprintf(stderr, "Open of %s failed", argv[4]); perror("open"); exit(1); } if (ftruncate(huge_fd, 0)) { - fprintf(stderr, "ftruncate %s to size 0 failed", argv[3]); + fprintf(stderr, "ftruncate %s to size 0 failed", argv[4]); perror("ftruncate"); exit(1); } + } else if (test_type == TEST_SHMEM) { + shm_fd = memfd_create(argv[0], 0); + if (shm_fd < 0) { + perror("memfd_create"); + exit(1); + } + if (ftruncate(shm_fd, nr_pages * page_size * 2)) { + perror("ftruncate"); + exit(1); + } + if (fallocate(shm_fd, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, + nr_pages * page_size * 2)) { + perror("fallocate"); + exit(1); + } } printf("nr_pages: %lu, nr_pages_per_cpu: %lu\n", nr_pages, nr_pages_per_cpu); _ Patches currently in -mm which might be from axelrasmussen@google.com are userfaultfd-add-minor-fault-registration-mode.patch userfaultfd-disable-huge-pmd-sharing-for-minor-registered-vmas.patch userfaultfd-hugetlbfs-only-compile-uffd-helpers-if-config-enabled.patch userfaultfd-add-uffdio_continue-ioctl.patch userfaultfd-update-documentation-to-describe-minor-fault-handling.patch userfaultfd-selftests-add-test-exercising-minor-fault-handling.patch userfaultfd-selftests-create-alias-mappings-in-the-shmem-test.patch userfaultfd-selftests-reinitialize-test-context-in-each-test.patch userfaultfd-selftests-exercise-minor-fault-handling-shmem-support.patch