aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <emunson@mgebm.net>2010-11-23 08:52:10 -0700
committerEric B Munson <emunson@mgebm.net>2010-11-29 13:40:25 -0700
commitcbf4fab8f7da298b53977009d8330216f76df66e (patch)
tree49a953fb4c21a2f3d8e16128294705dcbb503c6b
parentcca95fbca95828a2d75128ae5bb47c85ff2c03e3 (diff)
downloadlibhugetlbfs-cbf4fab8f7da298b53977009d8330216f76df66e.tar.gz
Add check for MAP_HUGETLB support
This patch adds a check for MAP_HUGETLB support and a flag in __hugetlb_opts for holding the availability. Signed-off-by: Eric B Munson <emunson@mgebm.net> Acked-by: Mel Gorman <mel@csn.ul.ie>
-rw-r--r--hugeutils.c21
-rw-r--r--init.c1
-rw-r--r--libhugetlbfs_internal.h4
3 files changed, 26 insertions, 0 deletions
diff --git a/hugeutils.c b/hugeutils.c
index 3b442c3..646dea1 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -340,6 +340,27 @@ void hugetlbfs_check_safe_noreserve()
}
}
+void hugetlbfs_check_map_hugetlb()
+{
+/*
+ * FIXME: MAP_HUGETLB has not been picked up by glibc so even though the
+ * kernel may support it, without the userspace mmap flag it cannot be
+ * used. This ifdef should be removed when the MAP_HUGETLB flag makes it
+ * into glibc.
+ */
+#ifdef MAP_HUGETLB
+ /*
+ * Kernels after 2.6.32 support mmaping pseudo-anonymous regions
+ * backed by huge pages, use this feature for huge pages we
+ * don't intend to share.
+ */
+ if (hugetlbfs_test_feature(HUGETLB_FEATURE_MAP_HUGETLB) > 0) {
+ INFO("Kernel supports MAP_HUGETLB\n");
+ __hugetlb_opts.map_hugetlb = 1;
+ }
+#endif
+}
+
/*
* Pool counters are typically exposed in sysfs in modern kernels, the
* counters for the default page size are exposed in procfs in all kernels
diff --git a/init.c b/init.c
index 049c9e2..c7f5a05 100644
--- a/init.c
+++ b/init.c
@@ -27,6 +27,7 @@ static void __attribute__ ((constructor)) setup_libhugetlbfs(void)
setup_features();
hugetlbfs_check_priv_resv();
hugetlbfs_check_safe_noreserve();
+ hugetlbfs_check_map_hugetlb();
#ifndef NO_ELFLINK
hugetlbfs_setup_elflink();
#endif
diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
index 6e9379e..78db329 100644
--- a/libhugetlbfs_internal.h
+++ b/libhugetlbfs_internal.h
@@ -33,6 +33,7 @@
#include <elf.h>
#include <link.h>
#include <limits.h>
+#include <stdbool.h>
#ifndef __LIBHUGETLBFS__
#error This header should not be included by library users.
@@ -61,6 +62,7 @@ struct libhugeopts_t {
int shrink_ok;
int shm_enabled;
int no_reserve;
+ bool map_hugetlb;
unsigned long force_elfmap;
char *ld_preload;
char *elfmap;
@@ -103,6 +105,8 @@ extern void setup_features();
extern void hugetlbfs_check_priv_resv();
#define hugetlbfs_check_safe_noreserve __lh_hugetlbfs_check_safe_noreserve
extern void hugetlbfs_check_safe_noreserve();
+#define hugetlbfs_check_map_hugetlb __lh_hugetblfs_check_map_hugetlb
+extern void hugetlbfs_check_map_hugetlb();
#define __hugetlbfs_hostname __lh___hugetlbfs_hostname
extern char __hugetlbfs_hostname[];
#define hugetlbfs_prefault __lh_hugetlbfs_prefault