Source-Changes-HG archive

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

[src/trunk]: src hold object lock across page unbusy



details:   https://anonhg.NetBSD.org/src/rev/1b381e0456cd
branches:  trunk
changeset: 757644:1b381e0456cd
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Sep 09 09:59:48 2010 +0000

description:
hold object lock across page unbusy

diffstat:

 sys/rump/librump/rumpvfs/vm_vfs.c |  12 ++++++++----
 tests/rump/kernspace/busypage.c   |   6 +++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diffs (93 lines):

diff -r 9e740fa5ea02 -r 1b381e0456cd sys/rump/librump/rumpvfs/vm_vfs.c
--- a/sys/rump/librump/rumpvfs/vm_vfs.c Thu Sep 09 09:50:21 2010 +0000
+++ b/sys/rump/librump/rumpvfs/vm_vfs.c Thu Sep 09 09:59:48 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm_vfs.c,v 1.21 2010/09/09 09:50:21 pooka Exp $        */
+/*     $NetBSD: vm_vfs.c,v 1.22 2010/09/09 10:01:25 pooka Exp $        */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.21 2010/09/09 09:50:21 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.22 2010/09/09 10:01:25 pooka Exp $");
 
 #include <sys/param.h>
 
@@ -114,10 +114,10 @@
                return;
 
        pgs = kmem_alloc(maxpages * sizeof(pgs), KM_SLEEP);
+       mutex_enter(&uobj->vmobjlock);
        while (len) {
                npages = MIN(maxpages, round_page(len) >> PAGE_SHIFT);
                memset(pgs, 0, npages * sizeof(struct vm_page *));
-               mutex_enter(&uobj->vmobjlock);
                rv = uobj->pgops->pgo_get(uobj, trunc_page(off),
                    pgs, &npages, 0, VM_PROT_READ | VM_PROT_WRITE,
                    0, PAGERFLAGS | PGO_PASTEOF);
@@ -142,8 +142,10 @@
                        off += chunklen;
                        len -= chunklen;
                }
+               mutex_enter(&uobj->vmobjlock);
                uvm_page_unbusy(pgs, npages);
        }
+       mutex_exit(&uobj->vmobjlock);
        kmem_free(pgs, maxpages * sizeof(pgs));
 
        return;
@@ -170,10 +172,10 @@
        if (flags & UBC_FAULTBUSY)
                pagerflags |= PGO_OVERWRITE;
 
+       mutex_enter(&uobj->vmobjlock);
        do {
                npages = len2npages(uio->uio_offset, todo);
                memset(pgs, 0, pgalloc);
-               mutex_enter(&uobj->vmobjlock);
                rv = uobj->pgops->pgo_get(uobj, trunc_page(uio->uio_offset),
                    pgs, &npages, 0, VM_PROT_READ | VM_PROT_WRITE, 0,
                    pagerflags);
@@ -198,8 +200,10 @@
                                pg->flags &= ~(PG_CLEAN | PG_FAKE);
                        todo -= xfersize;
                }
+               mutex_enter(&uobj->vmobjlock);
                uvm_page_unbusy(pgs, npages);
        } while (todo);
+       mutex_exit(&uobj->vmobjlock);
 
  out:
        kmem_free(pgs, pgalloc);
diff -r 9e740fa5ea02 -r 1b381e0456cd tests/rump/kernspace/busypage.c
--- a/tests/rump/kernspace/busypage.c   Thu Sep 09 09:50:21 2010 +0000
+++ b/tests/rump/kernspace/busypage.c   Thu Sep 09 09:59:48 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: busypage.c,v 1.2 2010/09/08 20:40:24 pooka Exp $       */
+/*     $NetBSD: busypage.c,v 1.3 2010/09/09 09:59:48 pooka Exp $       */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: busypage.c,v 1.2 2010/09/08 20:40:24 pooka Exp $");
+__RCSID("$NetBSD: busypage.c,v 1.3 2010/09/09 09:59:48 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -83,9 +83,9 @@
        mutex_enter(&uobj->vmobjlock);
        while (!threadrun)
                cv_wait(&tcv, &uobj->vmobjlock);
-       mutex_exit(&uobj->vmobjlock);
 
        uvm_page_unbusy(&testpg, 1);
+       mutex_exit(&uobj->vmobjlock);
 
        rv = kthread_join(newl);
        if (rv)



Home | Main Index | Thread Index | Old Index