aboutsummaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorMel Gorman <mel@csn.ul.ie>2008-08-18 19:02:25 +0100
committerEric B Munson <ebmunson@us.ibm.com>2008-08-19 13:36:05 -0700
commit8098bc41d27443605fed36b497ce4a43ea1ae521 (patch)
tree4d923bc83648a99cf489919d1955e3547645e771 /alloc.c
parentdda4d84914262fa698bd1242547d17d2b610329d (diff)
downloadlibhugetlbfs-8098bc41d27443605fed36b497ce4a43ea1ae521.tar.gz
Prefault regions allocated with get_huge_pages()
Similar to morecore, it is necessary to prefault regions allocated by get_huge_pagess() when requested. Signed-off-by: Mel Gorman <mel@csn.ul.ie> Acked-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/alloc.c b/alloc.c
index 596c3c1..197c1ce 100644
--- a/alloc.c
+++ b/alloc.c
@@ -102,6 +102,16 @@ void *get_huge_pages(size_t len, ghp_t flags)
return NULL;
}
+ /* Fault the region to ensure accesses succeed */
+ if (__lh_hugetlbfs_prefault(heap_fd, buf, len) != 0) {
+ munmap(buf, len);
+ close(heap_fd);
+
+ /* Try falling back to base pages if allowed */
+ if (flags & GHP_FALLBACK)
+ return fallback_base_pages(len, flags);
+ }
+
/* Close the file so we do not have to track the descriptor */
if (close(heap_fd) != 0) {
WARNING("Failed to close new heap fd: %s\n", strerror(errno));