On Thu, 2006-10-12 at 09:26 -0500, Steve Fox wrote:

> Instead of creating the shared mapping of size memsz (aligned), we're
> going to make it only filesz + non-zero BSS (we've found that glibc
> initializes stdin, stdout, stderr before we get control). Reducing the
> size of the shared mapping should result in less reserved hugepages.

elflink: Reduce the shared mapping to filesz + non-zero BSS. This should
decrease the number of huge pages we reserve.

---
This patch is an RFC. We need to test thoroughly before committing.

diff --git a/elflink.c b/elflink.c
index f659607..231ac94 100644
--- a/elflink.c
+++ b/elflink.c
@@ -416,7 +416,15 @@ static int prepare_segment(struct seg_in
        int hpage_size = gethugepagesize();
        void *p, *extra_start, *extra_end;
        unsigned long gap;
-       unsigned long size = ALIGN(seg->memsz, hpage_size);
+       unsigned long size;
+
+       /*
+        * Calculate the BSS size that we must copy in order to minimize
+        * the size of the shared mapping.
+        */
+       get_extracopy(seg, &extra_start, &extra_end);
+       size = ALIGN((unsigned long)extra_end - (unsigned long)seg->vaddr,
+                               hpage_size);
 
        /* Prepare the hugetlbfs file */
 
@@ -439,7 +447,6 @@ static int prepare_segment(struct seg_in
        memcpy(p, seg->vaddr, seg->filesz);
        DEBUG_CONT("done\n");
 
-       get_extracopy(seg, &extra_start, &extra_end);
        if (extra_end > extra_start) {
                DEBUG("Copying extra %#0lx bytes from %p...\n", 
                        (unsigned long)(extra_end - extra_start), extra_start);

-- 

Steve Fox
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

Reply via email to