Source-Changes-HG archive

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

[src/yamt-uio_vmspace]: src/sys/uvm - add a function to add a reference to a ...



details:   https://anonhg.NetBSD.org/src/rev/cc056c9edd75
branches:  yamt-uio_vmspace
changeset: 586693:cc056c9edd75
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sat Dec 31 11:21:26 2005 +0000

description:
- add a function to add a reference to a vmspace.
- add a macro to check if a vmspace belongs to kernel.

diffstat:

 sys/uvm/uvm_extern.h |   4 +++-
 sys/uvm/uvm_map.c    |  28 +++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 8 deletions(-)

diffs (82 lines):

diff -r 426765f149c6 -r cc056c9edd75 sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h      Sat Dec 31 11:14:00 2005 +0000
+++ b/sys/uvm/uvm_extern.h      Sat Dec 31 11:21:26 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_extern.h,v 1.108 2005/12/21 12:19:04 yamt Exp $    */
+/*     $NetBSD: uvm_extern.h,v 1.108.2.1 2005/12/31 11:21:26 yamt Exp $        */
 
 /*
  *
@@ -511,6 +511,7 @@
        caddr_t vm_maxsaddr;    /* user VA at max stack growth */
        caddr_t vm_minsaddr;    /* user VA at top of stack */
 };
+#define        VMSPACE_IS_KERNEL(vm)   VM_MAP_IS_KERNEL(&(vm)->vm_map)
 
 #ifdef _KERNEL
 
@@ -639,6 +640,7 @@
                            vaddr_t, vaddr_t);
 void                   uvmspace_exec(struct lwp *, vaddr_t, vaddr_t);
 struct vmspace         *uvmspace_fork(struct vmspace *);
+void                   uvmspace_addref(struct vmspace *);
 void                   uvmspace_free(struct vmspace *);
 void                   uvmspace_share(struct proc *, struct proc *);
 void                   uvmspace_unshare(struct lwp *);
diff -r 426765f149c6 -r cc056c9edd75 sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Sat Dec 31 11:14:00 2005 +0000
+++ b/sys/uvm/uvm_map.c Sat Dec 31 11:21:26 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_map.c,v 1.206 2005/12/24 20:45:10 perry Exp $      */
+/*     $NetBSD: uvm_map.c,v 1.206.2.1 2005/12/31 11:21:26 yamt Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.206 2005/12/24 20:45:10 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.206.2.1 2005/12/31 11:21:26 yamt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -3654,12 +3654,9 @@
 void
 uvmspace_share(struct proc *p1, struct proc *p2)
 {
-       struct simplelock *slock = &p1->p_vmspace->vm_map.ref_lock;
-
+
+       uvmspace_addref(p1->p_vmspace);
        p2->p_vmspace = p1->p_vmspace;
-       simple_lock(slock);
-       p1->p_vmspace->vm_refcnt++;
-       simple_unlock(slock);
 }
 
 /*
@@ -3769,6 +3766,23 @@
 }
 
 /*
+ * uvmspace_addref: add a referece to a vmspace.
+ */
+
+void
+uvmspace_addref(struct vmspace *vm)
+{
+       struct vm_map *map = &vm->vm_map;
+
+       KASSERT((map->flags & VM_MAP_DYING) == 0);
+
+       simple_lock(&map->ref_lock);
+       KASSERT(vm->vm_refcnt > 0);
+       vm->vm_refcnt++;
+       simple_unlock(&map->ref_lock);
+}
+
+/*
  * uvmspace_free: free a vmspace data structure
  */
 



Home | Main Index | Thread Index | Old Index