Source-Changes-HG archive

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

[src/netbsd-9]: src/tests/rump/rumpkern Pull up following revision(s) - all v...



details:   https://anonhg.NetBSD.org/src/rev/0b75897babbd
branches:  netbsd-9
changeset: 1002327:0b75897babbd
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 06 04:22:34 2021 +0000

description:
Pull up following revision(s) - all via patch -
(requested by riastradh in ticket #1317):

        sys/uvm/uvm_page.c: revision 1.248
        sys/uvm/uvm_anon.c: revision 1.80
        sys/rump/librump/rumpvfs/vm_vfs.c: revision 1.40
        sys/rump/librump/rumpvfs/vm_vfs.c: revision 1.41
        sys/rump/librump/rumpkern/vm.c: revision 1.191
        sys/uvm/uvm_pager.c: revision 1.130
        external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c: revision 1.71
        tests/rump/rumpkern/t_vm.c: revision 1.5
        tests/rump/rumpkern/t_vm.c: revision 1.6
        sys/rump/librump/rumpvfs/vm_vfs.c: revision 1.39

Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to
uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to
handle this flag separately.  Split out the pages part of uvm_aio_aiodone()
into uvm_aio_aiodone_pages() in rump just like in the real kernel.

In ZFS functions that can fail to copy data between the ARC and VM pages,
use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can
handle these "I/O" errors.  Fixes PR 55702.

fix an incorrect assertion in the previous commit.

Handle PG_PAGEOUT in uvm_anon_release() too.

Commit the ZFS file that I forgot in this previous commit:

Move the handling of PG_PAGEOUT from uvm_aio_aiodone_pages() to
uvm_page_unbusy() so that all callers of uvm_page_unbusy() don't need to
handle this flag separately.  Split out the pages part of uvm_aio_aiodone()
into uvm_aio_aiodone_pages() in rump just like in the real kernel.

In ZFS functions that can fail to copy data between the ARC and VM pages,
use uvm_aio_aiodone_pages() rather than uvm_page_unbusy() so that we can
handle these "I/O" errors.  Fixes PR 55702.
update the rump copy of uvm_page_unbusy() to match the real version,
in particular handle PG_PAGEOUT.  fixes a few atf tests.
the busypage test is buggy, expect it to fail.

make rump's uvm_aio_aiodone_pages() look more like the kernel version.
fixes some more rumpy assertions.

for the busypage test, replace atf_tc_expect_fail() with atf_tc_skip()
because atf apparently has no way to expect a test program to crash.
fixes PR 55945.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c |  18 ++--
 sys/rump/librump/rumpkern/vm.c                         |  43 ++++++++++--
 sys/rump/librump/rumpvfs/vm_vfs.c                      |  62 +++++++++++------
 sys/uvm/uvm_anon.c                                     |   9 ++-
 sys/uvm/uvm_page.c                                     |  18 ++++-
 sys/uvm/uvm_pager.c                                    |  16 +----
 tests/rump/rumpkern/t_vm.c                             |   6 +-
 7 files changed, 110 insertions(+), 62 deletions(-)

diffs (truncated from 377 to 300 lines):

diff -r 5dfd9a7cea98 -r 0b75897babbd external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c    Tue Jul 06 04:17:03 2021 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c    Tue Jul 06 04:22:34 2021 +0000
@@ -6007,6 +6007,12 @@
                    va, DMU_READ_PREFETCH);
                zfs_unmap_page(pg, va);
 
+               if (err != 0) {
+                       uvm_aio_aiodone_pages(ap->a_m, npages, false, err);
+                       memset(ap->a_m, 0, sizeof(ap->a_m[0]) *
+                              npages);
+                       goto out;
+               }
                mutex_enter(mtx);
                pg->flags &= ~(PG_FAKE);
                pmap_clear_modify(pg);
@@ -6023,6 +6029,7 @@
        mutex_exit(mtx);
        ap->a_m[ap->a_centeridx] = pg;
 
+out:
        ZFS_EXIT(zfsvfs);
        fstrans_done(mp);
 
@@ -6039,14 +6046,13 @@
        voff_t          len, klen;
        int             err;
 
