On 01.02.2007 [18:20:22 -0800], Nishanth Aravamudan wrote:
> On 01.02.2007 [09:43:01 -0600], Adam Litke wrote:
> > On Wed, 2007-01-31 at 20:45 -0800, Nishanth Aravamudan wrote:
<snip>
> > > + for (i = 0; i < num; i++) {
> > > +         if (seg[i].prot & PROT_WRITE) {
> > > +                 for (p = seg[i].vaddr;
> > > +                      p <= seg[i].vaddr + seg[i].filesz;
> > I just realized the above should be (vaddr + filesz + extracopysize).
> > Otherwise we will throw away the initialized bss data that we've been so
> > careful to collect earlier.
> 
> This does complicate things quite a bit, unfortunately, we currently
> throw away the extracopy information once we've done it. I've modified
> the code a bit to save this info, and I think I've got it right, but I'd
> appreciate you and Steve taking a look at the following two patches,
> which should allow for what you want.

commit 19d3d34954944e84d009cd3282c0abf45a69bdea
Author: Nishanth Aravamudan <[EMAIL PROTECTED]>
Date:   Thu Feb 1 17:51:47 2007 -0800

    elflink: store extracopy information
    
    Add a few fields to the seg_info structure to store the starting address
    and size of the extracopy area for use by the next patch to drop
    pagecache pages. If the extra_vaddr field is NULL, then the pagecache
    dropping code assumes this means there was no extracopy area.
    
    Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>

---

Note: Does extra_vaddr need to be explicitly set to NULL in a
(to-be-added) else or will it be NULL by default (my assumption)?

diff --git a/elflink.c b/elflink.c
index 5a57358..a8d5d4a 100644
--- a/elflink.c
+++ b/elflink.c
@@ -186,8 +186,8 @@ static char share_path[PATH_MAX+1];
 #define MAX_HTLB_SEGS  2
 
 struct seg_info {
-       void *vaddr;
-       unsigned long filesz, memsz;
+       void *vaddr, *extra_vaddr;
+       unsigned long filesz, memsz, extrasz;
        int prot;
        int fd;
        int phdr;
@@ -586,7 +586,7 @@ static int prepare_segment(struct seg_info *seg)
        int hpage_size = gethugepagesize();
        void *p, *extra_start, *extra_end;
        unsigned long gap;
-       unsigned long size;
+       unsigned long size, extra_size;
 
        /*
         * Calculate the BSS size that we must copy in order to minimize
@@ -618,11 +618,14 @@ static int prepare_segment(struct seg_info *seg)
        DEBUG_CONT("done\n");
 
        if (extra_end > extra_start) {
+               extra_size = (unsigned long)(extra_end - extra_start);
                DEBUG("Copying extra %#0lx bytes from %p...",
-                       (unsigned long)(extra_end - extra_start), extra_start);
+                                               extra_size, extra_start);
                gap = extra_start - (seg->vaddr + seg->filesz);
-               memcpy((p + seg->filesz + gap), extra_start, (extra_end - 
extra_start));
+               memcpy((p + seg->filesz + gap), extra_start, extra_size);
                DEBUG_CONT("done\n");
+               seg->extra_vaddr = extra_start;
+               seg->extrasz = extra_size;
        }
 
        munmap(p, size);

-- 
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to