Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm reduce the size of user coredump files by not dumpin...



details:   https://anonhg.NetBSD.org/src/rev/865934f92ac7
branches:  trunk
changeset: 573165:865934f92ac7
user:      chs <chs%NetBSD.org@localhost>
date:      Fri Jan 21 03:24:40 2005 +0000

description:
reduce the size of user coredump files by not dumping regions of
the address space that have never been touched (such as much of the
virtual space allocated for pthread stacks).

diffstat:

 sys/uvm/uvm_glue.c |  54 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 26 deletions(-)

diffs (95 lines):

diff -r 3d31ac1214df -r 865934f92ac7 sys/uvm/uvm_glue.c
--- a/sys/uvm/uvm_glue.c        Fri Jan 21 03:22:13 2005 +0000
+++ b/sys/uvm/uvm_glue.c        Fri Jan 21 03:24:40 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_glue.c,v 1.81 2004/05/12 20:09:51 yamt Exp $       */
+/*     $NetBSD: uvm_glue.c,v 1.82 2005/01/21 03:24:40 chs Exp $        */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.81 2004/05/12 20:09:51 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.82 2005/01/21 03:24:40 chs Exp $");
 
 #include "opt_kgdb.h"
 #include "opt_kstack.h"
@@ -717,11 +717,8 @@
        struct vmspace *vm = p->p_vmspace;
        struct vm_map *map = &vm->vm_map;
        struct vm_map_entry *entry;
-       vaddr_t maxstack;
        int error;
 
-       maxstack = trunc_page(USRSTACK - ctob(vm->vm_ssize));
-
        entry = NULL;
        vm_map_lock_read(map);
        for (;;) {
@@ -732,38 +729,43 @@
                if (entry == &map->header)
                        break;
 
-               /* Should never happen for a user process. */
-               if (UVM_ET_ISSUBMAP(entry))
-                       panic("uvm_coredump_walkmap: user process with "
-                           "submap?");
-
                state.cookie = cookie;
                state.start = entry->start;
                state.end = entry->end;
                state.prot = entry->protection;
                state.flags = 0;
 
-               if (state.start >= VM_MAXUSER_ADDRESS)
-                       continue;
-
-               if (state.end > VM_MAXUSER_ADDRESS)
-                       state.end = VM_MAXUSER_ADDRESS;
+               /*
+                * Dump the region unless one of the following is true:
+                *
+                * (1) the region has neither object nor amap behind it
+                *     (ie. it has never been accessed).
+                *
+                * (2) the region has no amap and is read-only
+                *     (eg. an executable text section).
+                *
+                * (3) the region's object is a device.
+                */
 
+               KASSERT(!UVM_ET_ISSUBMAP(entry));
+               KASSERT(state.start < VM_MAXUSER_ADDRESS);
+               KASSERT(state.end <= VM_MAXUSER_ADDRESS);
+               if (entry->object.uvm_obj == NULL &&
+                   entry->aref.ar_amap == NULL) {
+                       state.flags |= UVM_COREDUMP_NODUMP;
+               }
+               if ((entry->protection & VM_PROT_WRITE) == 0 &&
+                   entry->aref.ar_amap == NULL) {
+                       state.flags |= UVM_COREDUMP_NODUMP;
+               }
+               if (entry->object.uvm_obj != NULL &&
+                   UVM_OBJ_IS_DEVICE(entry->object.uvm_obj)) {
+                       state.flags |= UVM_COREDUMP_NODUMP;
+               }
                if (state.start >= (vaddr_t)vm->vm_maxsaddr) {
-                       if (state.end <= maxstack)
-                               continue;
-                       if (state.start < maxstack)
-                               state.start = maxstack;
                        state.flags |= UVM_COREDUMP_STACK;
                }
 
-               if ((entry->protection & VM_PROT_WRITE) == 0)
-                       state.flags |= UVM_COREDUMP_NODUMP;
-
-               if (entry->object.uvm_obj != NULL &&
-                   UVM_OBJ_IS_DEVICE(entry->object.uvm_obj))
-                       state.flags |= UVM_COREDUMP_NODUMP;
-
                vm_map_unlock_read(map);
                error = (*func)(p, vp, cred, &state);
                if (error)



Home | Main Index | Thread Index | Old Index