Source-Changes-HG archive

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

[src/trunk]: src Tweak the March 14th change to make page waits interlocked b...



details:   https://anonhg.NetBSD.org/src/rev/0019998a3dbe
branches:  trunk
changeset: 849878:0019998a3dbe
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Mar 17 18:31:38 2020 +0000

description:
Tweak the March 14th change to make page waits interlocked by pg->interlock.
Remove unneeded changes and only deal with the PQ_WANTED flag, to exclude
possible bugs.

diffstat:

 sys/miscfs/genfs/genfs_io.c     |   8 ++++----
 sys/rump/librump/rumpkern/vm.c  |  11 +++++------
 sys/ufs/lfs/lfs_pages.c         |   7 ++++---
 sys/uvm/uvm_aobj.c              |   9 +++++----
 sys/uvm/uvm_bio.c               |   8 +++++---
 sys/uvm/uvm_fault.c             |  33 +++++++++++++++++++++------------
 sys/uvm/uvm_loan.c              |  29 ++++++++++++++++++++---------
 sys/uvm/uvm_page.c              |  26 ++++++++++++--------------
 sys/uvm/uvm_page.h              |   4 ++--
 tests/rump/kernspace/busypage.c |   8 +++-----
 10 files changed, 81 insertions(+), 62 deletions(-)

diffs (truncated from 504 to 300 lines):

diff -r 76771f88c831 -r 0019998a3dbe sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c       Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/miscfs/genfs/genfs_io.c       Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_io.c,v 1.93 2020/03/14 20:45:23 ad Exp $ */
+/*     $NetBSD: genfs_io.c,v 1.94 2020/03/17 18:31:38 ad Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.93 2020/03/14 20:45:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.94 2020/03/17 18:31:38 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -516,9 +516,9 @@
                        }
                        uvm_pagelock(pg);
                        uvm_pageenqueue(pg);
-                       uvm_pageunbusy(pg);
+                       uvm_pagewakeup(pg);
                        uvm_pageunlock(pg);
-                       pg->flags &= ~PG_FAKE;
+                       pg->flags &= ~(PG_BUSY|PG_FAKE);
                        UVM_PAGE_OWN(pg, NULL);
                } else if (memwrite && !overwrite &&
                    uvm_pagegetdirty(pg) == UVM_PAGE_STATUS_CLEAN) {
diff -r 76771f88c831 -r 0019998a3dbe sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c    Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/rump/librump/rumpkern/vm.c    Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm.c,v 1.186 2020/03/14 20:23:51 ad Exp $      */
+/*     $NetBSD: vm.c,v 1.187 2020/03/17 18:31:38 ad 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.186 2020/03/14 20:23:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.187 2020/03/17 18:31:38 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -689,8 +689,9 @@
                if (pg->flags & PG_RELEASED) {
                        uvm_pagefree(pg);
                } else {
+                       pg->flags &= ~PG_BUSY;
                        uvm_pagelock(pg);
-                       uvm_pageunbusy(pg);
+                       uvm_pagewakeup(pg);
                        uvm_pageunlock(pg);
                }
        }
@@ -710,17 +711,15 @@
 }
 
 void
-uvm_pageunbusy(struct vm_page *pg)
+uvm_pagewakeup(struct vm_page *pg)
 {
 
-       KASSERT((pg->flags & PG_BUSY) != 0);
        KASSERT(mutex_owned(&pg->interlock));
 
        if ((pg->pqflags & PQ_WANTED) != 0) {
                pg->pqflags &= ~PQ_WANTED;
                wakeup(pg);
        }
-       pg->flags &= ~PG_BUSY;
 }
 
 void
diff -r 76771f88c831 -r 0019998a3dbe sys/ufs/lfs/lfs_pages.c
--- a/sys/ufs/lfs/lfs_pages.c   Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/ufs/lfs/lfs_pages.c   Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_pages.c,v 1.24 2020/03/14 20:45:23 ad Exp $        */
+/*     $NetBSD: lfs_pages.c,v 1.25 2020/03/17 18:31:38 ad Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.24 2020/03/14 20:45:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.25 2020/03/17 18:31:38 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -348,8 +348,9 @@
                                        pg->flags |= PG_DELWRI;
                                }
                        }
+                       pg->flags &= ~PG_BUSY;
                        uvm_pagelock(pg);
-                       uvm_pageunbusy(pg);
+                       uvm_pagewakeup(pg);
                        uvm_pageunlock(pg);
                        UVM_PAGE_OWN(pg, NULL);
                }
diff -r 76771f88c831 -r 0019998a3dbe sys/uvm/uvm_aobj.c
--- a/sys/uvm/uvm_aobj.c        Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/uvm/uvm_aobj.c        Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_aobj.c,v 1.137 2020/03/14 20:23:51 ad Exp $        */
+/*     $NetBSD: uvm_aobj.c,v 1.138 2020/03/17 18:31:39 ad Exp $        */
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.137 2020/03/14 20:23:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.138 2020/03/17 18:31:39 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_uvmhist.h"
@@ -1300,11 +1300,12 @@
         */
        uvm_pagelock(pg);
        uvm_pageenqueue(pg);
-       uvm_pageunbusy(pg);
+       uvm_pagewakeup(pg);
        uvm_pageunlock(pg);
 
-       pg->flags &= ~(PG_FAKE);
+       pg->flags &= ~(PG_BUSY|PG_FAKE);
        uvm_pagemarkdirty(pg, UVM_PAGE_STATUS_DIRTY);
+       UVM_PAGE_OWN(pg, NULL);
 
        return false;
 }
