Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm amap_copy(): Keep the source amap locked until its l...



details:   https://anonhg.NetBSD.org/src/rev/441ebb846586
branches:  trunk
changeset: 766556:441ebb846586
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Jun 27 15:56:36 2011 +0000

description:
amap_copy(): Keep the source amap locked until its lock has been copied.

Kernel assertion "anon->an_lock == amap->am_lock" no longer fails.

Ok: Mindaugas Rasiukevicius <rmind%netbsd.org@localhost>

diffstat:

 sys/uvm/uvm_amap.c |  21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diffs (63 lines):

diff -r 5305e263f2f9 -r 441ebb846586 sys/uvm/uvm_amap.c
--- a/sys/uvm/uvm_amap.c        Mon Jun 27 14:53:25 2011 +0000
+++ b/sys/uvm/uvm_amap.c        Mon Jun 27 15:56:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_amap.c,v 1.99 2011/06/24 01:48:43 rmind Exp $      */
+/*     $NetBSD: uvm_amap.c,v 1.100 2011/06/27 15:56:36 hannken Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.99 2011/06/24 01:48:43 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.100 2011/06/27 15:56:36 hannken Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -766,7 +766,6 @@
        const int waitf = (flags & AMAP_COPY_NOWAIT) ? UVM_FLAG_NOWAIT : 0;
        struct vm_amap *amap, *srcamap;
        struct vm_anon *tofree;
-       kmutex_t *lock;
        u_int slots, lcv;
        vsize_t len;
 
@@ -900,7 +899,7 @@
        /*
         * Drop our reference to the old amap (srcamap) and unlock.
         * Since the reference count on srcamap is greater than one,
-        * (we checked above), it cannot drop to zero.
+        * (we checked above), it cannot drop to zero while it is locked.
         */
 
        srcamap->am_ref--;
@@ -917,20 +916,20 @@
        }
 #endif
        uvm_anfree(tofree);
-       amap_unlock(srcamap);
 
        /*
         * If we referenced any anons, then share the source amap's lock.
         * Otherwise, we have nothing in common, so allocate a new one.
         */
 
+       KASSERT(amap->am_lock == NULL);
        if (amap->am_nused != 0) {
-               lock = srcamap->am_lock;
-               mutex_obj_hold(lock);
-       } else {
-               lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
-       }               
-       amap->am_lock = lock;
+               amap->am_lock = srcamap->am_lock;
+               mutex_obj_hold(amap->am_lock);
+       }
+       amap_unlock(srcamap);
+       if (amap->am_lock == NULL)
+               amap->am_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
        amap_list_insert(amap);
 
        /*



Home | Main Index | Thread Index | Old Index