This patch adds controls for the new THP related functionality in the library.

Signed-off-by: Eric B Munson <emun...@mgebm.net>
---
 hugectl.c     |   17 ++++++++++++++++-
 man/hugectl.8 |   11 +++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/hugectl.c b/hugectl.c
index e2a9828..741247f 100644
--- a/hugectl.c
+++ b/hugectl.c
@@ -67,6 +67,10 @@ void print_usage()
        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 @@ void verbose_expose(void)
 #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 main(int argc, char** argv)
        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 @@ int main(int argc, char** argv)
                {"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 @@ int main(int argc, char** argv)
                        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 @@ int main(int argc, char** argv)
        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 --git a/man/hugectl.8 b/man/hugectl.8
index 319742e..11de2aa 100644
--- a/man/hugectl.8
+++ b/man/hugectl.8
@@ -63,6 +63,17 @@ Request that multiple application instances share text 
segments that are
 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
+
+.TP
+.B --thp-madvise
+Call madvise(MADV_HUGEPAGE) on new heap regions as they are allocated.  This
+marks the area to be considered by khugepaged when it is only promoting 
madvised
+areas.  This option must be used with --thp
+
 .PP
 The following options affect how \fBhugectl\fP behaves.
 
-- 
1.7.4.1


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to