Received: by 10.223.164.202 with SMTP id h10csp226375wrb; Tue, 7 Nov 2017 05:35:10 -0800 (PST) X-Google-Smtp-Source: ABhQp+SdQBwtIRsjSavv+JgcILOMO3PhSuLE8MmPpXVkk1AvQKHnW6c6kURDBQN680reZ2n/7BPB X-Received: by 10.99.97.151 with SMTP id v145mr18733934pgb.184.1510061710204; Tue, 07 Nov 2017 05:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510061710; cv=none; d=google.com; s=arc-20160816; b=weg9rhb/Xx49Suj/OL7WJy7gTlrQ9TZNT7VSiI7kHd6iAXafcIQz9N3aPiJ4XL4zz3 jxkDon0UXoZftYjrXiG53tdJdWS2s60irq4syMCooihTHcA9Czm6r1GILZsJWFXDnbQn /RXGjRhr0TP5m/fgbZXKXV+eMyNrJLEsQ/qw3SbH2ypQdfW6UnRRujh+jfnDbogmB8eb UIhgjP/iFfHDZdYEFPkP2UvBmil9k9wIZ6RaZN1NyNUhrWXGOfeS7tlCYZMGSprklOFf GPGk1QaJSC1C/7ks9gm76jg0X48TNMUMOEKA776QOw2il99KX10Sq6gsfAYJuUOdt20l W57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:arc-authentication-results; bh=y7W3hQfe6EAmfc/sPmYlFCn2I8panLZe5R1SPZlr52M=; b=uMaWaKPmyumvvi0B3nxylkq9PvmY42C/4mm1cLFR5FSj1rY/1zMs0O6qhvgePCLDrj K+hRMfl8KQEha7dJMOFOJYe233wTCbiXq4ub8ASwMS8MIxPPhWTLanG0p8Ap9jPfqicg DxiQr6BMoXv7xOLSBiPB62SEVegvc2DYD8sGxpJesgLrgjwWY2f6QKtNHH75Yv/nk1D4 WBUDfbVNEsi26GfRoHHIfQ82gDY40F/KfWMzX/J7GYURpkFtqm+th+/7XzwOwoForQmf PhoGwc/UqAoVn5w1pVKLQuxRw9UpX/+hGNgT9v9NXsA03JfZX31vbDJk0Z7MoKMp13rp kcBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d24si1224427plr.654.2017.11.07.05.34.55; Tue, 07 Nov 2017 05:35:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933829AbdKGM3t (ORCPT + 91 others); Tue, 7 Nov 2017 07:29:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21962 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757688AbdKGM2g (ORCPT ); Tue, 7 Nov 2017 07:28:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18BAD6A7CD; Tue, 7 Nov 2017 12:28:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18BAD6A7CD Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com Received: from localhost (ovpn-112-38.ams2.redhat.com [10.36.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69E6C5D9C9; Tue, 7 Nov 2017 12:28:35 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: aarcange@redhat.com, hughd@google.com, nyc@holomorphy.com, mike.kravetz@oracle.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 9/9] memfd-test: run fuse test on hugetlb backend memory Date: Tue, 7 Nov 2017 13:28:00 +0100 Message-Id: <20171107122800.25517-10-marcandre.lureau@redhat.com> In-Reply-To: <20171107122800.25517-1-marcandre.lureau@redhat.com> References: <20171107122800.25517-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 07 Nov 2017 12:28:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Suggested-by: Mike Kravetz Signed-off-by: Marc-André Lureau --- tools/testing/selftests/memfd/fuse_test.c | 38 ++++++++++++++++++++------ tools/testing/selftests/memfd/run_fuse_test.sh | 2 +- tools/testing/selftests/memfd/run_tests.sh | 1 + 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c index 795a25ba8521..b018e835737d 100644 --- a/tools/testing/selftests/memfd/fuse_test.c +++ b/tools/testing/selftests/memfd/fuse_test.c @@ -38,6 +38,8 @@ #define MFD_DEF_SIZE 8192 #define STACK_SIZE 65536 +static size_t mfd_def_size = MFD_DEF_SIZE; + static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags) { int r, fd; @@ -123,7 +125,7 @@ static void *mfd_assert_mmap_shared(int fd) void *p; p = mmap(NULL, - MFD_DEF_SIZE, + mfd_def_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, @@ -141,7 +143,7 @@ static void *mfd_assert_mmap_private(int fd) void *p; p = mmap(NULL, - MFD_DEF_SIZE, + mfd_def_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, @@ -174,7 +176,7 @@ static int sealing_thread_fn(void *arg) usleep(200000); /* unmount mapping before sealing to avoid i_mmap_writable failures */ - munmap(global_p, MFD_DEF_SIZE); + munmap(global_p, mfd_def_size); /* Try sealing the global file; expect EBUSY or success. Current * kernels will never succeed, but in the future, kernels might @@ -224,7 +226,7 @@ static void join_sealing_thread(pid_t pid) int main(int argc, char **argv) { - static const char zero[MFD_DEF_SIZE]; + char *zero; int fd, mfd, r; void *p; int was_sealed; @@ -235,6 +237,25 @@ int main(int argc, char **argv) abort(); } + if (argc >= 3) { + if (!strcmp(argv[2], "hugetlbfs")) { + unsigned long hpage_size = default_huge_page_size(); + + if (!hpage_size) { + printf("Unable to determine huge page size\n"); + abort(); + } + + hugetlbfs_test = 1; + mfd_def_size = hpage_size * 2; + } else { + printf("Unknown option: %s\n", argv[2]); + abort(); + } + } + + zero = calloc(sizeof(*zero), mfd_def_size); + /* open FUSE memfd file for GUP testing */ printf("opening: %s\n", argv[1]); fd = open(argv[1], O_RDONLY | O_CLOEXEC); @@ -245,7 +266,7 @@ int main(int argc, char **argv) /* create new memfd-object */ mfd = mfd_assert_new("kern_memfd_fuse", - MFD_DEF_SIZE, + mfd_def_size, MFD_CLOEXEC | MFD_ALLOW_SEALING); /* mmap memfd-object for writing */ @@ -264,7 +285,7 @@ int main(int argc, char **argv) * This guarantees that the receive-buffer is pinned for 1s until the * data is written into it. The racing ADD_SEALS should thus fail as * the pages are still pinned. */ - r = read(fd, p, MFD_DEF_SIZE); + r = read(fd, p, mfd_def_size); if (r < 0) { printf("read() failed: %m\n"); abort(); @@ -291,10 +312,10 @@ int main(int argc, char **argv) * enough to avoid any in-flight writes. */ p = mfd_assert_mmap_private(mfd); - if (was_sealed && memcmp(p, zero, MFD_DEF_SIZE)) { + if (was_sealed && memcmp(p, zero, mfd_def_size)) { printf("memfd sealed during read() but data not discarded\n"); abort(); - } else if (!was_sealed && !memcmp(p, zero, MFD_DEF_SIZE)) { + } else if (!was_sealed && !memcmp(p, zero, mfd_def_size)) { printf("memfd sealed after read() but data discarded\n"); abort(); } @@ -303,6 +324,7 @@ int main(int argc, char **argv) close(fd); printf("fuse: DONE\n"); + free(zero); return 0; } diff --git a/tools/testing/selftests/memfd/run_fuse_test.sh b/tools/testing/selftests/memfd/run_fuse_test.sh index 407df68dfe27..22e572e2d66a 100755 --- a/tools/testing/selftests/memfd/run_fuse_test.sh +++ b/tools/testing/selftests/memfd/run_fuse_test.sh @@ -10,6 +10,6 @@ set -e mkdir mnt ./fuse_mnt ./mnt -./fuse_test ./mnt/memfd +./fuse_test ./mnt/memfd $@ fusermount -u ./mnt rmdir ./mnt diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh index daabb350697c..c2d41ed81b24 100755 --- a/tools/testing/selftests/memfd/run_tests.sh +++ b/tools/testing/selftests/memfd/run_tests.sh @@ -60,6 +60,7 @@ fi # Run the hugetlbfs test # ./memfd_test hugetlbfs +./run_fuse_test.sh hugetlbfs # # Give back any huge pages allocated for the test -- 2.15.0.125.g8f49766d64 From 1583470092436510019@xxx Wed Nov 08 04:19:17 +0000 2017 X-GM-THRID: 1583005705143932866 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread