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: 13007066 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 BB991C43217 for ; Fri, 14 Oct 2022 14:40:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58B6B6B0072; Fri, 14 Oct 2022 10:40:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53BD26B0075; Fri, 14 Oct 2022 10:40:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DC646B0078; Fri, 14 Oct 2022 10:40:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2A78C6B0072 for ; Fri, 14 Oct 2022 10:40:18 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B7971140C70 for ; Fri, 14 Oct 2022 14:40:17 +0000 (UTC) X-FDA: 80019815274.29.3DE3AC7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 4DE03A002F for ; Fri, 14 Oct 2022 14:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665758416; 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=IB6nXiuXAT3Z9Mxin+vwGF9H4f+uvf+W2OfmkPheVPfK9Ql3Ef1xFfSb4BFA7geg1Fhnzx aT1VmJwMBRzFUvIRmyt3FLncWNHNrFwxFgsco4ihoZ6cYbZju5SH8MhEknd0yDnbH1pPlE FEXFYUM10B/9JFnILmI1Hdsr1cY0cEQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-335-kEQ3flHuP0KxxABW8ACwzQ-1; Fri, 14 Oct 2022 10:40:15 -0400 X-MC-Unique: kEQ3flHuP0KxxABW8ACwzQ-1 Received: by mail-qv1-f72.google.com with SMTP id g12-20020a0cfdcc000000b004ad431ceee0so3560662qvs.7 for ; Fri, 14 Oct 2022 07:40:15 -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=bR6yknAB1SV6qgV2txwe1O4ycPoxeEVJfTPewHfi5zzzIsd5v3pH+1cxvSAjvSAzss KG4t7hXO3MQktB1T6Yz1Ed+SMlVGywH573lQoCEsrVVmfuRlfNXlTee8jc/srvaodKSu xG3Il5vGbmlteFR4EyLz0rdBGdzNvLq6cEIv+3yvj42XF1t5+Un2XwkJOa1Ha7M1tiB4 XiwLG0HFhFYuckTce45inkIIdZJHBTfxVIYhqHcxXRqLePFrfj14SnkeGQgW8WSrvMp4 xAqIPiSD9mx7R26xgHIpcs/iXafSN/e4rMb5ZW/zsiY4cNJoRi5av9KZjtKCMg5SA1g/ gn3Q== X-Gm-Message-State: ACrzQf2QA/mmc0eRAhZGc3q5V+B6Ye6LXwv9gv7/1+4Z8bzV4Qkq6S5Z 9iRw3JynHNFSrZIrh1hb2s9EOVQ8HEw8VGIIsDe37hcgJOcihbMBHvW1Cv1K7U/0lIIgRcQwfOt 4qANJv8o90uE= X-Received: by 2002:a37:c85:0:b0:6ed:4a79:fc66 with SMTP id 127-20020a370c85000000b006ed4a79fc66mr4006748qkm.433.1665758415334; Fri, 14 Oct 2022 07:40:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IfO7EVM9SoCYkoTimioBOx4Rp2krEuu3nGfkA84AP3QQ2Bab1uDw6m7lhGlL2PHeYZ7hQHQ== 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 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=1665758417; 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=QfilxfVK2YHPWaa0KOU5gINv7VnZqws5WfLOapUqmaEo8Hgpaj8Xgv6Nnf4TOLrYAHDg/4 bvW5h8gNB8LSd+XQSQ2/RPYLC/roH/lE31Fxd2mO5Zc18Aa2fErIoSl7Ujfi1sO04o4L1Z sPae+xEsF4kBgF9sWkgd3UniBv8UB78= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IB6nXiuX; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1665758417; a=rsa-sha256; cv=none; b=PLeiY8c85/YDoUqN+c/Qj5eIojm2dJZCYs5USFOjy5maM4GY0tMmiQk1bT9KoxeEI/YFYK TGrC0/xN3y3MxV1a2s2zQT9LauZhCSHKYsQLKSxNtG3drb/Hpx5PWzqUWszET9Dn6VjEtj /0Bo+u614z8QxlDngk/3gI5/UK3rCoI= X-Stat-Signature: byy9mqnm1oyxmrj4pod88qdp988i59t6 X-Rspamd-Queue-Id: 4DE03A002F Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IB6nXiuX; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1665758417-433268 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; }