-       bool async = (flags & PGO_SYNCIO) == 0;
        bool *cleanedp;
        struct uvm_object *uobj = &vp->v_uobj;
        kmutex_t *mtx = uobj->vmobjlock;
 
        if (zp->z_sa_hdl == NULL) {
                err = 0;
-               goto out_unbusy;
+               goto out;
        }
 
        /*
@@ -6120,14 +6126,8 @@
        }
        dmu_tx_commit(tx);
 
-out_unbusy:
-       mutex_enter(mtx);
-       mutex_enter(&uvm_pageqlock);
-       uvm_page_unbusy(pp, count);
-       mutex_exit(&uvm_pageqlock);
-       mutex_exit(mtx);
-
 out:
+       uvm_aio_aiodone_pages(pp, count, true, err);
        return (err);
 }
 
diff -r 5dfd9a7cea98 -r 0b75897babbd sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c    Tue Jul 06 04:17:03 2021 +0000
+++ b/sys/rump/librump/rumpkern/vm.c    Tue Jul 06 04:22:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm.c,v 1.173 2017/05/14 13:49:55 nat Exp $     */
+/*     $NetBSD: vm.c,v 1.173.14.1 2021/07/06 04:22:34 martin Exp $     */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.173 2017/05/14 13:49:55 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.173.14.1 2021/07/06 04:22:34 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -632,23 +632,50 @@
 uvm_page_unbusy(struct vm_page **pgs, int npgs)
 {
        struct vm_page *pg;
-       int i;
+       int i, pageout_done;
 
        KASSERT(npgs > 0);
-       KASSERT(mutex_owned(pgs[0]->uobject->vmobjlock));
 
+       pageout_done = 0;
        for (i = 0; i < npgs; i++) {
                pg = pgs[i];
-               if (pg == NULL)
+               if (pg == NULL || pg == PGO_DONTCARE) {
                        continue;
+               }
 
+#if 0
+               KASSERT(uvm_page_owner_locked_p(pg, true));
+#else
+               /*
+                * uvm_page_owner_locked_p() is not available in rump,
+                * and rump doesn't support amaps anyway.
+                */
+               KASSERT(mutex_owned(pg->uobject->vmobjlock));
+#endif
                KASSERT(pg->flags & PG_BUSY);
-               if (pg->flags & PG_WANTED)
+
+               if (pg->flags & PG_PAGEOUT) {
+                       pg->flags &= ~PG_PAGEOUT;
+                       pg->flags |= PG_RELEASED;
+                       pageout_done++;
+                       atomic_inc_uint(&uvmexp.pdfreed);
+               }
+               if (pg->flags & PG_WANTED) {
                        wakeup(pg);
-               if (pg->flags & PG_RELEASED)
+               }
+               if (pg->flags & PG_RELEASED) {
+                       KASSERT(pg->uobject != NULL ||
+                           (pg->uanon != NULL && pg->uanon->an_ref > 0));
+                       pg->flags &= ~PG_RELEASED;
                        uvm_pagefree(pg);
-               else
+               } else {
+                       KASSERT((pg->flags & PG_FAKE) == 0);
                        pg->flags &= ~(PG_WANTED|PG_BUSY);
+                       UVM_PAGE_OWN(pg, NULL);
+               }
+       }
+       if (pageout_done != 0) {
+               uvm_pageout_done(pageout_done);
        }
 }
 
diff -r 5dfd9a7cea98 -r 0b75897babbd sys/rump/librump/rumpvfs/vm_vfs.c
--- a/sys/rump/librump/rumpvfs/vm_vfs.c Tue Jul 06 04:17:03 2021 +0000
+++ b/sys/rump/librump/rumpvfs/vm_vfs.c Tue Jul 06 04:22:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm_vfs.c,v 1.34 2013/10/18 19:56:11 christos Exp $     */
+/*     $NetBSD: vm_vfs.c,v 1.34.34.1 2021/07/06 04:22:34 martin Exp $  */
 
 /*
  * Copyright (c) 2008-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.34 2013/10/18 19:56:11 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_vfs.c,v 1.34.34.1 2021/07/06 04:22:34 martin Exp $");
 
 #include <sys/param.h>
 
@@ -36,19 +36,47 @@
 #include <uvm/uvm.h>
 #include <uvm/uvm_readahead.h>
 
+void
+uvm_aio_aiodone_pages(struct vm_page **pgs, int npages, bool write, int error)
+{
+       struct uvm_object *uobj = pgs[0]->uobject;
+       struct vm_page *pg;
+       int i;
+
+       mutex_enter(uobj->vmobjlock);
+       for (i = 0; i < npages; i++) {
+               pg = pgs[i];
+               KASSERT((pg->flags & PG_PAGEOUT) == 0 ||
+                       (pg->flags & PG_FAKE) == 0);
+
+               if (pg->flags & PG_FAKE) {
+                       KASSERT(!write);
+                       pg->flags &= ~PG_FAKE;
+                       KASSERT((pg->flags & PG_CLEAN) != 0);
+                       uvm_pageenqueue(pg);
+                       pmap_clear_modify(pg);
+               }
+
+       }
+       uvm_page_unbusy(pgs, npages);
+       mutex_exit(uobj->vmobjlock);
+}
+
 /*
- * release resources held during async io.  this is almost the
- * same as uvm_aio_aiodone() from uvm_pager.c and only lacks the
- * call to uvm_aio_aiodone_pages(): unbusies pages directly here.
+ * Release resources held during async io.
  */
 void
 uvm_aio_aiodone(struct buf *bp)
 {
        struct uvm_object *uobj = NULL;
-       int i, npages = bp->b_bufsize >> PAGE_SHIFT;
+       int npages = bp->b_bufsize >> PAGE_SHIFT;
        struct vm_page **pgs;
        vaddr_t va;
-       int pageout = 0;
+       int i, error;
+       bool write;
+
+       error = bp->b_error;
+       write = BUF_ISWRITE(bp);
 
        KASSERT(npages > 0);
        pgs = kmem_alloc(npages * sizeof(*pgs), KM_SLEEP);
@@ -59,29 +87,15 @@
                if (uobj == NULL) {
                        uobj = pgs[i]->uobject;
                        KASSERT(uobj != NULL);
-                       mutex_enter(uobj->vmobjlock);
                } else {
                        KASSERT(uobj == pgs[i]->uobject);
                }
-
-               if (pgs[i]->flags & PG_PAGEOUT) {
-                       KASSERT((pgs[i]->flags & PG_FAKE) == 0);
-                       pageout++;
-                       pgs[i]->flags &= ~PG_PAGEOUT;
-                       pgs[i]->flags |= PG_RELEASED;
-               }
        }