diff -r 76771f88c831 -r 0019998a3dbe sys/uvm/uvm_bio.c
--- a/sys/uvm/uvm_bio.c Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/uvm/uvm_bio.c Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_bio.c,v 1.105 2020/03/14 20:23:51 ad Exp $ */
+/*     $NetBSD: uvm_bio.c,v 1.106 2020/03/17 18:31:39 ad Exp $ */
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.105 2020/03/14 20:23:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.106 2020/03/17 18:31:39 ad Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -283,8 +283,10 @@
 
        uvm_pagelock(pg);
        uvm_pageactivate(pg);
-       uvm_pageunbusy(pg);
+       uvm_pagewakeup(pg);
        uvm_pageunlock(pg);
+       pg->flags &= ~PG_BUSY;
+       UVM_PAGE_OWN(pg, NULL);
 
        return error;
 }
diff -r 76771f88c831 -r 0019998a3dbe sys/uvm/uvm_fault.c
--- a/sys/uvm/uvm_fault.c       Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/uvm/uvm_fault.c       Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_fault.c,v 1.218 2020/03/14 20:23:51 ad Exp $       */
+/*     $NetBSD: uvm_fault.c,v 1.219 2020/03/17 18:31:39 ad Exp $       */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.218 2020/03/14 20:23:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.219 2020/03/17 18:31:39 ad Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -479,10 +479,11 @@
 
                        uvm_pagelock(pg);
                        uvm_pageactivate(pg);
-                       uvm_pageunbusy(pg);
+                       uvm_pagewakeup(pg);
                        uvm_pageunlock(pg);
-                       pg->flags &= ~PG_FAKE;
+                       pg->flags &= ~(PG_BUSY|PG_FAKE);
                        uvm_pagemarkdirty(pg, UVM_PAGE_STATUS_UNKNOWN);
+                       UVM_PAGE_OWN(pg, NULL);
 #else
                        panic("%s: we_own", __func__);
 #endif /* defined(VMSWAP) */
@@ -1851,7 +1852,7 @@
         * Since this page isn't the page that's actually faulting,
         * ignore pmap_enter() failures; it's not critical that we
         * enter these right now.
-        * NOTE: page can't be PG_RELEASED because we've
+        * NOTE: page can't be waited on or PG_RELEASED because we've
         * held the lock the whole time we've had the handle.
         */
        KASSERT((pg->flags & PG_PAGEOUT) == 0);
@@ -1988,9 +1989,11 @@
                    "  wasn't able to relock after fault: retry",
                    0,0,0,0);
                if ((pg->flags & PG_RELEASED) == 0) {
+                       pg->flags &= ~PG_BUSY;
                        uvm_pagelock(pg);
-                       uvm_pageunbusy(pg);
+                       uvm_pagewakeup(pg);
                        uvm_pageunlock(pg);
+                       UVM_PAGE_OWN(pg, NULL);
                } else {
                        cpu_count(CPU_COUNT_FLTPGRELE, 1);
                        uvm_pagefree(pg);
@@ -2091,8 +2094,10 @@
                         */
 
                        uvm_pagelock(uobjpage);
-                       uvm_pageunbusy(uobjpage);
+                       uvm_pagewakeup(uobjpage);
                        uvm_pageunlock(uobjpage);
+                       uobjpage->flags &= ~PG_BUSY;
+                       UVM_PAGE_OWN(uobjpage, NULL);
 
                        uvmfault_unlockall(ufi, amap, uobj);
                        UVMHIST_LOG(maphist,
@@ -2171,9 +2176,11 @@
                 * since we still hold the object lock.
                 */
 
+               uobjpage->flags &= ~PG_BUSY;
                uvm_pagelock(uobjpage);
-               uvm_pageunbusy(uobjpage);
+               uvm_pagewakeup(uobjpage);
                uvm_pageunlock(uobjpage);
+               UVM_PAGE_OWN(uobjpage, NULL);
 
                UVMHIST_LOG(maphist,
                    "  promote uobjpage %#jx to anon/page %#jx/%#jx",
@@ -2260,7 +2267,7 @@
 
                uvm_pagelock(pg);
                uvm_pageenqueue(pg);
-               uvm_pageunbusy(pg);
+               uvm_pagewakeup(pg);
                uvm_pageunlock(pg);
 
                /*
@@ -2268,7 +2275,8 @@
                 * the object lock since the last time we checked.
                 */
                KASSERT((pg->flags & PG_RELEASED) == 0);
-               pg->flags &= ~PG_FAKE;
+               pg->flags &= ~(PG_BUSY|PG_FAKE);
+               UVM_PAGE_OWN(pg, NULL);
 
                uvmfault_unlockall(ufi, amap, uobj);
                if (!uvm_reclaimable()) {
@@ -2291,9 +2299,10 @@
         */
        KASSERT((pg->flags & PG_RELEASED) == 0);
        uvm_pagelock(pg);
-       uvm_pageunbusy(pg);
+       uvm_pagewakeup(pg);
        uvm_pageunlock(pg);
-       pg->flags &= ~PG_FAKE;
+       pg->flags &= ~(PG_BUSY|PG_FAKE);
+       UVM_PAGE_OWN(pg, NULL);
 
        pmap_update(ufi->orig_map->pmap);
        uvmfault_unlockall(ufi, amap, uobj);
diff -r 76771f88c831 -r 0019998a3dbe sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c        Tue Mar 17 18:17:07 2020 +0000
+++ b/sys/uvm/uvm_loan.c        Tue Mar 17 18:31:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_loan.c,v 1.97 2020/03/14 20:23:51 ad Exp $ */
+/*     $NetBSD: uvm_loan.c,v 1.98 2020/03/17 18:31:39 ad Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.97 2020/03/14 20:23:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.98 2020/03/17 18:31:39 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -712,8 +712,10 @@



Home | Main Index | Thread Index | Old Index