Source-Changes-HG archive

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

[src/trunk]: src/sys There is no need for uvm_coredump_walkmap() to explicity...



details:   https://anonhg.NetBSD.org/src/rev/b21912862a5d
branches:  trunk
changeset: 325706:b21912862a5d
user:      dsl <dsl%NetBSD.org@localhost>
date:      Fri Jan 03 21:12:18 2014 +0000

description:
There is no need for uvm_coredump_walkmap() to explicity pass the proc_t
  pointer to the calller's function.
If the code needs the process its address can be placed in the caller's
  cookie.

diffstat:

 sys/kern/core_elf32.c  |  26 ++++++++++++++------------
 sys/kern/core_netbsd.c |  10 ++++------
 sys/uvm/uvm_coredump.c |  12 ++++++------
 sys/uvm/uvm_extern.h   |   7 +++----
 4 files changed, 27 insertions(+), 28 deletions(-)

diffs (189 lines):

diff -r 6b3bd3975c00 -r b21912862a5d sys/kern/core_elf32.c
--- a/sys/kern/core_elf32.c     Fri Jan 03 20:52:47 2014 +0000
+++ b/sys/kern/core_elf32.c     Fri Jan 03 21:12:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: core_elf32.c,v 1.39 2014/01/03 20:52:47 dsl Exp $      */
+/*     $NetBSD: core_elf32.c,v 1.40 2014/01/03 21:12:18 dsl Exp $      */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.39 2014/01/03 20:52:47 dsl Exp $");
+__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.40 2014/01/03 21:12:18 dsl Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
@@ -68,8 +68,9 @@
 
 struct writesegs_state {
        Elf_Phdr *psections;
-       off_t   secoff;
-       size_t  npsections;
+       proc_t   *p;
+       off_t    secoff;
+       size_t   npsections;
 };
 
 /*
@@ -88,8 +89,7 @@
        unsigned int     ns_offset;      /* Write point in last buffer */
 };
 
-static int     ELFNAMEEND(coredump_getseghdrs)(struct proc *,
-                   struct uvm_coredump_state *);
+static int     ELFNAMEEND(coredump_getseghdrs)(struct uvm_coredump_state *);
 
 static int     ELFNAMEEND(coredump_notes)(struct lwp *, struct note_state *);
 static int     ELFNAMEEND(coredump_note)(struct lwp *, struct note_state *);
@@ -265,7 +265,7 @@
 }
 
 static int
-ELFNAMEEND(coredump_getseghdrs)(struct proc *p, struct uvm_coredump_state *us)
+ELFNAMEEND(coredump_getseghdrs)(struct uvm_coredump_state *us)
 {
        struct writesegs_state *ws = us->cookie;
        Elf_Phdr phdr;
@@ -290,7 +290,7 @@
                int i;
 
                end -= slen;
-               if ((error = copyin_proc(p, (void *)end, buf, slen)) != 0)
+               if ((error = copyin_proc(ws->p, (void *)end, buf, slen)) != 0)
                        return error;
 
                ep = (const long *) &buf[slen / sizeof(buf[0])];
@@ -397,18 +397,20 @@
 
        /*
         * Now, for each LWP, write the register info and any other
-        * per-LWP notes.  Since we're dumping core, we don't bother
-        * locking.
+        * per-LWP notes.
+        * Lock in case this is a gcore requested dump.
         */
+       mutex_enter(p->p_lock);
        LIST_FOREACH(l0, &p->p_lwps, l_sibling) {
                if (l0 == l)            /* we've taken care of this thread */
                        continue;
                error = ELFNAMEEND(coredump_note)(l0, ns);
                if (error)
-                       return (error);
+                       break;
        }
+       mutex_exit(p->p_lock);
 
-       return (0);
+       return error;
 }
 
 static int