-       KASSERT(mutex_owned(uobj->vmobjlock));
+       uvm_pagermapout((vaddr_t)bp->b_data, npages);
 
-       mutex_enter(&uvm_pageqlock);
-       uvm_page_unbusy(pgs, npages);
-       mutex_exit(&uvm_pageqlock);
-       mutex_exit(uobj->vmobjlock);
+       uvm_aio_aiodone_pages(pgs, npages, write, error);
 
-       uvm_pagermapout((vaddr_t)bp->b_data, npages);
-       uvm_pageout_done(pageout);
-
-       if (BUF_ISWRITE(bp) && (bp->b_cflags & BC_AGE) != 0) {
+       if (write && (bp->b_cflags & BC_AGE) != 0) {
                mutex_enter(bp->b_objlock);
                vwakeup(bp);
                mutex_exit(bp->b_objlock);
diff -r 5dfd9a7cea98 -r 0b75897babbd sys/uvm/uvm_anon.c
--- a/sys/uvm/uvm_anon.c        Tue Jul 06 04:17:03 2021 +0000
+++ b/sys/uvm/uvm_anon.c        Tue Jul 06 04:22:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_anon.c,v 1.64 2017/10/28 00:37:13 pgoyette Exp $   */
+/*     $NetBSD: uvm_anon.c,v 1.64.8.1 2021/07/06 04:22:34 martin Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.64 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_anon.c,v 1.64.8.1 2021/07/06 04:22:34 martin Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -443,6 +443,11 @@
        KASSERT(pg->loan_count == 0);
        KASSERT(anon->an_ref == 0);
 
+       if ((pg->flags & PG_PAGEOUT) != 0) {
+               pg->flags &= ~PG_PAGEOUT;
+               uvm_pageout_done(1);
+       }
+
        mutex_enter(&uvm_pageqlock);
        uvm_pagefree(pg);
        mutex_exit(&uvm_pageqlock);
diff -r 5dfd9a7cea98 -r 0b75897babbd sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Tue Jul 06 04:17:03 2021 +0000
+++ b/sys/uvm/uvm_page.c        Tue Jul 06 04:22:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.199 2019/03/14 19:10:04 kre Exp $       */
+/*     $NetBSD: uvm_page.c,v 1.199.4.1 2021/07/06 04:22:34 martin Exp $        */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.199 2019/03/14 19:10:04 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.199.4.1 2021/07/06 04:22:34 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -1362,9 +1362,10 @@
 uvm_page_unbusy(struct vm_page **pgs, int npgs)
 {
        struct vm_page *pg;
-       int i;
+       int i, pageout_done;
        UVMHIST_FUNC("uvm_page_unbusy"); UVMHIST_CALLED(ubchist);
 
+       pageout_done = 0;
        for (i = 0; i < npgs; i++) {
                pg = pgs[i];
                if (pg == NULL || pg == PGO_DONTCARE) {
@@ -1373,7 +1374,13 @@
 
                KASSERT(uvm_page_locked_p(pg));
                KASSERT(pg->flags & PG_BUSY);
-               KASSERT((pg->flags & PG_PAGEOUT) == 0);



Home | Main Index | Thread Index | Old Index