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.
This is because backing text/data assumed that linking with libhugetlbfs is required. If an application is already linked, then the library cannot also be preloaded. In the case of PPC64, this assumption is not true 100% of the time but hugectl has no way of automatically detecting that case. Signed-off-by: Eric B Munson <ebmun...@us.ibm.com> Acked-by: Mel Gorman <m...@csn.ul.ie> --- Changes from V1: Updated changelog and man page with explanation of why, not just what hugectl.c | 26 +++++++++++++++++++------- man/hugectl.8 | 8 ++++++++ 2 files changed, 27 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..bbaeb87 100644 --- a/man/hugectl.8 +++ b/man/hugectl.8 @@ -74,6 +74,14 @@ 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 option is used when +the segments of the binary are aligned to the hugepage boundary of interest +but the binary is not linked against libhugetlbfs. This is useful on PPC64 +where binaries are aligned to 64K as required by the ABI and the kernel is +using a 4K base pagesize. + +.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 Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel