I found the dearth of comments in morecore.c to be quite troublesome while debugging a related kernel bug. I hope these are accurate.
Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]> diff -urpN a/morecore.c b/morecore.c --- a/morecore.c 2006-09-06 11:34:18.000000000 -0700 +++ b/morecore.c 2006-09-06 11:58:48.000000000 -0700 @@ -92,16 +92,26 @@ static void *hugetlbfs_morecore(ptrdiff_ DEBUG("hugetlbfs_morecore(%ld) = ...\n", (long)increment); + /* + * how much to grow the heap by = + * (size of heap) + malloc request - mmap'd space + */ newsize = (heaptop-heapbase) + increment - mapsize; DEBUG("heapbase = %p, heaptop = %p, mapsize = %lx, newsize=%ld\n", heapbase, heaptop, mapsize, newsize); + /* growing the heap */ if (newsize > 0) { + /* + * convert our request to a multiple of hugepages + * we will have more space allocated then used, basically + */ newsize = ALIGN(newsize, blocksize); DEBUG("Attempting to map %ld bytes\n", newsize); + /* map in (extend) more of the file at the end of our last map */ p = mmap(heapbase + mapsize, newsize, PROT_READ|PROT_WRITE, MAP_PRIVATE, heap_fd, mapsize); if (p == MAP_FAILED) { @@ -109,10 +119,12 @@ static void *hugetlbfs_morecore(ptrdiff_ return NULL; } + /* if this is the first map */ if (! mapsize) { if (heapbase && (heapbase != p)) WARNING("Heap originates at %p instead of %p\n", p, heapbase); + /* then setup the heap variables */ heapbase = heaptop = p; } else if (p != (heapbase + mapsize)) { /* Couldn't get the mapping where we wanted */ @@ -130,10 +142,13 @@ static void *hugetlbfs_morecore(ptrdiff_ return NULL; } + /* we now have mmap'd further */ mapsize += newsize; } + /* heap is continuous */ p = heaptop; + /* and we now have added this much more space to the heap */ heaptop = heaptop + increment; DEBUG("... = %p\n", p); -- Nishanth Aravamudan <[EMAIL PROTECTED]> IBM Linux Technology Center ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel