Eric,
Eric B Munson wrote:
> 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..6bab543 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 && hpage_size == gethugepagesize()) {
As best I can tell, gethugepagesize() will return the value from the
HUGETLB_DEFAULT_PAGE_SIZE environment variable if it is set. This could be
different than the kernel default hugepage size. You probably need
kernel_default_hugepage_size() here.
> + 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) {
-Andrew Hastings
Cray Inc.
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel