]> Zhao Yanbai Git Server - minix.git/commitdiff
vm: report cropped region sizes
authorBen Gras <ben@minix3.org>
Sat, 26 Nov 2011 15:12:17 +0000 (15:12 +0000)
committerBen Gras <ben@minix3.org>
Sat, 26 Nov 2011 15:12:17 +0000 (15:12 +0000)
. when reporting on regions, only report part of the
  region (addr and length) that really has memory mapped
  into it
. to minimise core files

servers/vm/region.c

index c44062f85feb8181245df4fea7c873742910c818..2d63e1954117365cc3f85ea6b7634d5b3a50db68 100644 (file)
@@ -1991,9 +1991,19 @@ PUBLIC int get_region_info(struct vmproc *vmp, struct vm_region_info *vri,
        if(!(vr = region_get_iter(&v_iter))) return 0;
 
        for(count = 0; (vr = region_get_iter(&v_iter)) && count < max; count++, vri++) {
-               vri->vri_addr = arch_map2info(vmp, vr->vaddr, &vri->vri_seg,
-                       &vri->vri_prot);
-               vri->vri_length = vr->length;
+               struct phys_region *ph1, *ph2;
+
+               /* Report part of the region that's actually in use. */
+
+               /* Get first and last phys_regions, if any */
+               ph1 = physr_search_least(vr->phys);
+               ph2 = physr_search_greatest(vr->phys);
+               if(!ph1 || !ph2) { assert(!ph1 && !ph2); continue; }
+
+               /* Report start+length of region starting from lowest use. */
+               vri->vri_addr = arch_map2info(vmp, vr->vaddr + ph1->offset,
+                       &vri->vri_seg, &vri->vri_prot);
+               vri->vri_length = ph2->offset + ph2->ph->length - ph1->offset;
 
                /* "AND" the provided protection with per-page protection. */
                if (!(vr->flags & VR_WRITABLE))