aboutsummaryrefslogtreecommitdiff
path: root/morecore.c
diff options
context:
space:
mode:
authoraglitke <aglitke@aglitke.localdomain>2006-03-30 17:35:28 -0600
committeraglitke <aglitke@aglitke.localdomain>2006-03-30 17:35:28 -0600
commit3da5975d7e12aebd8d7614f48d8c0d68c6a03146 (patch)
treeca675d573bb9c6723bcbfb336aa63637f9125e57 /morecore.c
parentff2f5343e4a4e2d2e62173d557a7e5952cfa7733 (diff)
downloadlibhugetlbfs-3da5975d7e12aebd8d7614f48d8c0d68c6a03146.tar.gz
Use mlock to reserve newly allocated hugepages in hugetlb_morecore.
Since MAP_PRIVATE allocations are full overcommit, the mmap call can succeed even if there aren't enough huge pages to satisfy the mapping. Thus fallback to normal pages is not currently possible. Use mlock to instantiate the newly allocated area and if that fails, release it and initiate fallback to normal pages.
Diffstat (limited to 'morecore.c')
-rw-r--r--morecore.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/morecore.c b/morecore.c
index 8bb666f..ca4c71d 100644
--- a/morecore.c
+++ b/morecore.c
@@ -53,6 +53,7 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
{
void *p;
long newsize = 0;
+ int ret;
DEBUG("hugetlbfs_morecore(%ld) = ...\n", (long)increment);
@@ -86,6 +87,15 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
return NULL;
}
+ /* Use mlock to guarantee these pages to the process */
+ ret = mlock(p, newsize);
+ if (ret) {
+ WARNING("Failed to reserve huge pages in hugetlbfs_morecore()\n");
+ munmap(p, newsize);
+ return NULL;
+ }
+ munlock(p, newsize);
+
mapsize += newsize;
}