From patchwork Fri Oct 14 14:39:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 2719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp218361wrs; Fri, 14 Oct 2022 07:41:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kX2TWtgE95rzihbLbOPdf8/D0pMMWkJ+t3RKf4D8/JsOUFFdeQThWKfdudgJgRQypzhFC X-Received: by 2002:a17:907:7da2:b0:78e:25f8:8803 with SMTP id oz34-20020a1709077da200b0078e25f88803mr2367284ejc.723.1665758464443; Fri, 14 Oct 2022 07:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665758464; cv=none; d=google.com; s=arc-20160816; b=0FQNK4B9IhhnLQHhrZxnrW+ow5hl1SNUfMjUQWF5f6ebGWDLhxRfsNwtfpBta0o9Nk ZUN26+y8xAi6xqCe1ggG8cnAzEST5DBTi7NZ7Jtsx9IPh/xk7A7EAq9LCMqFDkDn1/UX uj1FjqKjQaByeNeHHWQFGTBAfOB5VjZP0e3ob9X25F/r7csvit+dw/li0vX9YWNQbL0q orWNLN9HxTYAKGsWY3Xk9YWbw5Cj/syWCeYbb+brB/sSGzsI+SEMgkY9eDphZU2qQyWa JNlyiXlFSImGNqTAMq68f/zv7KNE6TD83qbCRW2vYw03tJFGrb+jenIDU0nBFxFEegZO 6U4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CEy7pKIEsfMMFzj4vyOzQVpkWI0TxrmvN3NLo9J44z8=; b=oAJJoZ/Fp+XGqwvfHjO0Y5wVRv9kdcTg+peoyhryzInKMubH7dZ6DuqoICNPwojgjg +F1hZ9NxeyB1Dlim/B7SFN1rS+Y2dpkYlRJ9GfqOLbnDhQPs4WMFQ+/GigBYH/082e6R MDsxMkDt7/9EVZuAH6PcGKsEwXXyy20K7cpjeBhKLD6nIlfSh/8MKsp1yKKiP45JC7sz b6VuAD11GN+5F0bdcNjxhnpa0ffYHUGUHzQp+oVF+522rNXG0RPeLfSHx6++F3oZRcGK eChXFMgfHq6YtpSx+alc83civ/sEEiDY8rQN/hI4KVQznV3oqeBzsF9vT40wnP3nigXA X62Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iepYJhtt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg11-20020a170907320b00b00741a0c28f07si1986647ejb.943.2022.10.14.07.40.37; Fri, 14 Oct 2022 07:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iepYJhtt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbiJNOje (ORCPT + 99 others); Fri, 14 Oct 2022 10:39:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiJNOj1 (ORCPT ); Fri, 14 Oct 2022 10:39:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044DD1D4DE7 for ; Fri, 14 Oct 2022 07:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665758366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CEy7pKIEsfMMFzj4vyOzQVpkWI0TxrmvN3NLo9J44z8=; b=iepYJhttJwhqIGc6BDa2CKrYQKQSHTWGZcrN9v8IMO6Ngab5cIWXky27aNI4NmuNNYOSci bSf0nvG2q5zt0ych081OKFa68KQDieNsDiLXthPTHCB/NucxMfOIHcV3Sl6Zq5Ytq5HSPf 9cUoITp/c97tRaOiwJktQ35/6tRlOYs= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-622-l_ER5CKYNmuc7kbrvHuT5A-1; Fri, 14 Oct 2022 10:39:25 -0400 X-MC-Unique: l_ER5CKYNmuc7kbrvHuT5A-1 Received: by mail-qk1-f198.google.com with SMTP id j13-20020a05620a288d00b006be7b2a758fso3580147qkp.1 for ; Fri, 14 Oct 2022 07:39:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CEy7pKIEsfMMFzj4vyOzQVpkWI0TxrmvN3NLo9J44z8=; b=kyIQlijkbsz/HvzKAO59f5AwgWjTywJg4zXdJ4Z6JcQzqEcCl33jfDuXR1B1qnJCQy 5FU82tFQ6AulAfzojEbXKVOeRTmzm+PEwmbFK/taI7IenBp6gXibynNzGrbVrw9by02W vurin6GwOpYtRDrN8LbmX7SqNPchLmHdQx68RvyVr2XW2L4ghsrFnmzHVXyIerKlYPqR r6lZXNK64RJG3Ef+wkvWQITNsDk/azjxl20fZ0VIDZpgPH4IM+h0JjwCZTDiJWaGbzj+ 31Nk4+It7OxynBP4R4rVo2Z4jbdQ4h0XnO3ou2f1LP8yvy+Nwn4OmYkDIv8CjqLJrxBq F6Cw== X-Gm-Message-State: ACrzQf0yI6jITXJsZeR+UjxR9n6ivlrcJQOaql6vShcFEv/24p2snBsY n7njwdIJwq244B/7Ty/km44PlpnjwZuLVD+VyqxySVmmwDY1hu89TmoQoWZeWE5hs53DFwTK3mL nEWbFxdrDP4dHcMQ9MnzQyvSCKn4gwnp4dJevH94a97cnYlQ08L2ZcogE0LJvZAhhJdp+Kt7Y1w == X-Received: by 2002:a05:6214:500f:b0:4b1:d2b1:54c with SMTP id jo15-20020a056214500f00b004b1d2b1054cmr4236938qvb.54.1665758364406; Fri, 14 Oct 2022 07:39:24 -0700 (PDT) X-Received: by 2002:a05:6214:500f:b0:4b1:d2b1:54c with SMTP id jo15-20020a056214500f00b004b1d2b1054cmr4236905qvb.54.1665758364028; Fri, 14 Oct 2022 07:39:24 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id q4-20020a05620a2a4400b006ec09d7d357sm2675541qkp.47.2022.10.14.07.39.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 07:39:23 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Andrew Morton , peterx@redhat.com, Mike Kravetz Subject: [PATCH v2 1/4] selftests/vm: Use memfd for uffd hugetlb tests Date: Fri, 14 Oct 2022 10:39:18 -0400 Message-Id: <20221014143921.93887-2-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014143921.93887-1-peterx@redhat.com> References: <20221014143921.93887-1-peterx@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746674347310323333?= X-GMAIL-MSGID: =?utf-8?q?1746674347310323333?= We already used memfd for shmem test, move it forward with hugetlb too so that we don't need user to specify the hugetlb file path explicitly when running hugetlb shared tests. Reviewed-by: Axel Rasmussen Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 62 ++++++++---------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 74babdbc02e5..58f70d81e630 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -93,10 +93,8 @@ static volatile bool test_uffdio_zeropage_eexist = true; static bool test_uffdio_wp = true; /* Whether to test uffd minor faults */ static bool test_uffdio_minor = false; - static bool map_shared; -static int shm_fd; -static int huge_fd; +static int mem_fd; static unsigned long long *count_verify; static int uffd = -1; static int uffd_flags, finished, *pipefd; @@ -143,7 +141,7 @@ const char *examples = "# Run hugetlb memory test on 256MiB region with 50 bounces:\n" "./userfaultfd hugetlb 256 50\n\n" "# Run the same hugetlb test but using shared file:\n" - "./userfaultfd hugetlb_shared 256 50 /dev/hugepages/hugefile\n\n" + "./userfaultfd hugetlb_shared 256 50\n\n" "# 10MiB-~6GiB 999 bounces anonymous test, " "continue forever unless an error triggers\n" "while ./userfaultfd anon $[RANDOM % 6000 + 10] 999; do true; done\n\n"; @@ -260,35 +258,21 @@ static void hugetlb_release_pages(char *rel_area) static void hugetlb_allocate_area(void **alloc_area, bool is_src) { + off_t size = nr_pages * page_size; + off_t offset = is_src ? 0 : size; void *area_alias = NULL; char **alloc_area_alias; - if (!map_shared) - *alloc_area = mmap(NULL, - nr_pages * page_size, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | - (is_src ? 0 : MAP_NORESERVE), - -1, - 0); - else - *alloc_area = mmap(NULL, - nr_pages * page_size, - PROT_READ | PROT_WRITE, - MAP_SHARED | - (is_src ? 0 : MAP_NORESERVE), - huge_fd, - is_src ? 0 : nr_pages * page_size); + *alloc_area = mmap(NULL, size, PROT_READ | PROT_WRITE, + (map_shared ? MAP_SHARED : MAP_PRIVATE) | + (is_src ? 0 : MAP_NORESERVE), + mem_fd, offset); if (*alloc_area == MAP_FAILED) err("mmap of hugetlbfs file failed"); if (map_shared) { - area_alias = mmap(NULL, - nr_pages * page_size, - PROT_READ | PROT_WRITE, - MAP_SHARED, - huge_fd, - is_src ? 0 : nr_pages * page_size); + area_alias = mmap(NULL, size, PROT_READ | PROT_WRITE, + MAP_SHARED, mem_fd, offset); if (area_alias == MAP_FAILED) err("mmap of hugetlb file alias failed"); } @@ -334,14 +318,14 @@ static void shmem_allocate_area(void **alloc_area, bool is_src) } *alloc_area = mmap(p, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, - shm_fd, offset); + mem_fd, offset); if (*alloc_area == MAP_FAILED) err("mmap of memfd failed"); if (test_collapse && *alloc_area != p) err("mmap of memfd failed at %p", p); area_alias = mmap(p_alias, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, - shm_fd, offset); + mem_fd, offset); if (area_alias == MAP_FAILED) err("mmap of memfd alias failed"); if (test_collapse && area_alias != p_alias) @@ -1821,21 +1805,17 @@ int main(int argc, char **argv) } nr_pages = nr_pages_per_cpu * nr_cpus; - if (test_type == TEST_HUGETLB && map_shared) { - if (argc < 5) - usage(); - huge_fd = open(argv[4], O_CREAT | O_RDWR, 0755); - if (huge_fd < 0) - 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) + if (test_type == TEST_SHMEM || test_type == TEST_HUGETLB) { + unsigned int memfd_flags = 0; + + if (test_type == TEST_HUGETLB) + memfd_flags = MFD_HUGETLB; + mem_fd = memfd_create(argv[0], memfd_flags); + if (mem_fd < 0) err("memfd_create"); - if (ftruncate(shm_fd, nr_pages * page_size * 2)) + if (ftruncate(mem_fd, nr_pages * page_size * 2)) err("ftruncate"); - if (fallocate(shm_fd, + if (fallocate(mem_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, nr_pages * page_size * 2)) err("fallocate"); From patchwork Fri Oct 14 14:39:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 2720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp218368wrs; Fri, 14 Oct 2022 07:41:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TlxsHwLdxyz+TKel7e1rNzHcQyYw5yFU6T1f7yDB82lLGc2O2dwT4/Zeuy1np1Ao2u88j X-Received: by 2002:a05:6402:d0b:b0:458:a244:4e99 with SMTP id eb11-20020a0564020d0b00b00458a2444e99mr4569968edb.46.1665758475108; Fri, 14 Oct 2022 07:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665758475; cv=none; d=google.com; s=arc-20160816; b=b6ecyaqlHfh56qpg+taiSFc9DHxtLiOF4cOkfpcIIAilcSQKMNiCAnKGLEhsAq/1L+ D7I/lGb/CBbbq0HyAdTsSrdOiRoKrTOskwvHgDm+rzH3JNlhUFEr6EoSH2OtBMSCSYqb GlqMP/ytust14FWqpkMjMIMxIjL4vWuSNGk0o9xePGc3c1atxUcmKUdiO5NmjGWhqU04 Z6/kT8l+G/Ex3yOs5ZZ/1A3wMkPmY0ikqPjx1/e/DPyp2/BlwVrH2ZfkXZ8rG0uTtCqp fam6zBo3IZipfWVZVt/nbin5odltRzMH1VkzxRg2buKUMNoLVTp0lU/LPGl4uB+LndTS RG8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zhrtCe5O8iJscoLdf85Accar6WxcllS+eYr7bBy1HkM=; b=v0C+jveQqppMpLOenob80hmKS2xpz7lQ9WIZDWXHYVRxMRDTDOIXlhl8D3vOl0YXem yxQ1p7ekzXMlfHDPS6TGjQG8U6PWb/KMexshFm4R/cB9SfZ4BtFJLeXrcq4NDgw8ZEdP SQl9o6ak8+JXDlWupQ52a5n2tG9B+dvGvwMvU2iOit0obdEopNCtT0oWY4ksEIhcjPL4 BmBE8FLUwbyY8KLIKsYj1klDzEpC3VJcCcR4b226Aex1/YDFGEk2gcweNtQEQ4F9g1AZ JoQwttoZvTgkLQBQhNd+KUFee6EyHrzXordRRt1aUb7faPlksVfS67Ui1Heso/cuDNf/ h1dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gtdPCQso; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc1-20020a1709071c0100b007820f6b65c6si2774431ejc.469.2022.10.14.07.40.49; Fri, 14 Oct 2022 07:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gtdPCQso; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbiJNOjh (ORCPT + 99 others); Fri, 14 Oct 2022 10:39:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiJNOj3 (ORCPT ); Fri, 14 Oct 2022 10:39:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A61B1D4DE7 for ; Fri, 14 Oct 2022 07:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665758367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zhrtCe5O8iJscoLdf85Accar6WxcllS+eYr7bBy1HkM=; b=gtdPCQsofa7kHijNmmurBxhr/APJhIXVcNkZGAICAgJzsqN8S/KYZw8zO/ZVAZh19ZVc0H NeMb4fZxaw3zIiKsAZkrtL62b+FEnrh+/YSzx77cKfwLqSZoywohaqXv6peouxWspVaxEs qJ6aF9gJul5lj9NBGKPAXkANnUTjDNE= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-339-p1WeIEz_M_CFSrXw6Tm80g-1; Fri, 14 Oct 2022 10:39:26 -0400 X-MC-Unique: p1WeIEz_M_CFSrXw6Tm80g-1 Received: by mail-qk1-f197.google.com with SMTP id az32-20020a05620a172000b006ee8ae138a7so3594407qkb.4 for ; Fri, 14 Oct 2022 07:39:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zhrtCe5O8iJscoLdf85Accar6WxcllS+eYr7bBy1HkM=; b=g4VKWBHrZvqNyr2VGAzGCLM7kL+U6/eLN8CQ9BXeT67l2RRgg1SUE+HY9GffFf8Iue DHwowud44HkwRdlsBbtQsw0SE7HBYUMObE+uTA1sKMTp4jDlclYNplZqWDpoZ4IrO2kB H0VmPOltvQJp2AntD9mFzG5+EgFwgJ7GZOudhCh4V9C1/KrKxDB5lHZcuTu80JEeXPIg M5Xs8TQVzl2hrFpDgSDwx+hHwKAguHnwIHkOLlye8qt0HkeJlVxD4uOo6m44Xb4g993n 295+kUeDBgDj5h0Q+kvMcgrBsjZQlaI6S8CfzVuaoAqYDDTGN2E2a8+DZH7/rA2KuCGB mD1g== X-Gm-Message-State: ACrzQf1zz+88uePPogAIUi7yBcAl98fyRRrgGM/hLsFSMvJ5yP7CqHoS SetPN0lATx49BRB9NIIKJoUkelC0iJ9XdDngouXyxKL2xOMCcpskEJitaoL7v/7MMMgXZ8xIX+J w6z/1dfS2OwLKkiD41cxrXVMbQ/wDeqTf54+WjN3PhqY/wgIfs/XvdLHKgEUAEL5Q3k+IuxgZiQ == X-Received: by 2002:a05:620a:4487:b0:6ee:bcfd:bd38 with SMTP id x7-20020a05620a448700b006eebcfdbd38mr3958894qkp.468.1665758365599; Fri, 14 Oct 2022 07:39:25 -0700 (PDT) X-Received: by 2002:a05:620a:4487:b0:6ee:bcfd:bd38 with SMTP id x7-20020a05620a448700b006eebcfdbd38mr3958866qkp.468.1665758365343; Fri, 14 Oct 2022 07:39:25 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id q4-20020a05620a2a4400b006ec09d7d357sm2675541qkp.47.2022.10.14.07.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 07:39:24 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Axel Rasmussen , Andrew Morton , peterx@redhat.com, Mike Kravetz Subject: [PATCH v2 2/4] selftests/vm: Use memfd for hugetlb-madvise test Date: Fri, 14 Oct 2022 10:39:19 -0400 Message-Id: <20221014143921.93887-3-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014143921.93887-1-peterx@redhat.com> References: <20221014143921.93887-1-peterx@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746674358661099034?= X-GMAIL-MSGID: =?utf-8?q?1746674358661099034?= For dropping the hugetlb mountpoint in run_vmtests.sh. Since no parameter is needed, drop USAGE too. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/hugetlb-madvise.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/vm/hugetlb-madvise.c b/tools/testing/selftests/vm/hugetlb-madvise.c index 3c9943131881..f96435b70986 100644 --- a/tools/testing/selftests/vm/hugetlb-madvise.c +++ b/tools/testing/selftests/vm/hugetlb-madvise.c @@ -12,6 +12,7 @@ * directory. */ +#define _GNU_SOURCE #include #include #include @@ -19,7 +20,6 @@ #define __USE_GNU #include -#define USAGE "USAGE: %s \n" #define MIN_FREE_PAGES 20 #define NR_HUGE_PAGES 10 /* common number of pages to map/allocate */ @@ -103,11 +103,6 @@ int main(int argc, char **argv) int fd; int ret; - if (argc != 2) { - printf(USAGE, argv[0]); - exit(1); - } - huge_page_size = default_huge_page_size(); if (!huge_page_size) { printf("Unable to determine huge page size, exiting!\n"); @@ -125,9 +120,9 @@ int main(int argc, char **argv) exit(1); } - fd = open(argv[1], O_CREAT | O_RDWR, 0755); + fd = memfd_create(argv[0], MFD_HUGETLB); if (fd < 0) { - perror("Open failed"); + perror("memfd_create() failed"); exit(1); } @@ -406,6 +401,5 @@ int main(int argc, char **argv) (void)munmap(addr2, NR_HUGE_PAGES * huge_page_size); close(fd); - unlink(argv[1]); return 0; } From patchwork Fri Oct 14 14:40:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 2722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp225368wrs; Fri, 14 Oct 2022 07:58:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qq/7DNnCkLFKO89nJjmB5dmBydalhwYA2cTLxwOds3dZasvbwbY6Kdg1rokUPRv0GdcpB X-Received: by 2002:a17:906:db07:b0:77b:82cf:54af with SMTP id xj7-20020a170906db0700b0077b82cf54afmr3957455ejb.666.1665759524196; Fri, 14 Oct 2022 07:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665759524; cv=none; d=google.com; s=arc-20160816; b=VzweSJh9a2981Z6rolAjg1Lh4M1FPLq/i4AKQWl7dZPYe6TFY6mZ2WV4AFtEPNtugn EJQQtNGOsfqz4akeELP/ScY9Ge89VHfqnXcuyRKJCvTaKAlt7ww738tCWf2FLaGF1Rry 0f6e56qXpK0GgIhx3WWXWeCJn8URJF/8nE+rOVQ9scDLYP+bj9O0SJhVXHaNaQKY/Hh8 /ILf2sjR19ucxg8nIMpB5Nk1EzcPnH8dDwSOfuZwlcVnQW4YrqxJyVd3lrNnAIuYPR0Y tPUW1h43nJlgTi5Sb2+sdiAf7+zyH6q9d5VpnKw9welbG6S8/pL7KgFK/w6La/Ci/8BR bPJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iDP4uYCeHzqEOaCGXbcAwOcK1rZC2BBuQ6aTX5fgU3w=; b=lBzFxeJT24zCTKiTCtu5nzJkFg3b6B8eo/uT0/RZab809VSxbN+ZpvxfNDiGBtlcBH lCJ/dd2iimjZOb1ZC3+O2nJcw1+BjvOnLul9pKSQMIIAX0dNS1RkCYrt24HWyI7N2oeY M+ldR4A54dhiRaVXdoqY/Q8Vvapo3BqGMA5ZEGZfVRMI/jDAnhVWnBF1cDRsD+HDqbkR /ZBZyZTOgdBihmYoB3Q+PtFdaNqkJE8UQJr+/Ze9/OWZlKg0BxqD8mr9WcWZtZv+XtGH fRq5DnXdsH5y1Vd4KPLEpfmfImYPXAAttn7xUp4HjSzIwFJ6qgj7EH+gZIVXVJPBTARD ceiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aJ/1qwub"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a056402074500b0045c98d055a9si2277193edy.459.2022.10.14.07.58.18; Fri, 14 Oct 2022 07:58:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aJ/1qwub"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbiJNOkb (ORCPT + 99 others); Fri, 14 Oct 2022 10:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbiJNOkT (ORCPT ); Fri, 14 Oct 2022 10:40:19 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E2C950BB7 for ; Fri, 14 Oct 2022 07:40:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665758417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iDP4uYCeHzqEOaCGXbcAwOcK1rZC2BBuQ6aTX5fgU3w=; b=aJ/1qwubn0CASPVpRYd8b13X7iD65tWPi7YQDqLQvYOT/xBA19IK0tF5IXrql57THycRlJ E4Qveg/106Z35UMsWtplpaR6sLvhhBV9vIpn2HIamd4VEr//rqF1w18XrXeygNEE7qQHwp SEP9S7XZzFpwsa9LniWg3trPKGH4F4k= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-437-UtZ32APbMee-iw_SH0NmFQ-1; Fri, 14 Oct 2022 10:40:16 -0400 X-MC-Unique: UtZ32APbMee-iw_SH0NmFQ-1 Received: by mail-qk1-f200.google.com with SMTP id w13-20020a05620a424d00b006e833c4fb0dso3587391qko.2 for ; Fri, 14 Oct 2022 07:40:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iDP4uYCeHzqEOaCGXbcAwOcK1rZC2BBuQ6aTX5fgU3w=; b=2+1Br4UPiU60QR9Q/vlNsF67WZHX0tv1Nxtv0iacy4FNmd+0FMVir7nyJ6Ay85HppI zG6Dmfoa9ML5M6sRTltPF5K6ue2QDq5fr+K7TC0aflDD6rThQNtIE8ZE5JHsBw7e3UbJ cmYCQkA0XTn2GBkaNq4FqAYOEf2axwSWr01/AIt35P0r0CeTqI7RGQhj/tX3XPZS4UMH JhvZGx3V6gpRcntdaThGYvqWId1xgnIa9igMvaL8pDrWOUUDoMSL+wsAZW6ullR0k4nK oQrcoZTVLXpU3ozfYlgo0MMXi3lIvPjpGwFfqxNerpkO60oTZLVymBTJ98A86k8EFCUq ryrg== X-Gm-Message-State: ACrzQf0drtMt72lqs1iNHZJPZVpNQOeqYQkOPE+TOKFFtqIeGVT0twQK Hg3X5jL97PE44CNKHxftBFrHwGL3biqwvjG3X+RTTYmE7MGMRL5RHCT1OvcLonpgptNDR2kfsUV ztxlWAPy3ZmlVugEZpK90wJF38RajkylmIkmw40V+dqF94AufAuKDdJHJvvDYL0hJK4ZmXr6j9g == X-Received: by 2002:a37:c85:0:b0:6ed:4a79:fc66 with SMTP id 127-20020a370c85000000b006ed4a79fc66mr4006758qkm.433.1665758415401; Fri, 14 Oct 2022 07:40:15 -0700 (PDT) X-Received: by 2002:a37:c85:0:b0:6ed:4a79:fc66 with SMTP id 127-20020a370c85000000b006ed4a79fc66mr4006731qkm.433.1665758415046; Fri, 14 Oct 2022 07:40:15 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id d75-20020ae9ef4e000000b006ed61f18651sm2503120qkg.16.2022.10.14.07.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 07:40:14 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: peterx@redhat.com, Axel Rasmussen , Andrew Morton , Mike Kravetz Subject: [PATCH v2 3/4] selftests/vm: Use memfd for hugepage-mremap test Date: Fri, 14 Oct 2022 10:40:13 -0400 Message-Id: <20221014144013.94027-1-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014143921.93887-1-peterx@redhat.com> References: <20221014143921.93887-1-peterx@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746675458785319230?= X-GMAIL-MSGID: =?utf-8?q?1746675458785319230?= For dropping the hugetlb mountpoint in run_vmtests.sh. Cleaned it up a little bit around the changed codes. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/hugepage-mremap.c | 21 +++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/vm/hugepage-mremap.c b/tools/testing/selftests/vm/hugepage-mremap.c index e63a0214f639..e53b5eaa8fce 100644 --- a/tools/testing/selftests/vm/hugepage-mremap.c +++ b/tools/testing/selftests/vm/hugepage-mremap.c @@ -22,6 +22,7 @@ #include /* Definition of SYS_* constants */ #include #include +#include #define DEFAULT_LENGTH_MB 10UL #define MB_TO_BYTES(x) (x * 1024 * 1024) @@ -108,26 +109,23 @@ static void register_region_with_uffd(char *addr, size_t len) int main(int argc, char *argv[]) { size_t length = 0; + int ret = 0, fd; - if (argc != 2 && argc != 3) { - printf("Usage: %s [length_in_MB] \n", argv[0]); + if (argc >= 2 && !strcmp(argv[1], "-h")) { + printf("Usage: %s [length_in_MB]\n", argv[0]); exit(1); } /* Read memory length as the first arg if valid, otherwise fallback to * the default length. */ - if (argc == 3) - length = argc > 2 ? (size_t)atoi(argv[1]) : 0UL; + if (argc >= 2) + length = (size_t)atoi(argv[1]); + else + length = DEFAULT_LENGTH_MB; - length = length > 0 ? length : DEFAULT_LENGTH_MB; length = MB_TO_BYTES(length); - - int ret = 0; - - /* last arg is the hugetlb file name */ - int fd = open(argv[argc-1], O_CREAT | O_RDWR, 0755); - + fd = memfd_create(argv[0], MFD_HUGETLB); if (fd < 0) { perror("Open failed"); exit(1); @@ -185,7 +183,6 @@ int main(int argc, char *argv[]) } close(fd); - unlink(argv[argc-1]); return ret; } From patchwork Fri Oct 14 14:40:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 2723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp230502wrs; Fri, 14 Oct 2022 08:07:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4r/Edl7zvc5rz7G4DeROE611pmznXt/SynND8aaqNjEmQEOtyjfHfNhCG9d2J1CS4IIW+a X-Received: by 2002:a17:907:b08:b0:78d:cea9:937d with SMTP id h8-20020a1709070b0800b0078dcea9937dmr3875422ejl.216.1665760028263; Fri, 14 Oct 2022 08:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665760028; cv=none; d=google.com; s=arc-20160816; b=Arv4yeP3a7wwSP0JewYJhji6sPxwTWizWVDJJRf+1ZxlSzKNiyqOBrAkJu2p7LzRmP nFKkk09kUjj6mUkooQcDT4TieMBfq7SLjb1nvTvO1BvXS4cpNPf4N8dvB1zcUbNC2zHL kpmeB0QpjQm/Lq5WesNc9hXtRj2x5jlfFX3OpsWH7JSs2NP7uQwUbZesKRGYWztGYD9g GDTKbyIla4e7lMU7Nrmm7mI1yhZHQrooGlI2G/VPhfTferHoXcBkXs969JiWFDQ8lnWE bVhBVvufM0WAqo9UvreOn4uahytEz7fPLQQUC1w1y7Xw3icvgp28U52+CJgy9TsHEA/Z RRjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SLJyHDSa1XQjsFtgHwRksRspzx5xxcL5BS8fvTY+AU0=; b=VLzbbcPqXTbvtf2I+lULI2CwdwQAN/s1C1YiUQ0CH+z8c/pG0dJIZs+EyLQabP+WM7 MOTHExCiiegUxfvTZk/XCC+rE+GOWoDhLb5zUESbcuQwYwEhSQZSuxyRJtv2XcrA2FhF AJyYiibxTuBgUqAiYNsXUQ1YHDcZjneSkeA3ziuqtV3lrm0fgrCYgwYllm2WDYspnlbo 4WazHXypl2oLtKuhvXG2ZxAB7qymVXSfYpBBU4lm0uL0Ljamgrsun9guqbT3tSTUI37i UvvonXF261MfTHFp8v1fQCdojlDJoJHLz+H29gzuy3SG3kZI76771rUI8Pu76PVyBy13 buqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UsT97ZCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn42-20020a1709070d2a00b0078d0f88a6e9si2435334ejc.284.2022.10.14.08.06.39; Fri, 14 Oct 2022 08:07:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UsT97ZCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbiJNOke (ORCPT + 99 others); Fri, 14 Oct 2022 10:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiJNOkU (ORCPT ); Fri, 14 Oct 2022 10:40:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C045A32BB1 for ; Fri, 14 Oct 2022 07:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665758418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLJyHDSa1XQjsFtgHwRksRspzx5xxcL5BS8fvTY+AU0=; b=UsT97ZClr4/SeZvJKlLKREonCleLLyQP4u9p5A5jYtk6zBDjoEbdfyTUmun2c2+3snCZ30 XttAhYrPfjo6VbJvXJFilPWTiLK31cqD0hRWucFRyXXpI0Sljq5mbJ0QcHtRPu9cUjU4H5 cPnoxBadxv7g9P1RV4Ixiyz98R6JUEo= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-473-l2-pIrjSOlSd8JWwGEzymQ-1; Fri, 14 Oct 2022 10:40:17 -0400 X-MC-Unique: l2-pIrjSOlSd8JWwGEzymQ-1 Received: by mail-qt1-f200.google.com with SMTP id fy10-20020a05622a5a0a00b0039cd5097697so3083687qtb.7 for ; Fri, 14 Oct 2022 07:40:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SLJyHDSa1XQjsFtgHwRksRspzx5xxcL5BS8fvTY+AU0=; b=njLf7CxO1+a141ENli4XFLoYuI9II0UZjYyWavLSxV4BjK/ynXj/5YAxk2Uu48jiNp HS6L9p6LSMMtESvRDA1d2K8yQRNq27F4FQCO8eZomKu506cJiqVeEn22zlRMMIDhFyWh dvsObceuBa9DKKaCOP8JdrWNb25hMIvKw3U4YcPtWVHZHrSxo/6NdYY4yR9JnKqnq5Dt HtOhR30puE03eHvIiY1UG8twz9VG8q+JjZsp6mLX72dhrc2mZzIjDvHw+qfFFoH8iuCd tP5QAc3GMmlkdXqYR8+zoI3RbTdxR5Z5mYQrv7tnE0J2o+qkSNlKBkkUJzNH2FCA2vdy /KbA== X-Gm-Message-State: ACrzQf1FrJGx/maQWs3Z6A4SK6bdNHcM11ny0HmjXWvnRcJH8m2suPRb rbhXHvAhMEmNvd9HfXb3VSjlBbhc6RlvNCncEzd6itLNVLoWG4AQ0Ra5V90NTSr84Jl/ljg6Hor bt42bpSEG2vw8Y9WpGug8s6VrZ09ik0W6M8XNdvKfPsuyiOfJqYjWcCjck9CFNRGyQX6OOzgj7Q == X-Received: by 2002:a0c:a98e:0:b0:4ac:929d:216f with SMTP id a14-20020a0ca98e000000b004ac929d216fmr4569053qvb.16.1665758417185; Fri, 14 Oct 2022 07:40:17 -0700 (PDT) X-Received: by 2002:a0c:a98e:0:b0:4ac:929d:216f with SMTP id a14-20020a0ca98e000000b004ac929d216fmr4569025qvb.16.1665758416855; Fri, 14 Oct 2022 07:40:16 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id u6-20020a05620a0c4600b006cec8001bf4sm2414202qki.26.2022.10.14.07.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 07:40:16 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: peterx@redhat.com, Axel Rasmussen , Andrew Morton , Mike Kravetz Subject: [PATCH v2 4/4] selftests/vm: Drop mnt point for hugetlb in run_vmtests.sh Date: Fri, 14 Oct 2022 10:40:15 -0400 Message-Id: <20221014144015.94039-1-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221014143921.93887-1-peterx@redhat.com> References: <20221014143921.93887-1-peterx@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746675987536278379?= X-GMAIL-MSGID: =?utf-8?q?1746675987536278379?= After converting all the three relevant testcases (uffd, madvise, mremap) to use memfd, no test will need the hugetlb mount point anymore. Drop the code. Reviewed-by: Axel Rasmussen Signed-off-by: Peter Xu --- tools/testing/selftests/vm/run_vmtests.sh | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh index e780e76c26b8..0dc9f545a32d 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -5,7 +5,6 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 -mnt=./huge exitcode=0 #get huge pagesize and freepages from /proc/meminfo @@ -84,9 +83,6 @@ run_test() { fi } -mkdir "$mnt" -mount -t hugetlbfs none "$mnt" - run_test ./hugepage-mmap shmmax=$(cat /proc/sys/kernel/shmmax) @@ -98,14 +94,9 @@ echo "$shmmax" > /proc/sys/kernel/shmmax echo "$shmall" > /proc/sys/kernel/shmall run_test ./map_hugetlb - -run_test ./hugepage-mremap "$mnt"/huge_mremap -rm -f "$mnt"/huge_mremap - +run_test ./hugepage-mremap run_test ./hugepage-vmemmap - -run_test ./hugetlb-madvise "$mnt"/madvise-test -rm -f "$mnt"/madvise-test +run_test ./hugetlb-madvise echo "NOTE: The above hugetlb tests provide minimal coverage. Use" echo " https://github.com/libhugetlbfs/libhugetlbfs.git for" @@ -126,14 +117,11 @@ for mod in "${uffd_mods[@]}"; do # Hugetlb tests require source and destination huge pages. Pass in half # the size ($half_ufd_size_MB), which is used for *each*. run_test ./userfaultfd hugetlb${mod} "$half_ufd_size_MB" 32 - run_test ./userfaultfd hugetlb_shared${mod} "$half_ufd_size_MB" 32 "$mnt"/uffd-test - rm -f "$mnt"/uffd-test + run_test ./userfaultfd hugetlb_shared${mod} "$half_ufd_size_MB" 32 run_test ./userfaultfd shmem${mod} 20 16 done #cleanup -umount "$mnt" -rm -rf "$mnt" echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages run_test ./compaction_test