From patchwork Tue Oct 4 21:43:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12998724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2FFAC433FE for ; Tue, 4 Oct 2022 21:43:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 595776B0071; Tue, 4 Oct 2022 17:43:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5451F6B0073; Tue, 4 Oct 2022 17:43:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E6046B0074; Tue, 4 Oct 2022 17:43:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2C5B06B0071 for ; Tue, 4 Oct 2022 17:43:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0374A1602D5 for ; Tue, 4 Oct 2022 21:43:07 +0000 (UTC) X-FDA: 79984592856.08.C0AD130 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id A83F51C000E for ; Tue, 4 Oct 2022 21:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664919787; 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=cM7qRnpkZjQEY+Ujh9rGEuA89d+cTGs8Wg553RYc2JgYt2n6Ho9oaaph8I/589smYnJodG uVbaE9milM70QaDpc/de1JKEwc223QKnr+/SHNmJJhQ0wR+ANFjSjkb5j+HBwmKkvQivKj OiJWkRkEHcNP/J7ETkXicx8EQBmya1s= 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-600-rZkJRcUXMjCO7jhLx3k9Xg-1; Tue, 04 Oct 2022 17:43:06 -0400 X-MC-Unique: rZkJRcUXMjCO7jhLx3k9Xg-1 Received: by mail-qk1-f197.google.com with SMTP id ay35-20020a05620a17a300b006cfc01b4436so12814605qkb.13 for ; Tue, 04 Oct 2022 14:43:06 -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; bh=iDP4uYCeHzqEOaCGXbcAwOcK1rZC2BBuQ6aTX5fgU3w=; b=6eMMEvE9Kje2PRK74xvtJ1TyAZJD4uaxhaxqGL2m2F5YLyiZuYzBV5Mx6fS96ePakH vDxIqilIcTQKMlsVvTtW3gCstE1sxI8El8pFpLzOCRa9L+ZeuiWDZYptyVR2R9mPq9UB MABSFd5BS84e7EyI4Gxr96wA0okW1tiqYjHd+4loBYIjYGs9Th0cDUMRuIznQmDp0Uay hhsMHA4Mh7zOeat8LYtiDvK41z469Me97H3QX2jctHeDpe7TQaIxxcAoODl83q/04LPQ PjyQVFPugkSPVnFs1/eHJBX6mjjKAZnHMGMesgGSJG5nvS0N3CFdgNzoCuIckBWw0SgK HsVA== X-Gm-Message-State: ACrzQf1vDr02cNE2TkB5dhcHw6upB7rqq1F9gr2zhcRr/Ekel9yHHj2E 8NLPv9I7hfDr8kAiHX7crX1eCGpXaiGEdMrB+RQhWi+lLceIj/XfZcjaS5Hz+XtyKylz4AJTEfR X6tBIGnvhzS4= X-Received: by 2002:a37:4553:0:b0:6cf:4dbd:b5f6 with SMTP id s80-20020a374553000000b006cf4dbdb5f6mr18472728qka.339.1664919785784; Tue, 04 Oct 2022 14:43:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77JL7JEmps8VFSIv2pFu3zdKv9SaLpBJ+ezlOLM+yMue29M9e7KeiI1bvH4JScBSCCgMYdkQ== X-Received: by 2002:a37:4553:0:b0:6cf:4dbd:b5f6 with SMTP id s80-20020a374553000000b006cf4dbdb5f6mr18472717qka.339.1664919785571; Tue, 04 Oct 2022 14:43:05 -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 a5-20020ac85b85000000b0035ba7012724sm13297803qta.70.2022.10.04.14.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 14:43:05 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: peterx@redhat.com, Axel Rasmussen , Mike Kravetz , Andrew Morton Subject: [PATCH 3/4] selftests/vm: Use memfd for hugepage-mremap test Date: Tue, 4 Oct 2022 17:43:03 -0400 Message-Id: <20221004214303.121394-1-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004214125.120993-1-peterx@redhat.com> References: <20221004214125.120993-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664919787; h=from:from:sender: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:dkim-signature; bh=iDP4uYCeHzqEOaCGXbcAwOcK1rZC2BBuQ6aTX5fgU3w=; b=BNijvuLbOzOWlFBOWQ4+v349JxqS3Lt0p/DeBZRCVH6d6amO4jp/4F3TKy2DO9Hyz/x5HZ Pe3WmkPz2t72NQuNCsWxVRZetk8J9fOiGqIxPkp8K4pWDG7O+qfSTBQNfi7EDXltjDFi9f 6+E1/lKHhcz0PzgQAZkVXzYL8X+bYfo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cM7qRnpk; spf=pass (imf21.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664919787; a=rsa-sha256; cv=none; b=F9N4khXHZivcgEAfDA1eEoZzQSD7Hxx+0yYXR3YRmuzleaaJgEKjr1becSP1MXUdLmds2r qk3/q/E30njV6GmLD0BJo/vH4sah1YAUg8ZosEdxIJG+zEWKFs63ge1bpvARPxOypmmkFr jV2Oq8ioG/ha0OJublTmHZPQQwaa0X4= X-Rspamd-Queue-Id: A83F51C000E Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cM7qRnpk; spf=pass (imf21.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: nwtyfosqj5zr6zmqyf6c8dn51wi6kqu7 X-HE-Tag: 1664919787-196106 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }