As with get_huge_pages it is appropriate to use MAP_HUGETLB for
mappings that will hold the heap.

Signed-off-by: Eric B Munson <[email protected]>
---
 morecore.c |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/morecore.c b/morecore.c
index e120d55..4fd51c3 100644
--- a/morecore.c
+++ b/morecore.c
@@ -94,8 +94,13 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
                INFO("Attempting to map %ld bytes\n", delta);
 
                /* map in (extend) more of the file at the end of our last map 
*/
-               p = mmap(heapbase + mapsize, delta, PROT_READ|PROT_WRITE,
-                        MAP_PRIVATE|mmap_reserve, heap_fd, mapsize);
+               if (__hugetlb_opts.map_hugetlb)
+                       p = mmap(heapbase + mapsize, delta, 
PROT_READ|PROT_WRITE,
+                                
MAP_HUGETLB|MAP_ANONYMOUS|MAP_PRIVATE|mmap_reserve,
+                                heap_fd, mapsize);
+               else
+                       p = mmap(heapbase + mapsize, delta, 
PROT_READ|PROT_WRITE,
+                                MAP_PRIVATE|mmap_reserve, heap_fd, mapsize);
                if (p == MAP_FAILED) {
                        WARNING("New heap segment map at %p failed: %s\n",
                                heapbase+mapsize, strerror(errno));
@@ -166,7 +171,7 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
                if (ret) {
                        WARNING("Unmapping failed while shrinking heap: "
                                "%s\n", strerror(errno));
-               } else {
+               } else if (!__hugetlb_opts.map_hugetlb){
 
                        /*
                         * Now shrink the hugetlbfs file.
@@ -223,15 +228,21 @@ void hugetlbfs_setup_morecore(void)
                else
                        WARNING("Hugepage size (%s)\n", strerror(errno));
                return;
-       } else if (!hugetlbfs_find_path_for_size(hpage_size)) {
-               WARNING("Hugepage size %li unavailable", hpage_size);
-               return;
        }
 
-       heap_fd = hugetlbfs_unlinked_fd_for_size(hpage_size);
-       if (heap_fd < 0) {
-               WARNING("Couldn't open hugetlbfs file for morecore\n");
-               return;
+       if(__hugetlb_opts.map_hugetlb) {
+               heap_fd = -1;
+       } else {
+               if (!hugetlbfs_find_path_for_size(hpage_size)) {
+                       WARNING("Hugepage size %li unavailable", hpage_size);
+                       return;
+               }
+
+               heap_fd = hugetlbfs_unlinked_fd_for_size(hpage_size);
+               if (heap_fd < 0) {
+                       WARNING("Couldn't open hugetlbfs file for morecore\n");
+                       return;
+               }
        }
 
        if (__hugetlb_opts.heapbase) {
-- 
1.7.1


------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to