Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm Add uvm_pagewanted_p(): return true if someone is wa...



details:   https://anonhg.NetBSD.org/src/rev/1695d5cdc50f
branches:  trunk
changeset: 972361:1695d5cdc50f
user:      ad <ad%NetBSD.org@localhost>
date:      Sun May 24 19:46:59 2020 +0000

description:
Add uvm_pagewanted_p(): return true if someone is waiting on the page and
assert caller has correct lock to observe that.

diffstat:

 sys/uvm/uvm_page.c |  21 ++++++++++++++++++---
 sys/uvm/uvm_page.h |   3 ++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diffs (67 lines):

diff -r 2ccabd886404 -r 1695d5cdc50f sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Sun May 24 19:46:10 2020 +0000
+++ b/sys/uvm/uvm_page.c        Sun May 24 19:46:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.237 2020/05/19 20:46:39 ad Exp $        */
+/*     $NetBSD: uvm_page.c,v 1.238 2020/05/24 19:46:59 ad Exp $        */
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.237 2020/05/19 20:46:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.238 2020/05/24 19:46:59 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -1718,8 +1718,8 @@
        KASSERT(uvm_page_owner_locked_p(pg, false));
 
        mutex_enter(&pg->interlock);
+       pg->pqflags |= PQ_WANTED;
        rw_exit(lock);
-       pg->pqflags |= PQ_WANTED;
        UVM_UNLOCK_AND_WAIT(pg, &pg->interlock, false, wmesg, 0);
 }
 
@@ -1744,6 +1744,21 @@
        }
 }
 
+/*
+ * uvm_pagewanted_p: return true if someone is waiting on the page
+ *
+ * => object must be write locked (lock out all concurrent access)
+ */
+
+bool
+uvm_pagewanted_p(struct vm_page *pg)
+{
+
+       KASSERT(uvm_page_owner_locked_p(pg, true));
+
+       return (atomic_load_relaxed(&pg->pqflags) & PQ_WANTED) != 0;
+}
+
 #if defined(UVM_PAGE_TRKOWN)
 /*
  * uvm_page_own: set or release page ownership
diff -r 2ccabd886404 -r 1695d5cdc50f sys/uvm/uvm_page.h
--- a/sys/uvm/uvm_page.h        Sun May 24 19:46:10 2020 +0000
+++ b/sys/uvm/uvm_page.h        Sun May 24 19:46:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.h,v 1.103 2020/05/17 19:38:17 ad Exp $        */
+/*     $NetBSD: uvm_page.h,v 1.104 2020/05/24 19:46:59 ad Exp $        */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -378,6 +378,7 @@
 bool uvm_pagereadonly_p(struct vm_page *);
 bool uvm_page_locked_p(struct vm_page *);
 void uvm_pagewakeup(struct vm_page *);
+bool uvm_pagewanted_p(struct vm_page *);
 void uvm_pagewait(struct vm_page *, krwlock_t *, const char *);
 
 int uvm_page_lookup_freelist(struct vm_page *);



Home | Main Index | Thread Index | Old Index