Binaries for ppc64 are already aligned properly for 64KB backed program
segments so it should be reasonable to use 64KB huge pages for these
segments without relinking, however this requires preloading libhugetlbfs.
Currently hugectl will not allow libhugetlbfs to be preloaded if huge page
backed segments are requested.  This patch introduces the --force-preload
switch that allows the user to bypass this check and preload libhugetlbfs
any time.

Signed-off-by: Eric B Munson <[email protected]>

---
 hugectl.c     |   26 +++++++++++++++++++-------
 man/hugectl.8 |    6 ++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/hugectl.c b/hugectl.c
index 21ccdc1..73fb0af 100644
--- a/hugectl.c
+++ b/hugectl.c
@@ -69,6 +69,7 @@ void print_usage()
        OPTION("--shm", "Requests remapping of shared memory segments");
 
        OPTION("--no-preload", "Disable preloading the libhugetlbfs library");
+       OPTION("--force-preload", "Force preloading the libhugetlbfs library");
 
        OPTION("--dry-run", "describe what would be done without doing it");
 
@@ -87,6 +88,7 @@ void print_usage()
 }
 
 int opt_dry_run = 0;
+int opt_force_preload = 0;
 int verbose_level = VERBOSITY_DEFAULT;
 
 void verbose_init(void)
@@ -148,13 +150,14 @@ void verbose_expose(void)
 #define MAP_BASE       0x1000
 #define LONG_BASE      0x2000
 
-#define LONG_NO_PRELOAD        (LONG_BASE | 'p')
+#define LONG_NO_PRELOAD                (LONG_BASE | 'p')
+#define LONG_FORCE_PRELOAD     (LONG_BASE | 'F')
 
-#define LONG_DRY_RUN   (LONG_BASE | 'd')
+#define LONG_DRY_RUN           (LONG_BASE | 'd')
 
-#define LONG_SHARE     (LONG_BASE | 's')
-#define LONG_NO_LIBRARY        (LONG_BASE | 'L')
-#define LONG_LIBRARY   (LONG_BASE | 'l')
+#define LONG_SHARE             (LONG_BASE | 's')
+#define LONG_NO_LIBRARY                (LONG_BASE | 'L')
+#define LONG_LIBRARY           (LONG_BASE | 'l')
 
 /*
  * Mapping selectors, one per remappable/backable area as requested
@@ -311,9 +314,10 @@ void ldpreload(int count)
        if (map_size[MAP_SHM])
                allowed++;
 
-       if (allowed == count) {
+       if ((allowed == count) || opt_force_preload) {
                setup_environment("LD_PRELOAD", "libhugetlbfs.so");
-               WARNING("LD_PRELOAD in use for lone --heap/--shm\n");
+               if (allowed == count)
+                       INFO("LD_PRELOAD in use for lone --heap/--shm\n");
        } else {
                WARNING("LD_PRELOAD not appropriate for this map 
combination\n");
        }
@@ -332,6 +336,8 @@ int main(int argc, char** argv)
                {"help",       no_argument, NULL, 'h'},
                {"verbose",    required_argument, NULL, 'v' },
                {"no-preload", no_argument, NULL, LONG_NO_PRELOAD},
+               {"force-preload",
+                              no_argument, NULL, LONG_FORCE_PRELOAD},
                {"dry-run",    no_argument, NULL, LONG_DRY_RUN},
                {"library-path",
                               required_argument, NULL, LONG_LIBRARY},
@@ -379,6 +385,12 @@ int main(int argc, char** argv)
                        INFO("LD_PRELOAD disabled\n");
                        break;
 
+               case LONG_FORCE_PRELOAD:
+                       opt_preload = 1;
+                       opt_force_preload = 1;
+                       INFO("Forcing ld preload\n");
+                       break;
+
                case LONG_DRY_RUN:
                        opt_dry_run = 1;
                        break;
diff --git a/man/hugectl.8 b/man/hugectl.8
index 6b43255..48b37e0 100644
--- a/man/hugectl.8
+++ b/man/hugectl.8
@@ -74,6 +74,12 @@ linked against the library. \fBhugectl\fP may pre-load the 
library by mistake
 and this option prevents that.
 
 .TP
+.B --force-preload
+Force pre-loading of the \fBlibhugetlbfs\fP library.  This may be necessary if
+huge page backed program segments have been requested but the target binary was
+not linked using the libhugetlbfs linker script.
+
+.TP
 .B --dry-run
 Instead of running the process, the \fBhugectl\fP utility will describe what
 environment variables it set for \fBlibhugetlbfs\fP. This is useful if
-- 
1.6.1.2


------------------------------------------------------------------------------
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to