diff -r 6b3bd3975c00 -r b21912862a5d sys/kern/core_netbsd.c
--- a/sys/kern/core_netbsd.c    Fri Jan 03 20:52:47 2014 +0000
+++ b/sys/kern/core_netbsd.c    Fri Jan 03 21:12:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: core_netbsd.c,v 1.20 2014/01/03 15:15:02 dsl Exp $     */
+/*     $NetBSD: core_netbsd.c,v 1.21 2014/01/03 21:12:18 dsl Exp $     */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.20 2014/01/03 15:15:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.21 2014/01/03 21:12:18 dsl Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_coredump.h"
@@ -74,8 +74,7 @@
        struct CORENAME(core) core;
 };
 
-static int     CORENAME(coredump_writesegs_netbsd)(struct proc *,
-                   struct uvm_coredump_state *);
+static int     CORENAME(coredump_writesegs_netbsd)(struct uvm_coredump_state *);
 
 int
 CORENAME(coredump_netbsd)(struct lwp *l, struct coredump_iostate *iocookie)
@@ -118,8 +117,7 @@
 }
 
 static int
-CORENAME(coredump_writesegs_netbsd)(struct proc *p,
-    struct uvm_coredump_state *us)
+CORENAME(coredump_writesegs_netbsd)(struct uvm_coredump_state *us)
 {
        struct coredump_state *cs = us->cookie;
        struct CORENAME(coreseg) cseg;
diff -r 6b3bd3975c00 -r b21912862a5d sys/uvm/uvm_coredump.c
--- a/sys/uvm/uvm_coredump.c    Fri Jan 03 20:52:47 2014 +0000
+++ b/sys/uvm/uvm_coredump.c    Fri Jan 03 21:12:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_coredump.c,v 1.4 2014/01/03 15:15:02 dsl Exp $     */
+/*     $NetBSD: uvm_coredump.c,v 1.5 2014/01/03 21:12:18 dsl Exp $     */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_coredump.c,v 1.4 2014/01/03 15:15:02 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_coredump.c,v 1.5 2014/01/03 21:12:18 dsl Exp $");
 
 /*
  * uvm_coredump.c: glue functions for coredump
@@ -84,8 +84,8 @@
  */
 
 int
-uvm_coredump_walkmap(struct proc *p, int (*func)(struct proc *,
-    struct uvm_coredump_state *), void *cookie)
+uvm_coredump_walkmap(struct proc *p, int (*func)(struct uvm_coredump_state *),
+    void *cookie)
 {
        struct uvm_coredump_state state;
        struct vmspace *vm = p->p_vmspace;
@@ -191,7 +191,7 @@
                        continue;
                
                vm_map_unlock_read(map);
-               error = (*func)(p, &state);
+               error = (*func)(&state);
                if (error)
                        return (error);
                vm_map_lock_read(map);
@@ -202,7 +202,7 @@
 }
 
 static int
-count_segs(struct proc *p, struct uvm_coredump_state *s)
+count_segs(struct uvm_coredump_state *s)
 {
     (*(int *)s->cookie)++;
 
diff -r 6b3bd3975c00 -r b21912862a5d sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h      Fri Jan 03 20:52:47 2014 +0000
+++ b/sys/uvm/uvm_extern.h      Fri Jan 03 21:12:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_extern.h,v 1.187 2014/01/03 15:15:02 dsl Exp $     */
+/*     $NetBSD: uvm_extern.h,v 1.188 2014/01/03 21:12:18 dsl Exp $     */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -590,9 +590,8 @@
 void                   uvm_proc_fork(struct proc *, struct proc *, bool);
 void                   uvm_lwp_fork(struct lwp *, struct lwp *,
                            void *, size_t, void (*)(void *), void *);
-struct coredump_iostate;
-int                    uvm_coredump_walkmap(struct proc *, int (*)(struct proc *,
-                           struct uvm_coredump_state *), void *);
+int                    uvm_coredump_walkmap(struct proc *,
+                           int (*)(struct uvm_coredump_state *), void *);
 int                    uvm_coredump_count_segs(struct proc *);
 void                   uvm_proc_exit(struct proc *);
 void                   uvm_lwp_exit(struct lwp *);



Home | Main Index | Thread Index | Old Index