aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric B Munson <emunson@mgebm.net>2010-11-23 08:52:11 -0700
committerEric B Munson <emunson@mgebm.net>2010-11-29 13:40:44 -0700
commitb046b0bc9a5a170b0f43972e9846f46c1bfd7aaa (patch)
tree81f41f7e4267f1af83937ab31b1bd325abd5ccc2
parentcbf4fab8f7da298b53977009d8330216f76df66e (diff)
downloadlibhugetlbfs-b046b0bc9a5a170b0f43972e9846f46c1bfd7aaa.tar.gz
Separate finding page sizes from mount points
Now that we have the ability to map huge pages without having an active hugetlfs mount point with MAP_HUGETLB it no longer makes sense to detect valid page sizes based on active mount points. This patch separates out the detection of valid page sizes from the detection of active mount points. Signed-off-by: Eric B Munson <emunson@mgebm.net> Acked-by: Mel Gorman <mel@csn.ul.ie>
-rw-r--r--hugeutils.c23
-rw-r--r--init.c4
-rw-r--r--libhugetlbfs_internal.h6
3 files changed, 27 insertions, 6 deletions
diff --git a/hugeutils.c b/hugeutils.c
index 646dea1..4e26dd5 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -311,6 +311,21 @@ void hugetlbfs_setup_env()
__hugetlb_opts.no_reserve = 1;
}
+void hugetlbfs_setup_kernel_page_size()
+{
+ long page_size = kernel_default_hugepage_size();
+
+ if (page_size <= 0) {
+ WARNING("Unable to find default kernel huge page size\n");
+ return;
+ }
+
+ INFO("Found pagesize %ld kB\n", page_size / 1024);
+ hpage_sizes[0].pagesize = page_size;
+
+ nr_hpage_sizes = 1;
+}
+
void hugetlbfs_check_priv_resv()
{
/*
@@ -420,7 +435,7 @@ static int hpage_size_to_index(unsigned long size)
return -1;
}
-static void probe_default_hpage_size(void)
+void probe_default_hpage_size(void)
{
long size;
int index;
@@ -510,7 +525,7 @@ static void add_hugetlbfs_mount(char *path, int user_mount)
strcpy(hpage_sizes[idx].mount, path);
}
-static void debug_show_page_sizes(void)
+void debug_show_page_sizes(void)
{
int i;
@@ -600,10 +615,6 @@ void setup_mounts(void)
/* Then probe all mounted filesystems */
if (do_scan)
find_mounts();
-
- probe_default_hpage_size();
- if (__hugetlbfs_debug)
- debug_show_page_sizes();
}
int get_pool_size(long size, struct hpage_pool *pool)
diff --git a/init.c b/init.c
index c7f5a05..b912448 100644
--- a/init.c
+++ b/init.c
@@ -23,7 +23,11 @@ static void __attribute__ ((constructor)) setup_libhugetlbfs(void)
{
hugetlbfs_setup_env();
hugetlbfs_setup_debug();
+ hugetlbfs_setup_kernel_page_size();
setup_mounts();
+ probe_default_hpage_size();
+ if (__hugetlbfs_debug)
+ debug_show_page_sizes();
setup_features();
hugetlbfs_check_priv_resv();
hugetlbfs_check_safe_noreserve();
diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
index 78db329..5b147f7 100644
--- a/libhugetlbfs_internal.h
+++ b/libhugetlbfs_internal.h
@@ -113,6 +113,12 @@ extern char __hugetlbfs_hostname[];
extern int hugetlbfs_prefault(int fd, void *addr, size_t length);
#define parse_page_size __lh_parse_page_size
extern long parse_page_size(const char *str);
+#define probe_default_hpage_size __lh__probe_default_hpage_size
+extern void probe_default_hpage_size(void);
+#define debug_show_page_sizes __lh__debug_show_page_sizes
+extern void debug_show_page_sizes(void);
+#define hugetlbfs_setup_kernel_page_size __lh__hugetlbfs_setup_kernel_page_size
+extern void hugetlbfs_setup_kernel_page_size(void);
#define __hugetlb_opts __lh__hugetlb_opts
extern struct libhugeopts_t __hugetlb_opts;