Hello community,

here is the log from the commit of package libhugetlbfs for openSUSE:Factory 
checked in at 2017-03-12 20:04:59
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libhugetlbfs (Old)
 and      /work/SRC/openSUSE:Factory/.libhugetlbfs.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libhugetlbfs"

Sun Mar 12 20:04:59 2017 rev:43 rq:478037 version:2.20

Changes:
--------
--- /work/SRC/openSUSE:Factory/libhugetlbfs/libhugetlbfs.changes        
2015-11-08 11:27:05.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.libhugetlbfs.new/libhugetlbfs.changes   
2017-03-12 20:05:02.636893715 +0100
@@ -1,0 +2,9 @@
+Thu Mar  9 09:10:07 UTC 2017 - [email protected]
+
+- Update to 2.20
+- Bug Fixes:
+  * Fix keyword collisions and warnings from GCC 5
+  * hugeadm output is parsed for default size in huge_page_setup_helper
+  * Testsuite: fallocate tests
+
+-------------------------------------------------------------------

Old:
----
  libhugetlbfs-2.18.99.tar.xz

New:
----
  libhugetlbfs-2.20.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libhugetlbfs.spec ++++++
--- /var/tmp/diff_new_pack.0vxseX/_old  2017-03-12 20:05:03.556763551 +0100
+++ /var/tmp/diff_new_pack.0vxseX/_new  2017-03-12 20:05:03.564762419 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package libhugetlbfs
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %define my_make_flags V=1 CFLAGS="%{optflags} -fPIC" BUILDTYPE=NATIVEONLY 
PREFIX=%{_prefix} LIBDIR32=%{_libdir} DESTDIR=%{buildroot}
 Name:           libhugetlbfs
-Version:        2.18.99
+Version:        2.20
 Release:        0
 Summary:        Hugetlbfs helper library
 License:        LGPL-2.1+

++++++ _service ++++++
--- /var/tmp/diff_new_pack.0vxseX/_old  2017-03-12 20:05:03.612755628 +0100
+++ /var/tmp/diff_new_pack.0vxseX/_new  2017-03-12 20:05:03.616755062 +0100
@@ -3,8 +3,8 @@
     <param name="url">git://github.com/libhugetlbfs/libhugetlbfs.git</param>
     <param name="scm">git</param>
     <param name="filename">libhugetlbfs</param>
-    <param name="version">2.18.99</param>
-    <param name="revision">next</param>
+    <param name="version">2.20</param>
+    <param name="revision">2.20</param>
   </service>
   <service name="recompress" mode="disabled">
     <param name="file">*.tar</param>

++++++ libhugetlbfs-2.18.99.tar.xz -> libhugetlbfs-2.20.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/NEWS new/libhugetlbfs-2.20/NEWS
--- old/libhugetlbfs-2.18.99/NEWS       2015-11-06 13:01:34.000000000 +0100
+++ new/libhugetlbfs-2.20/NEWS  2015-12-04 03:04:07.000000000 +0100
@@ -1,3 +1,12 @@
+libhugetlbfs 2.20 "View Across the Charles"
+======================================================================
+Bug Fixes
+* Fix keyword collisions and warnings from GCC 5
+* hugeadm output is parsed for default size in huge_page_setup_helper
+
+Test Suite
+* fallocate tests
+
 libhugetlbfs 2.19 "Missing Longfellow Lanes"
 ======================================================================
 Bug Fixes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/README 
new/libhugetlbfs-2.20/README
--- old/libhugetlbfs-2.18.99/README     2015-11-06 13:01:34.000000000 +0100
+++ new/libhugetlbfs-2.20/README        2015-12-04 03:04:07.000000000 +0100
@@ -1,3 +1,15 @@
+03 December 2015 -- Yet another mailing list move
+
+librelist seems to be dead or at least broken.  I have recieved several
+emails directly saying that patches were posted, but they never got
+responses and the archives always seem empty.  So we are moving the list
+again.  This from here on out we will be using
+
[email protected]
+
+as our mailing list.  Please send patches to this list rather than
+creating a pull request.
+
 03 June 2015  -- libhugetlbfs to find new home
 
 As part of the fall out from the recent hijacking various "unmaintained"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/SubmittingCode 
