Hello community,

here is the log from the commit of package libhugetlbfs for openSUSE:Factory 
checked in at 2012-04-17 07:45:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libhugetlbfs (Old)
 and      /work/SRC/openSUSE:Factory/.libhugetlbfs.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libhugetlbfs", Maintainer is "tr...@novell.com"

Changes:
--------
--- /work/SRC/openSUSE:Factory/libhugetlbfs/libhugetlbfs.changes        
2011-10-16 12:56:13.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.libhugetlbfs.new/libhugetlbfs.changes   
2012-04-17 07:46:04.000000000 +0200
@@ -1,0 +2,11 @@
+Tue Apr 10 19:51:51 UTC 2012 - tabra...@novell.com
+
+- Update to version 2.13
+  * hugeadm can now be used to control Transparent Huge Page tunables
+  * New morecore mode to better support THP
+  * Check permissions on hugetlbfs mount point before marking it as 
+    available
+  * Fix shm tests to use random address instead of fixed, old address 
+    failed on ARM
+
+-------------------------------------------------------------------

Old:
----
  libhugetlbfs-2.12.tar.gz

New:
----
  libhugetlbfs-2.13.tar.gz

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

Other differences:
------------------
++++++ libhugetlbfs.spec ++++++
--- /var/tmp/diff_new_pack.b13KYd/_old  2012-04-17 07:46:09.000000000 +0200
+++ /var/tmp/diff_new_pack.b13KYd/_new  2012-04-17 07:46:09.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package libhugetlbfs
 #
-# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2012 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
@@ -15,8 +15,6 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
-# norootforbuild
-
 
 Name:           libhugetlbfs
 
@@ -25,16 +23,16 @@
 %endif
 BuildRequires:  doxygen
 
+Summary:        Hugetlbfs helper library
 License:        LGPL-2.1+
 Group:          Development/Libraries/Other
-Summary:        Hugetlbfs helper library
 # bug437293
 %ifarch ppc64
 Obsoletes:      libhugetlbfs-64bit
 %endif
 #
-Version:        2.12
-Release:        1
+Version:        2.13
+Release:        0
 Url:            http://libhugetlbfs.sourceforge.net/
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 %define my_make_flags V=1 CFLAGS="$RPM_OPT_FLAGS -fPIC" BUILDTYPE=NATIVEONLY 
PREFIX=/usr LIBDIR32=%{_libdir} DESTDIR=$RPM_BUILD_ROOT
@@ -49,11 +47,9 @@
 make large pages available to applications in a transparent manner.
 
 %package libhugetlb-devel
-License:        LGPL-2.1+
 Summary:        Devel package for libhugetlb
-Requires:       libhugetlbfs
 Group:          Development/Libraries/Other
-AutoReqProv:    on
+Requires:       libhugetlbfs
 
 %description libhugetlb-devel
 Devel package, header and static library, of libhugetlb

++++++ libhugetlbfs-2.12.tar.gz -> libhugetlbfs-2.13.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/HOWTO new/libhugetlbfs-2.13/HOWTO
--- old/libhugetlbfs-2.12/HOWTO 2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/HOWTO 2012-03-05 14:20:12.000000000 +0100
@@ -2,7 +2,7 @@
 ==================
 
 Author: David Gibson <d...@au1.ibm.com>, Adam Litke <a...@us.ibm.com>, and 
others
-Last updated: February 1st, 2011
+Last updated: December 07, 2011
 
 Introduction
 ============
@@ -264,6 +264,11 @@
   To use a specific huge page size:
        HUGETLB_MORECORE=<pagesize>
 
+  To use Transparent Huge Pages (THP):
+       HUGETLB_MORECORE=thp
+
+Note: This option requires a kernel that supports Transparent Huge Pages
+
 Usually it's preferable to set these environment variables on the
 command line of the program you wish to run, rather than using
 "export", because you'll only want to enable the hugepage malloc() for
@@ -284,9 +289,9 @@
 Under some circumstances, you might want to specify the address where
 the hugepage heap is located.  You can do this by setting the
 HUGETLB_MORECORE_HEAPBASE environment variable to the heap address in
