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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C5BFC433F5 for ; Tue, 1 Feb 2022 19:06:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0482B8D007F; Tue, 1 Feb 2022 14:06:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F394B8D006D; Tue, 1 Feb 2022 14:06:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD9738D007F; Tue, 1 Feb 2022 14:06:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id C7F7D8D006D for ; Tue, 1 Feb 2022 14:06:26 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 722D182F0CEC for ; Tue, 1 Feb 2022 19:06:26 +0000 (UTC) X-FDA: 79095141972.04.1EF30E0 Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) by imf02.hostedemail.com (Postfix) with ESMTP id 05A9680003 for ; Tue, 1 Feb 2022 19:06:25 +0000 (UTC) Received: by mail-ua1-f49.google.com with SMTP id y4so14986270uad.1 for ; Tue, 01 Feb 2022 11:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qUbQ0b8ZRd0AkjeyzEsyBCt3tnTOzbqx/Ys5mz3HL90=; b=iy3UNgBrq5QIwft+G9BGA9Y0FZyDvqHq7QcVj2quS7jbiXUvsx8BZfCHJrbVaWNEZW dOGUSjaJpOAn3f8bxEnzmYZAgTD0BtXi1VVyp9IkpdXdrx0qIBRB76CNUOxZ7Eunin36 q4umGQKhdKU0A/ygq1g4FUBc611k+BqG4skbOpIifPih6MijOW4e4NTfnKxqp/iLvcIi 18jgnsguAdT1nm9/C4XcvT/LJgnmE0rFyGA1IOvn99NQ4SvbGHzvyK4Uq2ysj0DlO7eA AnXhEZ9/1c5cqw0Ek/jPeQo/UhEu1VLgQQsYso1ipCv9td44o7vDnRtddPLeRqgBDqW4 5vNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qUbQ0b8ZRd0AkjeyzEsyBCt3tnTOzbqx/Ys5mz3HL90=; b=1PKro2fS4OMOKRT9MKeTXrCiiWsfC1/bLTQvefSSy5bg4rZVGNZz3NnbxitjttFsIS p9oQzKZznymc2tZeI6Vvstva8e6ih9O2sriN6grk2McVkq6Z3anivUie/sYO3YdwB6FQ 8rJ/JJN8iHQfttErzWn4wqFfbQuB0zw8FxH+XGpzHqJXy++D+BUynmJKMW1z3l8vFPer zzZeG3Xhud6Z/BNPfONaIHAJs9CB+jsNkiF2ZANNj1lni2QO6B2ciDjIf0K7fHCRU+Xh 60BpvoaHZfM5G5mx9aN1vjqw9xAOJtckuuC2dKzVQTllY54yxHgkExPGA5amjpYQFN3F /VSg== X-Gm-Message-State: AOAM531XlcJV8wOA7sc9motadRI5bz88Gsj3DsbuDi1534FDJaDMUqLT sbUxbfUzspNOL3rkCe22nYJVGWnVgNuSiBSHFEJcxg== X-Google-Smtp-Source: ABdhPJzOe1y3RAp2TcJlvoR6jIriXoQif+8Cx2+nvtnlFymktSZCJUs/LJjWSYP0MW73mpCRBbHbzLqHAnuwo9CI+gQ= X-Received: by 2002:ab0:2092:: with SMTP id r18mr10365251uak.66.1643742385158; Tue, 01 Feb 2022 11:06:25 -0800 (PST) MIME-Version: 1.0 References: <20220201033459.156944-1-mike.kravetz@oracle.com> In-Reply-To: <20220201033459.156944-1-mike.kravetz@oracle.com> From: Mina Almasry Date: Tue, 1 Feb 2022 11:06:13 -0800 Message-ID: Subject: Re: [PATCH] selftests/vm: cleanup hugetlb file after mremap test To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed , Muchun Song , Shuah Khan , Andrew Morton Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 05A9680003 X-Stat-Signature: e6a5uf8wmfrkpwnxq1bwsp4euhqhk894 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=iy3UNgBr; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of almasrymina@google.com designates 209.85.222.49 as permitted sender) smtp.mailfrom=almasrymina@google.com X-Rspam-User: nil X-HE-Tag: 1643742385-277146 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: On Mon, Jan 31, 2022 at 7:35 PM Mike Kravetz wrote: > > The hugepage-mremap test will create a file in a hugetlb filesystem. > In a default 'run_vmtests' run, the file will contain all the hugetlb > pages. After the test, the file remains and there are no free hugetlb > pages for subsequent tests. This causes those hugetlb tests to fail. > > Change hugepage-mremap to take the name of the hugetlb file as an > argument. Unlink the file within the test, and just to be sure remove > the file in the run_vmtests script. > > Signed-off-by: Mike Kravetz Thanks Mike! Reviewed-by: Mina Almasry > --- > tools/testing/selftests/vm/hugepage-mremap.c | 26 ++++++++++++++------ > tools/testing/selftests/vm/run_vmtests.sh | 3 ++- > 2 files changed, 21 insertions(+), 8 deletions(-) > > diff --git a/tools/testing/selftests/vm/hugepage-mremap.c b/tools/testing/selftests/vm/hugepage-mremap.c > index 2a7c33631a29..1d689084a54b 100644 > --- a/tools/testing/selftests/vm/hugepage-mremap.c > +++ b/tools/testing/selftests/vm/hugepage-mremap.c > @@ -3,9 +3,10 @@ > * hugepage-mremap: > * > * Example of remapping huge page memory in a user application using the > - * mremap system call. Code assumes a hugetlbfs filesystem is mounted > - * at './huge'. The amount of memory used by this test is decided by a command > - * line argument in MBs. If missing, the default amount is 10MB. > + * mremap system call. The path to a file in a hugetlbfs filesystem must > + * be passed as the last argument to this test. The amount of memory used > + * by this test in MBs can optionally be passed as an argument. If no memory > + * amount is passed, the default amount is 10MB. > * > * To make sure the test triggers pmd sharing and goes through the 'unshare' > * path in the mremap code use 1GB (1024) or more. > @@ -25,7 +26,6 @@ > #define DEFAULT_LENGTH_MB 10UL > #define MB_TO_BYTES(x) (x * 1024 * 1024) > > -#define FILE_NAME "huge/hugepagefile" > #define PROTECTION (PROT_READ | PROT_WRITE | PROT_EXEC) > #define FLAGS (MAP_SHARED | MAP_ANONYMOUS) > > @@ -107,17 +107,26 @@ static void register_region_with_uffd(char *addr, size_t len) > > int main(int argc, char *argv[]) > { > + size_t length; > + > + if (argc != 2 && argc != 3) { > + 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. Any additional args are ignored. > + * the default length. > */ > - size_t length = argc > 1 ? (size_t)atoi(argv[1]) : 0UL; > + if (argc == 3) > + length = argc > 2 ? (size_t)atoi(argv[1]) : 0UL; > > length = length > 0 ? length : DEFAULT_LENGTH_MB; > length = MB_TO_BYTES(length); > > int ret = 0; > > - int fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755); > + /* last arg is the hugetlb file name */ > + int fd = open(argv[argc-1], O_CREAT | O_RDWR, 0755); > > if (fd < 0) { > perror("Open failed"); > @@ -169,5 +178,8 @@ int main(int argc, char *argv[]) > > munmap(addr, length); > > + close(fd); > + unlink(argv[argc-1]); > + > return ret; > } > diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh > index e09040a3dc08..e10d50e0b8e8 100755 > --- a/tools/testing/selftests/vm/run_vmtests.sh > +++ b/tools/testing/selftests/vm/run_vmtests.sh > @@ -111,13 +111,14 @@ fi > echo "-----------------------" > echo "running hugepage-mremap" > echo "-----------------------" > -./hugepage-mremap 256 > +./hugepage-mremap $mnt/huge_mremap > if [ $? -ne 0 ]; then > echo "[FAIL]" > exitcode=1 > else > echo "[PASS]" > fi > +rm -f $mnt/huge_mremap > > echo "------------------------" > echo "running hugepage-vmemmap" > -- > 2.34.1 >