(Note: Final pre-1.1 patch in my queue)

We currently run into problems with the libhugetlbfs malloc
implementation if hugepages are available when we mmap, but not
available when we touch them. The application is killed, even though
there were sufficient hugepages at some point in its lifetime. We have
code which uses mlock() to bring in all the hugepages in our heap, but
it was commented-out because of bad NUMA performance (all hugepages
would be allocated node-local). Bring back that code, as the kernel-side
issues with NUMA and hugepages have been resolved (interleave works
again), and add a comment indicating NUMA users should use numactl to
specify the hugepage allocation policy.

Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>

diff --git a/morecore.c b/morecore.c
index 5fdcb24..6bcc6e1 100644
--- a/morecore.c
+++ b/morecore.c
@@ -52,6 +52,7 @@ static long mapsize;
 
 static void *hugetlbfs_morecore(ptrdiff_t increment)
 {
+       int ret;
        void *p;
        long newsize = 0;
 
@@ -99,11 +100,12 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
                        return NULL;
                }
 
-#if 0
-/* Use of mlock is disabled because it results in bad numa behavior since
- * the malloc'd memory is allocated node-local to the cpu calling morecore()
- * and not to the cpu(s) that are actually using the memory.
- */
+               /* Use of mlock was reintroduced in libhugetlbfs 1.1,
+                * as the NUMA issues have been fixed in-kernel. The
+                * NUMA users of libhugetlbfs' malloc feature are
+                * expected to use the numactl program to specify an
+                * appropriate policy for hugepage allocation */
+
                /* Use mlock to guarantee these pages to the process */
                ret = mlock(p, newsize);
                if (ret) {
@@ -112,7 +114,6 @@ static void *hugetlbfs_morecore(ptrdiff_t increment)
                        return NULL;
                }
                munlock(p, newsize);
-#endif
 
                /* we now have mmap'd further */
                mapsize += newsize;

-- 
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to