From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
aarcange@redhat.com, hughd@google.com, nyc@holomorphy.com
Subject: Re: [PATCH v2 9/9] memfd-test: run fuse test on hugetlb backend memory
Date: Tue, 7 Nov 2017 07:12:12 -0500 (EST) [thread overview]
Message-ID: <1272204993.37283597.1510056732810.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <988f32e8-9073-0022-076b-6f86dc650a9c@oracle.com>
Hi
----- Original Message -----
> On 11/06/2017 06:39 AM, Marc-André Lureau wrote:
> > Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > 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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
next prev parent reply other threads:[~2017-11-07 12:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 14:39 [PATCH v2 0/9] memfd: add sealing to hugetlb-backed memory Marc-André Lureau
2017-11-06 14:39 ` [PATCH v2 1/9] shmem: unexport shmem_add_seals()/shmem_get_seals() Marc-André Lureau
2017-11-06 14:39 ` [PATCH v2 2/9] shmem: rename functions that are memfd-related Marc-André Lureau
2017-11-06 14:39 ` [PATCH v2 3/9] hugetlb: expose hugetlbfs_inode_info in header Marc-André Lureau
2017-11-06 14:39 ` [PATCH v2 4/9] hugetlbfs: implement memfd sealing Marc-André Lureau
2017-11-06 14:39 ` [PATCH v2 5/9] shmem: add sealing support to hugetlb-backed memfd Marc-André Lureau
2017-11-06 23:56 ` Mike Kravetz
2017-11-06 14:39 ` [PATCH v2 6/9] memfd-tests: test hugetlbfs sealing Marc-André Lureau
2017-11-07 1:30 ` Mike Kravetz
2017-11-06 14:39 ` [PATCH v2 7/9] memfd-test: add 'memfd-hugetlb:' prefix when testing hugetlbfs Marc-André Lureau
2017-11-07 1:31 ` Mike Kravetz
2017-11-06 14:39 ` [PATCH v2 8/9] memfd-test: move common code to a shared unit Marc-André Lureau
2017-11-07 1:32 ` Mike Kravetz
2017-11-06 14:39 ` [PATCH v2 9/9] memfd-test: run fuse test on hugetlb backend memory Marc-André Lureau
2017-11-07 1:41 ` Mike Kravetz
2017-11-07 12:12 ` Marc-André Lureau [this message]
2017-11-07 1:47 ` [PATCH v2 0/9] memfd: add sealing to hugetlb-backed memory Mike Kravetz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1272204993.37283597.1510056732810.JavaMail.zimbra@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=aarcange@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=nyc@holomorphy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).