-hexadecimal.  (NOTE: this will not work on PowerPC systems with old kernels
+hexadecimal.  NOTE: this will not work on PowerPC systems with old kernels
 which don't respect the hugepage hint address; see Kernel Prerequisites
-above).
+above.  Also note that this option is ignored for THP morecore.
 
 By default, the hugepage heap begins at roughly the same place a
 normal page heap would, rounded up by an amount determined by your
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/Makefile 
new/libhugetlbfs-2.13/Makefile
--- old/libhugetlbfs-2.12/Makefile      2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/Makefile      2012-03-05 14:20:12.000000000 +0100
@@ -196,7 +196,7 @@
 tests: libs # Force make to build the library first
 tests: tests/all
 
-tests/%:
+tests/%: libs
        $(MAKE) -C tests $*
 
 tools:  $(foreach file,$(INSTALL_BIN),$(BIN_OBJ_DIR)/$(file))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/NEWS new/libhugetlbfs-2.13/NEWS
--- old/libhugetlbfs-2.12/NEWS  2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/NEWS  2012-03-05 14:20:12.000000000 +0100
@@ -1,3 +1,16 @@
+libhugetlbfs 2.13 "Insert Clever Title Here"
+======================================================================
+New Features
+* hugeadm can now be used to control Transparent Huge Page tunables
+* New morecore mode to better support THP
+
+Bug Fixes
+* Check permissions on hugetlbfs mount point before marking it as available
+
+Test Suite
+* Fix shm tests to use random address instead of fixed, old address failed
+  on ARM
+
 libhugetlbfs 2.12 "Serrano"
 ======================================================================
 New Features
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/hugeadm.c 
new/libhugetlbfs-2.13/hugeadm.c
--- old/libhugetlbfs-2.12/hugeadm.c     2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/hugeadm.c     2012-03-05 14:20:12.000000000 +0100
@@ -83,6 +83,14 @@
 #define SWAP_FREE "SwapFree:"
 #define SWAP_TOTAL "SwapTotal:"
 
