aboutsummaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorMel Gorman <mel@csn.ul.ie>2008-11-10 11:55:31 +0000
committerEric B Munson <ebmunson@us.ibm.com>2008-11-10 15:10:36 +0000
commitb656d0829e4e6a8f6a8b7ecd326f6da9881955db (patch)
treec3c81ee90d76390554670fe0db3cf638b5517f40 /alloc.c
parent67b846675adbde3d889647a4c6b840da4d0d345e (diff)
downloadlibhugetlbfs-b656d0829e4e6a8f6a8b7ecd326f6da9881955db.tar.gz
Force get_huge_pages() to only deal with hugepages
It has been asserted that the name get_huge_pages() implies the API is a close-to-kernel interface for allocating hugepages and nothing else. In 2.1-preX, this definition does not fit as it allows fallback to base pages for example. This patch enforces the meaning implied by the function name by removing the ability of the function to fallback to base pages and redefines GHP_DEFAULT to mean "Use the default hugepage size to back the region". Signed-off-by: Mel Gorman <mel@csn.ul.ie> Acked-by: Adam Litke <agl@us.ibm.com> Acked-by: Eric B Munson <ebmunson@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/alloc.c b/alloc.c
index c118f18..e12fd52 100644
--- a/alloc.c
+++ b/alloc.c
@@ -65,15 +65,13 @@ static void *fallback_base_pages(size_t len, ghp_t flags)
/**
* get_huge_pages - Allocate an amount of memory backed by huge pages
- * len: Size of the region to allocate
+ * len: Size of the region to allocate, must be hugepage-aligned
* flags: Flags specifying the behaviour of the function
*
- * This function allocates a region of memory backed by huge pages and
- * at least hugepage-aligned. This is not a suitable drop-in for malloc()
- * and is only suitable in the event the length is expected to be
- * hugepage-aligned. However, a malloc-like library could use this function
- * to create additional heap similar in principal to what morecore does for
- * glibc malloc.
+ * This function allocates a region of memory that is backed by huge pages
+ * and hugepage-aligned. This is not a suitable drop-in for malloc() but a
+ * a malloc library could use this function to create a new fixed-size heap
+ * similar in principal to what morecore does for glibc malloc.
*/
void *get_huge_pages(size_t len, ghp_t flags)
{
@@ -93,10 +91,6 @@ void *get_huge_pages(size_t len, ghp_t flags)
if (buf == MAP_FAILED) {
close(heap_fd);
- /* Try falling back to base pages if allowed */
- if (flags & GHP_FALLBACK)
- return fallback_base_pages(len, flags);
-
WARNING("get_huge_pages: New region mapping failed (flags: 0x%lX): %s\n",
flags, strerror(errno));
return NULL;
@@ -107,9 +101,9 @@ void *get_huge_pages(size_t len, ghp_t flags)
munmap(buf, len);
close(heap_fd);
- /* Try falling back to base pages if allowed */
- if (flags & GHP_FALLBACK)
- return fallback_base_pages(len, flags);
+ WARNING("get_huge_pages: Prefaulting failed (flags: 0x%lX): %s\n",
+ flags, strerror(errno));
+ return NULL;
}
/* Close the file so we do not have to track the descriptor */