summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2015-10-08 15:58:39 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2015-10-08 15:58:39 +0000
commit76748a2648faa485e0567727bdbbc3068e9b0a8a (patch)
treee89f59c16f99202c1338c3247e52295fa1e12152 /sys
parent33d6754907f6e8756b273bf35b8e1e5d12fb197b (diff)
Lock the page queues by turning uvm_lock_pageq() and uvm_unlock_pageq() into
mtx_enter() and mtx_leave() operations. Not 100% this won't blow up but there is only one way to find out, and we need this to make progress on further unlocking uvm. prodded by deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/uvm/uvm.h3
-rw-r--r--sys/uvm/uvm_page.c3
-rw-r--r--sys/uvm/uvm_page.h6
-rw-r--r--sys/uvm/uvm_pdaemon.c4
4 files changed, 10 insertions, 6 deletions
diff --git a/sys/uvm/uvm.h b/sys/uvm/uvm.h
index bc42871cc7e..5a6082d35db 100644
--- a/sys/uvm/uvm.h
+++ b/sys/uvm/uvm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm.h,v 1.59 2015/05/04 10:21:15 dlg Exp $ */
+/* $OpenBSD: uvm.h,v 1.60 2015/10/08 15:58:38 kettenis Exp $ */
/* $NetBSD: uvm.h,v 1.24 2000/11/27 08:40:02 chs Exp $ */
/*
@@ -54,6 +54,7 @@ struct uvm {
struct pglist page_inactive_swp;/* pages inactive (reclaim or free) */
struct pglist page_inactive_obj;/* pages inactive (reclaim or free) */
/* Lock order: pageqlock, then fpageqlock. */
+ struct mutex pageqlock; /* lock for active/inactive page q */
struct mutex fpageqlock; /* lock for free page q + pdaemon */
boolean_t page_init_done; /* TRUE if uvm_page_init() finished */
struct uvm_pmr_control pmr_control; /* pmemrange data */
diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c
index 84be6eb8a38..08160054b48 100644
--- a/sys/uvm/uvm_page.c
+++ b/sys/uvm/uvm_page.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_page.c,v 1.142 2015/09/21 12:59:01 visa Exp $ */
+/* $OpenBSD: uvm_page.c,v 1.143 2015/10/08 15:58:38 kettenis Exp $ */
/* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */
/*
@@ -179,6 +179,7 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp)
TAILQ_INIT(&uvm.page_active);
TAILQ_INIT(&uvm.page_inactive_swp);
TAILQ_INIT(&uvm.page_inactive_obj);
+ mtx_init(&uvm.pageqlock, IPL_NONE);
mtx_init(&uvm.fpageqlock, IPL_VM);
uvm_pmr_init();
diff --git a/sys/uvm/uvm_page.h b/sys/uvm/uvm_page.h
index aaf03181c81..1300b3b96b9 100644
--- a/sys/uvm/uvm_page.h
+++ b/sys/uvm/uvm_page.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_page.h,v 1.59 2015/08/21 16:04:35 visa Exp $ */
+/* $OpenBSD: uvm_page.h,v 1.60 2015/10/08 15:58:38 kettenis Exp $ */
/* $NetBSD: uvm_page.h,v 1.19 2000/12/28 08:24:55 chs Exp $ */
/*
@@ -285,8 +285,8 @@ int vm_physseg_find(paddr_t, int *);
* macros
*/
-#define uvm_lock_pageq() /* lock */
-#define uvm_unlock_pageq() /* unlock */
+#define uvm_lock_pageq() mtx_enter(&uvm.pageqlock)
+#define uvm_unlock_pageq() mtx_leave(&uvm.pageqlock)
#define uvm_lock_fpageq() mtx_enter(&uvm.fpageqlock)
#define uvm_unlock_fpageq() mtx_leave(&uvm.fpageqlock)
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index ea8961703e0..15dba9c4e6a 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.76 2015/08/21 16:04:35 visa Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.77 2015/10/08 15:58:38 kettenis Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -237,7 +237,9 @@ uvm_pageout(void *arg)
if (uvmexp.free - BUFPAGES_DEFICIT < uvmexp.freetarg)
size += uvmexp.freetarg - (uvmexp.free -
BUFPAGES_DEFICIT);
+ uvm_unlock_pageq();
(void) bufbackoff(&constraint, size * 2);
+ uvm_lock_pageq();
/* Scan if needed to meet our targets. */
if (pma != NULL ||