+#define ALWAYS           "always"
+#define MADVISE                  "madvise"
+#define NEVER            "never"
+#define TRANS_ENABLE     "/sys/kernel/mm/transparent_hugepage/enabled"
+#define KHUGE_SCAN_PAGES  
"/sys/kernel/mm/transparent_hugepage/khugepaged/pages_to_scan"
+#define KHUGE_SCAN_SLEEP  
"/sys/kernel/mm/transparent_hugepage/khugepaged/scan_sleep_millisecs"
+#define KHUGE_ALLOC_SLEEP 
"/sys/kernel/mm/transparent_hugepage/khugepaged/alloc_sleep_millisecs"
+
 void print_usage()
 {
        fprintf(stderr, "hugeadm [options]\n");
@@ -97,6 +105,15 @@
        CONT("Adjust pool 'size' lower bound");
        OPTION("--obey-mempolicy", "Obey the NUMA memory policy when");
        CONT("adjusting the pool 'size' lower bound");
+       OPTION("--thp-always", "Enable transparent huge pages always");
+       OPTION("--thp-madvise", "Enable transparent huge pages with madvise");
+       OPTION("--thp-never", "Disable transparent huge pages");
+       OPTION("--thp-khugepaged-pages <pages to scan>", "Number of pages that 
khugepaged");
+       CONT("should scan on each pass");
+       OPTION("--thp-khugepaged-scan-sleep <milliseconds>", "Time in ms to 
sleep between");
+       CONT("khugepaged passes");
+       OPTION("--thp-khugepages-alloc-sleep <milliseconds>", "Time in ms for 
khugepaged");
+       CONT("to wait if there was a huge page allocation failure");
        OPTION("--pool-pages-max 
<size|DEFAULT>:[+|-]<pagecount|memsize<G|M|K>>", "");
        CONT("Adjust pool 'size' upper bound");
        OPTION("--set-recommended-min_free_kbytes", "");
@@ -271,6 +288,16 @@
 
 #define LONG_EXPLAIN   ('e' << 8)
 
+#define LONG_TRANS                     ('t' << 8)
+#define LONG_TRANS_ALWAYS              (LONG_TRANS|'a')
+#define LONG_TRANS_MADVISE             (LONG_TRANS|'m')
+#define LONG_TRANS_NEVER               (LONG_TRANS|'n')
+
+#define LONG_KHUGE                     ('K' << 8)
+#define LONG_KHUGE_PAGES               (LONG_KHUGE|'p')
+#define LONG_KHUGE_SCAN                        (LONG_KHUGE|'s')
+#define LONG_KHUGE_ALLOC               (LONG_KHUGE|'a')
+
 #define MAX_POOLS      32
 
 static int cmpsizes(const void *p1, const void *p2)
@@ -1062,6 +1089,30 @@
        }
 }
 
+void set_trans_opt(const char *file, const char *value)
+{
+       FILE *f;
+
+       if (geteuid() != 0) {
+                ERROR("Transparent huge page options can only be set by 
root\n");
+                exit(EXIT_FAILURE);
+        }
+
+       if (opt_dry_run) {
+               printf("echo '%s' > %s\n", value, file);
+               return;
+       }
+
+       f = fopen(file, "w");
+       if (!f) {
+               ERROR("Couldn't open %s: %s\n", file, strerror(errno));
+               return;
+       }
+
+       fprintf(f, "%s", value);
+       fclose(f);
+}
+
 enum {
        POOL_MIN,
        POOL_MAX,
@@ -1308,7 +1359,10 @@
        int opt_list_mounts = 0, opt_pool_list = 0, opt_create_mounts = 0;
        int opt_global_mounts = 0, opt_pgsizes = 0, opt_pgsizes_all = 0;
        int opt_explain = 0, minadj_count = 0, maxadj_count = 0;
+       int opt_trans_always = 0, opt_trans_never = 0, opt_trans_madvise = 0;
+       int opt_khuge_pages = 0, opt_khuge_scan = 0, opt_khuge_alloc = 0;
        int ret = 0, index = 0;
+       char *khuge_pages = NULL, *khuge_alloc = NULL, *khuge_scan = NULL;
        gid_t opt_gid = 0;
        struct group *opt_grp = NULL;
        int group_invalid = 0;
@@ -1321,6 +1375,12 @@
                {"pool-pages-min", required_argument, NULL, LONG_POOL_MIN_ADJ},
                {"pool-pages-max", required_argument, NULL, LONG_POOL_MAX_ADJ},
                {"obey-mempolicy", no_argument, NULL, LONG_POOL_MEMPOL},
+               {"thp-always", no_argument, NULL, LONG_TRANS_ALWAYS},
+               {"thp-madvise", no_argument, NULL, LONG_TRANS_MADVISE},
+               {"thp-never", no_argument, NULL, LONG_TRANS_NEVER},
+               {"thp-khugepaged-pages", required_argument, NULL, 
LONG_KHUGE_PAGES},
+               {"thp-khugepaged-scan-sleep", required_argument, NULL, 
LONG_KHUGE_SCAN},
+               {"thp-khugepaged-alloc-sleep", required_argument, NULL, 
LONG_KHUGE_ALLOC},
                {"set-recommended-min_free_kbytes", no_argument, NULL, 
LONG_SET_RECOMMENDED_MINFREEKBYTES},
                {"set-recommended-shmmax", no_argument, NULL, 
LONG_SET_RECOMMENDED_SHMMAX},
                {"set-shm-group", required_argument, NULL, 
LONG_SET_HUGETLB_SHM_GROUP},
@@ -1424,6 +1484,33 @@
                        opt_obey_mempolicy = 1;
                        break;
 
+               case LONG_TRANS_ALWAYS:
+                       opt_trans_always = 1;
+                       break;
+
+               case LONG_TRANS_MADVISE:
+                       opt_trans_madvise = 1;
+                       break;
+
+               case LONG_TRANS_NEVER:
+                       opt_trans_never = 1;
+                       break;
+
+               case LONG_KHUGE_PAGES:
+                       opt_khuge_pages = 1;
+                       khuge_pages = optarg;
+                       break;
+
+               case LONG_KHUGE_SCAN:
+                       opt_khuge_scan = 1;
+                       khuge_scan = optarg;
+                       break;
+
+               case LONG_KHUGE_ALLOC:
+                       opt_khuge_alloc = 1;
+                       khuge_alloc = optarg;
+                       break;
+
                case LONG_POOL_MAX_ADJ:
                        if (! kernel_has_overcommit()) {
                                ERROR("kernel does not support overcommit, "
@@ -1534,6 +1621,24 @@
        if (opt_movable != -1)
                setup_zone_movable(opt_movable);
 
+       if (opt_trans_always)
+               set_trans_opt(TRANS_ENABLE, ALWAYS);
+
+       if (opt_trans_madvise)
+               set_trans_opt(TRANS_ENABLE, MADVISE);
+
+       if (opt_trans_never)
+               set_trans_opt(TRANS_ENABLE, NEVER);
+
+       if (opt_khuge_pages)
+               set_trans_opt(KHUGE_SCAN_PAGES, khuge_pages);
+
+       if (opt_khuge_alloc)
+               set_trans_opt(KHUGE_ALLOC_SLEEP, khuge_alloc);
+
+       if (opt_khuge_scan)
+               set_trans_opt(KHUGE_SCAN_SLEEP, khuge_scan);
+
        if (opt_set_recommended_minfreekbytes)
                set_recommended_minfreekbytes();
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/hugectl.c 
new/libhugetlbfs-2.13/hugectl.c
--- old/libhugetlbfs-2.12/hugectl.c     2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/hugectl.c     2012-03-05 14:20:12.000000000 +0100
@@ -67,6 +67,10 @@
        OPTION("--heap[=<size>]", "Requests remapping of the program heap");
        CONT("(malloc space)");
        OPTION("--shm", "Requests remapping of shared memory segments");
+       OPTION("--thp", "Setup the heap space to be aligned for merging");
+       CONT("by khugepaged into huge pages.  This requires");
+       CONT("kernel support for transparent huge pages to be");
+       CONT("enabled");
 
        OPTION("--no-preload", "Disable preloading the libhugetlbfs library");
        OPTION("--no-reserve", "Disable huge page reservation for segments");
@@ -171,6 +175,8 @@
 #define LONG_NO_LIBRARY                (LONG_BASE | 'L')
 #define LONG_LIBRARY           (LONG_BASE | 'l')
 
+#define LONG_THP_HEAP          ('t')
+
 /*
  * Mapping selectors, one per remappable/backable area as requested
  * by the user.  These are also used as returns from getopts where they
@@ -341,6 +347,7 @@
        int opt_preload = 1;
        int opt_no_reserve = 0;
        int opt_share = 0;
+       int opt_thp_heap = 0;
        char *opt_library = NULL;
 
        char opts[] = "+hvq";
@@ -365,7 +372,7 @@
                {"bss",        optional_argument, NULL, MAP_BASE|MAP_BSS},
                {"heap",       optional_argument, NULL, MAP_BASE|MAP_HEAP},
                {"shm",        optional_argument, NULL, MAP_BASE|MAP_SHM},
-
+               {"thp",        no_argument, NULL, LONG_THP_HEAP},
                {0},
        };
 
@@ -398,6 +405,11 @@
                        quiet();
                        break;
 
+               case LONG_THP_HEAP:
+                       opt_thp_heap = 1;
+                       INFO("Aligning heap for use with THP\n");
+                       break;
+
                case LONG_NO_PRELOAD:
                        opt_preload = 0;
                        INFO("LD_PRELOAD disabled\n");
@@ -464,6 +476,9 @@
        if (opt_share)
                setup_environment("HUGETLB_SHARE", "1");
 
+       if (opt_thp_heap)
+               setup_environment("HUGETLB_MORECORE", "thp");
+
        if (opt_dry_run)
                exit(EXIT_SUCCESS);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/hugeutils.c 
new/libhugetlbfs-2.13/hugeutils.c
--- old/libhugetlbfs-2.12/hugeutils.c   2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/hugeutils.c   2012-03-05 14:20:12.000000000 +0100
@@ -335,6 +335,15 @@
        __hugetlb_opts.morecore = getenv("HUGETLB_MORECORE");
        __hugetlb_opts.heapbase = getenv("HUGETLB_MORECORE_HEAPBASE");
 
+       if (__hugetlb_opts.morecore)
+               __hugetlb_opts.thp_morecore =
+                       (strcasecmp(__hugetlb_opts.morecore, "thp") == 0);
+
+       if (__hugetlb_opts.thp_morecore && __hugetlb_opts.heapbase) {
+               DEBUG("Heapbase specified with THP for morecore, ignoring 
heapbase\n");
+               __hugetlb_opts.heapbase = NULL;
+       }
+
        env = getenv("HUGETLB_FORCE_ELFMAP");
        if (env && (strcasecmp(env, "yes") == 0))
                __hugetlb_opts.force_elfmap = 1;
@@ -371,12 +380,12 @@
 
        /* Determine if shmget() calls should be overridden */
        env = getenv("HUGETLB_SHM");
-       if (env && !strcmp(env, "yes"))
+       if (env && !strcasecmp(env, "yes"))
                __hugetlb_opts.shm_enabled = true;
 
        /* Determine if all reservations should be avoided */
        env = getenv("HUGETLB_NO_RESERVE");
-       if (env && !strcmp(env, "yes"))
+       if (env && !strcasecmp(env, "yes"))
                __hugetlb_opts.no_reserve = true;
 }
 
@@ -652,7 +661,8 @@
                 */
                err = sscanf(line, "%*s %" stringify(PATH_MAX) "s hugetlbfs "
                        "%*s %d", path, &dummy);
-               if ((err == 2) && (hugetlbfs_test_path(path) == 1))
+               if ((err == 2) && (hugetlbfs_test_path(path) == 1) &&
+                   !(access(path, R_OK | W_OK | X_OK)))
                        add_hugetlbfs_mount(path, 0);
        }
        close(fd);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/libhugetlbfs_internal.h 
new/libhugetlbfs-2.13/libhugetlbfs_internal.h
--- old/libhugetlbfs-2.12/libhugetlbfs_internal.h       2011-04-01 
22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/libhugetlbfs_internal.h       2012-03-05 
14:20:12.000000000 +0100
@@ -63,6 +63,7 @@
        bool            shm_enabled;
        bool            no_reserve;
        bool            map_hugetlb;
+       bool            thp_morecore;
        unsigned long   force_elfmap;
        char            *ld_preload;
        char            *elfmap;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/man/hugeadm.8 
new/libhugetlbfs-2.13/man/hugeadm.8
--- old/libhugetlbfs-2.12/man/hugeadm.8 2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/man/hugeadm.8 2012-03-05 14:20:12.000000000 +0100
@@ -238,10 +238,45 @@
 spaces can later be removed manually using the swapoff command.
 
 .PP
+The following options tune the transparent huge page usage
+
+.TP
+.B --thp-always
+
+Enable transparent huge pages always
+
+.TP
+.B --thp-madvise
+
+Enable transparent huge pages only on madvised regions
+
+.TP
+.B --thp-never
+
+Disable transparent huge pages
+
+.TP
+.B --thp-khugepaged-pages <pages to scan>
+
+Configure the number of pages that khugepaged should scan on each pass
+
+.TP
+.B --thp-khugepaged-scan-sleep <milliseconds>
+
+Configure how many milliseconds khugepaged should wait between passes
+
+.TP
+.B --thp-khugepages-alloc-sleep <milliseconds>
+
+Configure how many milliseconds khugepaged should wait after failing to
+allocate a huge page to throttle the next attempt.
+
+.PP
 The following options affect the verbosity of libhugetlbfs.
 
 .TP
 .B --verbose <level>, -v
+
 The default value for the verbosity level is 1 and the range of the value can
 be set with --verbose from 0 to 99. The higher the value, the more verbose the
 library will be. 0 is quiet and 3 will output much debugging information. The
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/man/hugectl.8 
new/libhugetlbfs-2.13/man/hugectl.8
--- old/libhugetlbfs-2.12/man/hugectl.8 2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/man/hugectl.8 2012-03-05 14:20:12.000000000 +0100
@@ -63,6 +63,11 @@
 backed with huge pages.  This option sets the environment variable
 HUGETLB_SHARE to 1.
 
+.TP
+.B --thp
+Align heap regions to huge page size for promotion by khugepaged.  For more
+information on transparent huge pages see linux-2.6/Documentation/transhuge.txt
+
 .PP
 The following options affect how \fBhugectl\fP behaves.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/morecore.c 
new/libhugetlbfs-2.13/morecore.c
--- old/libhugetlbfs-2.12/morecore.c    2011-04-01 22:39:44.000000000 +0200
+++ new/libhugetlbfs-2.13/morecore.c    2012-03-05 14:20:12.000000000 +0100
@@ -202,6 +202,73 @@
        return p;
 }
 
+static void *thp_morecore(ptrdiff_t increment)
+{
+       void *p;
+       long delta;
+
+       INFO("thp_morecore(%ld) = ...\n", (long)increment);
+
+       delta = (heaptop - heapbase) + increment - mapsize;
+       delta = ALIGN(delta, hpage_size);
+
+       if (delta > 0) {
+               /*
+                * This first time we expand the mapping we need to account for
+                * the initial heap mapping not necessarily being huge page
+                * aligned
+                */
+               if (!mapsize)
+                       delta = hugetlbfs_next_addr((long)heapbase + delta) -
+                                       (unsigned long)heapbase;
+
+               INFO("Adding %ld bytes to heap\n", delta);
+
+               p = sbrk(delta);
+               if (p == (void *)-1) {
+                       WARNING("sbrk returned ENOMEM\n");
+                       return NULL;
+               }
+
+               if (!mapsize) {
+                       if (heapbase && (heapbase != p)) {
+                               WARNING("Heap was expected at %p instead of %p, 
"
+                                       "heap has been modified by someone 
else!\n",
+                                       heapbase, p);
+                               if (__hugetlbfs_debug)
+                                       dump_proc_pid_maps();
+                       }
+                       heapbase = heaptop = p;
+               }
+
+               mapsize += delta;
+#ifdef MADV_HUGEPAGE
+               madvise(p, delta, MADV_HUGEPAGE);
+#endif
+       } else if (delta < 0) {
+               /* shrinking the heap */
+               if (!mapsize) {
+                       WARNING("Can't shrink an empty heap\n");
+                       return NULL;
+               }
+
+               INFO("Attempting to shrink heap by %ld bytes with sbrk\n",
+                       -delta);
+               p = sbrk(delta);
+               if (p == (void *)-1) {
+                       WARNING("Unable to shrink heap\n");
+                       return heaptop;
+               }
+
+               mapsize += delta;
+       }
+
+       p = heaptop;
+       heaptop += increment;
+       INFO("... = %p\n", p);
+       return p;
+}
+
 void hugetlbfs_setup_morecore(void)
 {
        char *ep;
@@ -222,6 +289,8 @@
         */
        if (strncasecmp(__hugetlb_opts.morecore, "y", 1) == 0)
                hpage_size = gethugepagesize();
+       else if (__hugetlb_opts.thp_morecore)
+               hpage_size = kernel_default_hugepage_size();
        else
                hpage_size = parse_page_size(__hugetlb_opts.morecore);
 
@@ -237,8 +306,12 @@
                return;
        }
 
-       if(__hugetlb_opts.map_hugetlb &&
-                       hpage_size == kernel_default_hugepage_size()) {
+       /*
+        * We won't need an fd for the heap mmaps if we are using MAP_HUGETLB
+        * or we are depending on transparent huge pages
+        */
+       if(__hugetlb_opts.thp_morecore || (__hugetlb_opts.map_hugetlb &&
+                       hpage_size == kernel_default_hugepage_size())) {
                heap_fd = -1;
        } else {
                if (!hugetlbfs_find_path_for_size(hpage_size)) {
@@ -253,7 +326,12 @@
                }
        }
 
-       if (__hugetlb_opts.heapbase) {
+       /*
+        * THP morecore uses sbrk to allocate more heap space, counting on the
+        * kernel to back the area with THP.  So setting heapbase is
+        * meaningless if thp_morecore is used.
+        */
+       if (!__hugetlb_opts.thp_morecore && __hugetlb_opts.heapbase) {
                heapaddr = strtoul(__hugetlb_opts.heapbase, &ep, 16);
                if (*ep != '\0') {
                        WARNING("Can't parse HUGETLB_MORECORE_HEAPBASE: %s\n",
@@ -262,13 +340,17 @@
                }
        } else {
                heapaddr = (unsigned long)sbrk(0);
-               heapaddr = hugetlbfs_next_addr(heapaddr);
+               if (!__hugetlb_opts.thp_morecore)
+                       heapaddr = hugetlbfs_next_addr(heapaddr);
        }
 
        INFO("setup_morecore(): heapaddr = 0x%lx\n", heapaddr);
 
        heaptop = heapbase = (void *)heapaddr;
-       __morecore = &hugetlbfs_morecore;
+       if (__hugetlb_opts.thp_morecore)
+               __morecore = &thp_morecore;
+       else
+               __morecore = &hugetlbfs_morecore;
 
        /* Set some allocator options more appropriate for hugepages */
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/tests/shm-perms.c 
new/libhugetlbfs-2.13/tests/shm-perms.c
--- old/libhugetlbfs-2.12/tests/shm-perms.c     2011-04-01 22:39:44.000000000 
+0200
+++ new/libhugetlbfs-2.13/tests/shm-perms.c     2012-03-05 14:20:12.000000000 
+0100
@@ -34,11 +34,10 @@
 
 #define SEGMENT_SIZE   ((size_t)0x4000000)
 #define SEGMENT_KEY    0x82ba15ff
-#define SEGMENT_ADDR   ((void *)0x80000000)
-
 #define STRIDE         0x200000
 
 static int global_shmid = -1;
+void *shm_addr = NULL;
 
 void cleanup(void)
 {
@@ -53,12 +52,14 @@
        shmid = shmget(SEGMENT_KEY, segsize, shmflags);
        if (shmid == -1) {
                perror("shmget(SEGMENT)");
+               cleanup();
                exit(EXIT_FAILURE);
        }
 
        /* Attach large segment */
-       if (shmat(shmid, SEGMENT_ADDR, shmperms) == (void *)-1) {
+       if ( (shm_addr = shmat(shmid, shm_addr, shmperms)) == (void *)-1) {
                perror("shmat(SEGMENT)");
+               cleanup();
                exit(EXIT_FAILURE);
        }
 
@@ -90,12 +91,12 @@
 
        /* Create, attach and part init segment */
        attach_segment(SEGMENT_SIZE, IPC_CREAT|SHM_HUGETLB|0640, 0);
-       p = (char *)SEGMENT_ADDR;
+       p = (char *)shm_addr;
        for (i = 0; i < 4; i++, p += STRIDE)
                memset(p, 0x55, STRIDE);
 
        /* Detach segment */
-       if (shmdt(SEGMENT_ADDR) != 0)
+       if (shmdt(shm_addr) != 0)
                FAIL("shmdt(SEGMENT)");
 
        /* Create children to reattach read-only */
@@ -109,7 +110,7 @@
                        wait_list[i] = pid;
                } else {
                        attach_segment(0, 0, SHM_RDONLY);
-                       if (shmdt(SEGMENT_ADDR) != 0) {
+                       if (shmdt(shm_addr) != 0) {
                                perror("shmdt(SEGMENT)");
                                exit(EXIT_FAILURE);
                        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libhugetlbfs-2.12/version 
new/libhugetlbfs-2.13/version
--- old/libhugetlbfs-2.12/version       2011-04-01 22:44:09.000000000 +0200
+++ new/libhugetlbfs-2.13/version       2012-03-05 14:24:38.000000000 +0100
@@ -1 +1 @@
-2.12
+2.13

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to