new/libhugetlbfs-2.20/SubmittingCode
--- old/libhugetlbfs-2.18.99/SubmittingCode     2015-11-06 13:01:34.000000000 
+0100
+++ new/libhugetlbfs-2.20/SubmittingCode        2015-12-04 03:04:07.000000000 
+0100
@@ -9,7 +9,7 @@
 Also like the Linux kernel, we transact in patches over a mailing list.
 The libhugetlbfs mailing is at:
 
[email protected]
[email protected]
 
 You do not need to be subscribed to send mail to that list.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/Makefile 
new/libhugetlbfs-2.20/tests/Makefile
--- old/libhugetlbfs-2.18.99/tests/Makefile     2015-11-06 13:01:34.000000000 
+0100
+++ new/libhugetlbfs-2.20/tests/Makefile        2015-12-04 03:04:07.000000000 
+0100
@@ -13,7 +13,8 @@
        shm-perms \
        mremap-expand-slice-collision \
        mremap-fixed-normal-near-huge mremap-fixed-huge-near-normal \
-       corrupt-by-cow-opt noresv-preserve-resv-page noresv-regarded-as-resv
+       corrupt-by-cow-opt noresv-preserve-resv-page noresv-regarded-as-resv \
+       fallocate_basic fallocate_align fallocate_stress
 LIB_TESTS_64 =
 LIB_TESTS_64_STATIC = straddle_4GB huge_at_4GB_normal_below \
        huge_below_4GB_normal_above
@@ -26,7 +27,8 @@
 # NOTE: all named tests in WRAPPERS must also be named in TESTS
 WRAPPERS = quota counters madvise_reserve fadvise_reserve \
        readahead_reserve mremap-expand-slice-collision \
-       mremap-fixed-normal-near-huge mremap-fixed-huge-near-normal
+       mremap-fixed-normal-near-huge mremap-fixed-huge-near-normal \
+       fallocate_basic fallocate_align fallocate_stress
 HELPERS = get_hugetlbfs_path compare_kvers
 HELPER_LIBS = libheapshrink.so
 BADTOOLCHAIN = bad-toolchain.sh
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/fallocate_align.c 
new/libhugetlbfs-2.20/tests/fallocate_align.c
--- old/libhugetlbfs-2.18.99/tests/fallocate_align.c    1970-01-01 
01:00:00.000000000 +0100
+++ new/libhugetlbfs-2.20/tests/fallocate_align.c       2015-12-04 
03:04:07.000000000 +0100
@@ -0,0 +1,141 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 20015 Mike Kravetz, Oracle Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include <hugetlbfs.h>
+
+#include "hugetests.h"
+
+#define P "fallocate-align"
+#define DESC \
+       "* Test alignment of fallocate arguments.  fallocate will take     *\n"\
+       "* non-huge page aligned offsets and addresses.  However,          *\n"\
+       "* operations are only performed on huge pages.  This is different *\n"\
+       "* that than fallocate behavior in "normal" filesystems.           *"
+
+int main(int argc, char *argv[])
+{
+       long hpage_size;
+       int fd;
+       int err;
+       unsigned long free_before, free_after;
+
+       test_init(argc, argv);
+
+       hpage_size = check_hugepagesize();
+
+       fd = hugetlbfs_unlinked_fd();
+       if (fd < 0)
+               FAIL("hugetlbfs_unlinked_fd()");
+
+       free_before = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+
+       /*
+        * First preallocate file with with just 1 byte.  Allocation sizes
+        * are rounded up, so we should get an entire huge page.
+        */
+       err = fallocate(fd, 0, 0, 1);
+       if (err) {
+               if (errno == EOPNOTSUPP)
+                       IRRELEVANT();
+               if (err)
+                       FAIL("fallocate(): %s", strerror(errno));
+       }
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_before - free_after != 1)
+               FAIL("fallocate 1 byte did not preallocate entire huge page\n");
+
+       /*
+        * Now punch a hole with just 1 byte.  On hole punch, sizes are
+        * rounded down.  So, this operation should not create a hole.
+        */
+       err = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                       0, 1);
+       if (err)
+               FAIL("fallocate(FALLOC_FL_PUNCH_HOLE): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_after == free_before)
+               FAIL("fallocate hole punch 1 byte free'ed a huge page\n");
+
+       /*
+        * Now punch a hole with of 2 * hpage_size - 1 byte.  This size
+        * should be rounded down to a single huge page and the hole created.
+        */
+       err = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                       0, (2 * hpage_size) - 1);
+       if (err)
+               FAIL("fallocate(FALLOC_FL_PUNCH_HOLE): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_after != free_before)
+               FAIL("fallocate hole punch 2 * hpage_size - 1 byte did not free 
huge page\n");
+
+       /*
+        * Perform a preallocate operation with offset 1 and size of
+        * hpage_size.  The offset should be rounded down and the
+        * size rounded up to preallocate two huge pages.
+        */
+       err = fallocate(fd, 0, 1, hpage_size);
+       if (err)
+               FAIL("fallocate(): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_before - free_after != 2)
+               FAIL("fallocate 1 byte offset, huge page size did not 
preallocate two huge pages\n");
+
+       /*
+        * The hole punch code will only delete 'whole' huge pags that are
+        * in the specified range.  The offset is rounded up, and (offset
+        * + size) is rounded down to determine the huge pages to be deleted.
+        * In this case, after rounding the range is (hpage_size, hpage_size).
+        * So, no pages should be deleted.
+        */
+       err = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                       1, hpage_size);
+       if (err)
+               FAIL("fallocate(FALLOC_FL_PUNCH_HOLE): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_before - free_after != 2)
+               FAIL("fallocate hole punch 1 byte offset, huge page size 
incorrectly deleted a huge page\n");
+
+       /*
+        * To delete both huge pages, the range passed to hole punch must
+        * overlap the allocated pages
+        */
+       err = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                       0, 2 * hpage_size);
+       if (err)
+               FAIL("fallocate(FALLOC_FL_PUNCH_HOLE): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_after != free_before)
+               FAIL("fallocate hole punch did not delete two huge pages\n");
+
+       PASS();
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/fallocate_align.sh 
new/libhugetlbfs-2.20/tests/fallocate_align.sh
--- old/libhugetlbfs-2.18.99/tests/fallocate_align.sh   1970-01-01 
01:00:00.000000000 +0100
+++ new/libhugetlbfs-2.20/tests/fallocate_align.sh      2015-12-04 
03:04:07.000000000 +0100
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+. wrapper-utils.sh
+
+#
+# hugetlbfs fallocate support was not available until 4.3
+#
+compare_kvers `uname -r` "4.3.0"
+if [ $? -eq 1 ]; then
+       echo "FAIL no fallocate support in kernels before 4.3.0"
+       exit $RC_FAIL
+else
+       EXP_RC=$RC_PASS
+       exec_and_check $EXP_RC fallocate_align "$@"
+fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/fallocate_basic.c 
new/libhugetlbfs-2.20/tests/fallocate_basic.c
--- old/libhugetlbfs-2.18.99/tests/fallocate_basic.c    1970-01-01 
01:00:00.000000000 +0100
+++ new/libhugetlbfs-2.20/tests/fallocate_basic.c       2015-12-04 
03:04:07.000000000 +0100
@@ -0,0 +1,89 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 20015 Mike Kravetz, Oracle Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+#include <hugetlbfs.h>
+
+#include "hugetests.h"
+
+#define P "fallocate-basic"
+#define DESC \
+       "* Test basic fallocate functionality in hugetlbfs.  Preallocate   *\n"\
+       "* huge pages to a file in hugetlbfs, and then remove the pages    *\n"\
+       "* via hole punch.                                                 *"
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+#define MAX_PAGES_TO_USE 5
+
+int main(int argc, char *argv[])
+{
+       long hpage_size;
+       long nr_hpages_free;
+       int fd;
+       int err;
+       int max_iterations;
+       unsigned long free_before, free_after;
+
+       test_init(argc, argv);
+
+       hpage_size = check_hugepagesize();
+       nr_hpages_free = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       max_iterations = min(nr_hpages_free, MAX_PAGES_TO_USE);
+
+       fd = hugetlbfs_unlinked_fd();
+       if (fd < 0)
+               FAIL("hugetlbfs_unlinked_fd()");
+
+       free_before = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+
+       /* First preallocate file with max_iterations pages */
+       err = fallocate(fd, 0, 0, hpage_size * max_iterations);
+       if (err) {
+               if (errno == EOPNOTSUPP)
+                       IRRELEVANT();
+               if (err)
+                       FAIL("fallocate(): %s", strerror(errno));
+       }
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_before - free_after != max_iterations)
+               FAIL("fallocate did not preallocate %u huge pages\n",
+                                                       max_iterations);
+
+       /* Now punch a hole of the same size */
+       err = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                       0, hpage_size * max_iterations);
+       if (err)
+               FAIL("fallocate(FALLOC_FL_PUNCH_HOLE): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_after != free_before)
+               FAIL("fallocate hole punch did not release %u huge pages\n",
+                                                       max_iterations);
+
+       PASS();
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/fallocate_basic.sh 
new/libhugetlbfs-2.20/tests/fallocate_basic.sh
--- old/libhugetlbfs-2.18.99/tests/fallocate_basic.sh   1970-01-01 
01:00:00.000000000 +0100
+++ new/libhugetlbfs-2.20/tests/fallocate_basic.sh      2015-12-04 
03:04:07.000000000 +0100
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+. wrapper-utils.sh
+
+#
+# hugetlbfs fallocate support was not available until 4.3
+#
+compare_kvers `uname -r` "4.3.0"
+if [ $? -eq 1 ]; then
+       echo "FAIL no fallocate support in kernels before 4.3.0"
+       exit $RC_FAIL
+else
+       EXP_RC=$RC_PASS
+       exec_and_check $EXP_RC fallocate_basic "$@"
+fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/fallocate_stress.c 
new/libhugetlbfs-2.20/tests/fallocate_stress.c
--- old/libhugetlbfs-2.18.99/tests/fallocate_stress.c   1970-01-01 
01:00:00.000000000 +0100
+++ new/libhugetlbfs-2.20/tests/fallocate_stress.c      2015-12-04 
03:04:07.000000000 +0100
@@ -0,0 +1,223 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 20015 Mike Kravetz, Oracle Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <hugetlbfs.h>
+
+#include "hugetests.h"
+
+#define P "fallocate-stress"
+#define DESC \
+       "* Stress test fallocate.  This test starts three threads.  Thread *\n"\
+       "* one will continually punch/fill holes via falloc.  Thread two   *\n"\
+       "* will continually fault in those same pages.  Thread three will  *\n"\
+       "* continually mmap/munmap that page range.                        *"
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+#define MAX_PAGES_TO_USE 100
+
+static int htlb_fd;
+static long max_hpages;
+static long hpage_size;
+
+#define FALLOCATE_ITERATIONS 100000
+static void *thread_fallocate(void *arg)
+{
+       int i, err;
+       long tpage;
+
+       for (i=0; i < FALLOCATE_ITERATIONS; i++) {
+               tpage = ((long long)random()) % (max_hpages);
+               err = fallocate(htlb_fd,
+                               FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+                               tpage * hpage_size, hpage_size);
+               if (err)
+                       FAIL("fallocate(): %s", strerror(errno));
+               err = fallocate(htlb_fd, 0, tpage * hpage_size, hpage_size);
+               if (err)
+                       FAIL("fallocate(FALLOC_FL_PUNCH_HOLE): %s",
+                               strerror(errno));
+       }
+
+       return NULL;
+}
+
+static void *fault_mmap_addr = NULL;
+
+static void thread_fault_cleanup(void *arg)
+{
+       if (fault_mmap_addr)
+               munmap(fault_mmap_addr, max_hpages * hpage_size);
+}
+
+static void *thread_fault(void *arg)
+{
+       long tpage;
+       char foo;
+       struct timespec ts;
+
+       fault_mmap_addr = mmap(NULL, max_hpages * hpage_size,
+                               PROT_READ | PROT_WRITE, MAP_SHARED,
+                               htlb_fd, 0);
+       if (fault_mmap_addr == MAP_FAILED)
+               FAIL("mmap(): %s", strerror(errno));
+
+       pthread_cleanup_push(thread_fault_cleanup, NULL);
+
+       ts.tv_sec = 0;
+       ts.tv_nsec = 0;
+
+       while (1) {
+               tpage = ((long long)random()) % (max_hpages);
+
+               foo = *((char *)(fault_mmap_addr + (tpage * hpage_size)));
+               *((char *)(fault_mmap_addr + (tpage * hpage_size))) = foo;
+
+               nanosleep(&ts, NULL);   /* thread cancellation point */
+       }
+
+       pthread_cleanup_pop(1);
+
+       return NULL;
+}
+
+static void *mmap_munmap_addr = NULL;
+
+static void thread_mmap_munmap_cleanup(void *arg)
+{
+       if (mmap_munmap_addr)
+               munmap(mmap_munmap_addr, max_hpages * hpage_size);
+}
+
+static void *thread_mmap_munmap(void *arg)
+{
+       int err;
+       struct timespec ts;
+
+       pthread_cleanup_push(thread_mmap_munmap_cleanup, NULL);
+
+       ts.tv_sec = 0;
+       ts.tv_nsec = 0;
+
+       while (1) {
+               mmap_munmap_addr = mmap(NULL, max_hpages * hpage_size,
+                                       PROT_READ | PROT_WRITE,
+                                       MAP_SHARED, htlb_fd, 0);
+               if (mmap_munmap_addr == MAP_FAILED)
+                       FAIL("mmap(): %s", strerror(errno));
+
+               err = munmap(mmap_munmap_addr, max_hpages * hpage_size);
+               if (err)
+                       FAIL("munmap(): %s", strerror(errno));
+               mmap_munmap_addr = NULL;
+
+               nanosleep(&ts, NULL);   /* thread cancellation point */
+       }
+
+       pthread_cleanup_pop(1);
+
+       return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+       long nr_hpages_free;
+       int err;
+       unsigned long free_before, free_after;
+       unsigned long rsvd_before, rsvd_after;
+       pthread_t falloc_th, fault_th, mmap_munmap_th;
+       void *falloc_th_ret, *fault_th_ret, *mmap_munmap_th_ret;
+
+       test_init(argc, argv);
+
+       srandom((int)getpid() * time(NULL));
+       hpage_size = check_hugepagesize();
+       nr_hpages_free = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       max_hpages = min(nr_hpages_free, MAX_PAGES_TO_USE);
+
+       htlb_fd = hugetlbfs_unlinked_fd();
+       if (htlb_fd < 0)
+               FAIL("hugetlbfs_unlinked_fd()");
+
+       free_before = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       rsvd_before = get_huge_page_counter(hpage_size, HUGEPAGES_RSVD);
+
+       /* First preallocate file with max_hpages pages */
+       err = fallocate(htlb_fd, 0, 0, hpage_size * max_hpages);
+       if (err) {
+               if (errno == EOPNOTSUPP)
+                       IRRELEVANT();
+               if (err)
+                       FAIL("fallocate(): %s", strerror(errno));
+       }
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       if (free_before - free_after != max_hpages)
+               FAIL("fallocate did not preallocate %ld huge pages\n",
+                                                       max_hpages);
+
+       err = pthread_create(&falloc_th, NULL, thread_fallocate, NULL);
+       if (err != 0)
+               FAIL("pthread_create(): %s\n", strerror(errno));
+       err = pthread_create(&fault_th, NULL, thread_fault, NULL);
+       if (err != 0)
+               FAIL("pthread_create(): %s\n", strerror(errno));
+       err = pthread_create(&mmap_munmap_th, NULL, thread_mmap_munmap, NULL);
+       if (err != 0)
+               FAIL("pthread_create(): %s\n", strerror(errno));
+
+       err = pthread_join(falloc_th, &falloc_th_ret);
+       if (err != 0)
+               FAIL("pthread_join(): %s\n", strerror(errno));
+       if (falloc_th_ret)
+               FAIL("thread_fallocate unexpected exit code\n");
+
+       err = pthread_cancel(fault_th);
+       if (err != 0)
+               FAIL("pthread_cancel(): %s\n", strerror(errno));
+       err = pthread_join(fault_th, &fault_th_ret);
+       if (err != 0)
+               FAIL("pthread_join(): %s\n", strerror(errno));
+
+       err = pthread_cancel(mmap_munmap_th);
+       if (err != 0)
+               FAIL("pthread_cancel(): %s\n", strerror(errno));
+       err = pthread_join(mmap_munmap_th, &mmap_munmap_th_ret);
+       if (err != 0)
+               FAIL("pthread_join(): %s\n", strerror(errno));
+
+       if (close(htlb_fd))
+               FAIL("close(): %s", strerror(errno));
+
+       free_after = get_huge_page_counter(hpage_size, HUGEPAGES_FREE);
+       rsvd_after = get_huge_page_counter(hpage_size, HUGEPAGES_RSVD);
+       if (free_after != free_before || rsvd_after != rsvd_before)
+               FAIL("free or reserve counts not correct after fallocate stress 
testing\n");
+
+       PASS();
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/fallocate_stress.sh 
new/libhugetlbfs-2.20/tests/fallocate_stress.sh
--- old/libhugetlbfs-2.18.99/tests/fallocate_stress.sh  1970-01-01 
01:00:00.000000000 +0100
+++ new/libhugetlbfs-2.20/tests/fallocate_stress.sh     2015-12-04 
03:04:07.000000000 +0100
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+. wrapper-utils.sh
+
+#
+# hugetlbfs fallocate support was not available until 4.3
+#
+compare_kvers `uname -r` "4.3.0"
+if [ $? -eq 1 ]; then
+       echo "FAIL no fallocate support in kernels before 4.3.0"
+       exit $RC_FAIL
+else
+       EXP_RC=$RC_PASS
+       exec_and_check $EXP_RC fallocate_stress "$@"
+fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.18.99/tests/run_tests.py 
new/libhugetlbfs-2.20/tests/run_tests.py
--- old/libhugetlbfs-2.18.99/tests/run_tests.py 2015-11-06 13:01:34.000000000 
+0100
+++ new/libhugetlbfs-2.20/tests/run_tests.py    2015-12-04 03:04:07.000000000 
+0100
@@ -519,6 +519,8 @@
     do_test("mprotect")
     do_test_with_rlimit(resource.RLIMIT_MEMLOCK, -1, "mlock")
     do_test("misalign")
+    do_test("fallocate_basic.sh")
+    do_test("fallocate_align.sh")
 
     # Specific kernel bug tests
     do_test("ptrace-write-hugepage")
@@ -650,6 +652,8 @@
 
     do_shm_test(("shm-getraw", repr(nr_pages), "/dev/full"), limit)
 
+    do_test("fallocate_stress.sh")
+
 def main():
     global wordsizes, pagesizes, dangerous, paranoid_pool_check, 
system_default_hpage_size
     global custom_ldscripts


Reply via email to