Received: by 10.223.164.202 with SMTP id h10csp766821wrb; Tue, 7 Nov 2017 14:18:11 -0800 (PST) X-Google-Smtp-Source: ABhQp+Qq3Ht6Dxc8SmAl3h7BDMhvucvORSuzj/bk1H9Dcqkti/n1mk14ARlMp2iFl/kntrLoIOQJ X-Received: by 10.84.224.1 with SMTP id r1mr191298plj.65.1510093091861; Tue, 07 Nov 2017 14:18:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510093091; cv=none; d=google.com; s=arc-20160816; b=V7PSprWhlbWX7xAt28GyNVfESc+20HZjq43Eu1D8Fhoz5ehuZo8zeGRAHiC5Q5bqM0 M9sysr3bOn0G/W7gKvj5M1owexlR+AlrXbcicx7e65EsO/yTrOI78ddJXYF719hvJZxu 3rpuU5gMgEeHfGst5x9ia3xrHgZwA/M7BIDwwL5ATffw65c2PjzY9J8AwKMrq927vRtb JglMTO2B+RsAn31WzsQdeDx2MvdR8wnFNT7HxnAb6CgrPoGmHBDoKsCqN0oBd82B4GzM 6qLOhBtjO8CJnWtt07hEMDgkQPyC+1PRlAYA34s2KD9x3rbl1KhbHtIPmfZuX5nfY8uw HlmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dmarc-filter :arc-authentication-results; bh=4HF36MQm+ECtX2QBKkTrrcLbuaF/qMMwWm6hKykqOu4=; b=eVChfArCqTE5gwTvYVnADop7jwfcWXriJde3dzogDUT9tbLNgVegsvIEk9lcC/WR6h u0+W76PFsjffF9SJ3FjVr8A98RLdvvu+JAbQGdjG2s4Re2DKk78w/EuP3EXZsBqt6dHI b1RBltXbC0hovdAhGT9iVN+IUmPIXmxVa+BpNo1N9sMYsKJVf1UL+05CkIK+w5YFner6 RAx7DS3BQBYXkFbf8GsFge65tDM/Tw6D5oH1bxR5SIYZ2U9VTipo5o4fOGut/Ewq/iqY pWAYJsp0BQxw4xd0+9WEAj4j0mBVl+636GM1kpIZT78j4sv1Gi45cqB5dbS5mn3gaCSp 3xVQ== 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 f34si2053336ple.249.2017.11.07.14.17.58; Tue, 07 Nov 2017 14:18:11 -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 S933572AbdKGMMP convert rfc822-to-8bit (ORCPT + 91 others); Tue, 7 Nov 2017 07:12:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40456 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755985AbdKGMMN (ORCPT ); Tue, 7 Nov 2017 07:12:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64BC4267DC; Tue, 7 Nov 2017 12:12:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64BC4267DC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mlureau@redhat.com Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4748C60BE3; Tue, 7 Nov 2017 12:12:13 +0000 (UTC) Received: from zmail17.collab.prod.int.phx2.redhat.com (zmail17.collab.prod.int.phx2.redhat.com [10.5.83.19]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 09D281800BD3; Tue, 7 Nov 2017 12:12:13 +0000 (UTC) Date: Tue, 7 Nov 2017 07:12:12 -0500 (EST) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, aarcange@redhat.com, hughd@google.com, nyc@holomorphy.com Message-ID: <1272204993.37283597.1510056732810.JavaMail.zimbra@redhat.com> In-Reply-To: <988f32e8-9073-0022-076b-6f86dc650a9c@oracle.com> References: <20171106143944.13821-1-marcandre.lureau@redhat.com> <20171106143944.13821-10-marcandre.lureau@redhat.com> <988f32e8-9073-0022-076b-6f86dc650a9c@oracle.com> Subject: Re: [PATCH v2 9/9] memfd-test: run fuse test on hugetlb backend memory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.36.112.38, 10.4.195.26] Thread-Topic: memfd-test: run fuse test on hugetlb backend memory Thread-Index: NfP2gZXsit8FgY2W3ax4kUy1feYLyw== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 07 Nov 2017 12:12:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi ----- Original Message ----- > On 11/06/2017 06:39 AM, Marc-André Lureau wrote: > > Suggested-by: Mike Kravetz > > Signed-off-by: Marc-André Lureau > > --- > > tools/testing/selftests/memfd/fuse_test.c | 30 > > ++++++++++++++++++++++---- > > tools/testing/selftests/memfd/run_fuse_test.sh | 2 +- > > tools/testing/selftests/memfd/run_tests.sh | 1 + > > 3 files changed, 28 insertions(+), 5 deletions(-) > > > > diff --git a/tools/testing/selftests/memfd/fuse_test.c > > b/tools/testing/selftests/memfd/fuse_test.c > > index 795a25ba8521..0a85b34929e1 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); > > When ftruncate'ing the newly created file, you need to make sure length is > a multiple of huge page size for hugetlbfs files. So, you will want to > do something like: > > --- a/tools/testing/selftests/memfd/fuse_test.c > +++ b/tools/testing/selftests/memfd/fuse_test.c > @@ -265,7 +265,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 */ > > Leaving MFD_DEF_SIZE for the size of reads and writes should be fine. I actually intended to replace all MFD_DEF_SIZE with mfd_def_size. Should be fine too. Resending updated series. > > -- > Mike Kravetz > > > @@ -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 > > > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org > From 1583421158555422349@xxx Tue Nov 07 15:21:30 +0000 2017 X-GM-THRID: 1583328137525009507 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread