commit 122c260924a811b57e6c686004964d4b020ed29d
Author: Nishanth Aravamudan <[EMAIL PROTECTED]>
Date:   Fri Feb 2 13:13:48 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. This
    method uses the start address and size to represent the extracopy area.
    
    Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>

---

Between this and the following patch, which is preferred?

diff --git a/elflink.c b/elflink.c
index 5a57358..cedd49b 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;
@@ -497,8 +497,7 @@ static inline int keep_symbol(Elf_Sym *s, void *start, void 
*end)
  * include these initialized variables in our copy.
  */
 
-static void get_extracopy(struct seg_info *seg, void **extra_start,
-                                                       void **extra_end)
+static void get_extracopy(struct seg_info *seg)
 {
        Elf_Dyn *dyntab;        /* dynamic segment table */
        Elf_Sym *symtab = NULL; /* dynamic symbol table */
@@ -511,7 +510,7 @@ static void get_extracopy(struct seg_info *seg, void 
**extra_start,
        end_orig = seg->vaddr + seg->memsz;
        start_orig = seg->vaddr + seg->filesz;
        if (seg->filesz == seg->memsz)
-               goto bail2;
+               return;
        if (!minimal_copy)
                goto bail2;
 
@@ -557,21 +556,20 @@ static void get_extracopy(struct seg_info *seg, void 
**extra_start,
 
        if (found_sym) {
                /* Return the copy window */
-               *extra_start = start;
-               *extra_end = end;
-               return;
-       } else {
-               /* No need to copy anything */
-               *extra_start = start_orig;
-               *extra_end = start_orig;
-               goto bail3;
+               seg->extra_vaddr = start;
+               seg->extrasz = end - start;
        }
+       /*
+        * else no need to copy anything, so leave seg->extra_vaddr as
+        * NULL
+        */
+       return;
 
 bail:
        DEBUG("Unable to perform minimal copy\n");
 bail2:
-       *extra_start = start_orig;
-       *extra_end = end_orig;
+       seg->extra_start = start_orig;
+       seg->extrasz = end_orig - start_orig;
 bail3:
        return;
 }
@@ -584,7 +582,7 @@ bail3:
 static int prepare_segment(struct seg_info *seg)
 {
        int hpage_size = gethugepagesize();
-       void *p, *extra_start, *extra_end;
+       void *p;
        unsigned long gap;
        unsigned long size;
 
@@ -592,9 +590,10 @@ static int prepare_segment(struct seg_info *seg)
         * 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);
+       get_extracopy(seg);
+       size = ALIGN((unsigned long)seg->extra_vaddr +
+                       seg->extrasz - (unsigned long)seg->vaddr,
+                       hpage_size);
 
        /* Prepare the hugetlbfs file */
 
@@ -617,11 +616,12 @@ static int prepare_segment(struct seg_info *seg)
        memcpy(p, seg->vaddr, seg->filesz);
        DEBUG_CONT("done\n");
 
-       if (extra_end > extra_start) {
+       if (seg->extra_vaddr) {
                DEBUG("Copying extra %#0lx bytes from %p...",
-                       (unsigned long)(extra_end - extra_start), extra_start);
-               gap = extra_start - (seg->vaddr + seg->filesz);
-               memcpy((p + seg->filesz + gap), extra_start, (extra_end - 
extra_start));
+                                       seg->extrasz, seg->extra_vaddr);
+               gap = seg->extra_vaddr - (seg->vaddr + seg->filesz);
+               memcpy((p + seg->filesz + gap), seg->extra_vaddr,
+                                                       seg->extrasz);
                DEBUG_CONT("done\n");
        }
 

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