Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Move A->K loan break code to uvm_loan.c.
details: https://anonhg.NetBSD.org/src/rev/161d2007ac5f
branches: trunk
changeset: 751363:161d2007ac5f
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Feb 02 06:06:02 2010 +0000
description:
Move A->K loan break code to uvm_loan.c.
diffstat:
sys/uvm/uvm_fault.c | 72 ++--------------------------------------------------
sys/uvm/uvm_loan.c | 62 ++++++++++++++++++++++++++++++++++++++++++++-
sys/uvm/uvm_loan.h | 3 +-
3 files changed, 65 insertions(+), 72 deletions(-)
diffs (204 lines):
diff -r 68a70cfd0232 -r 161d2007ac5f sys/uvm/uvm_fault.c
--- a/sys/uvm/uvm_fault.c Tue Feb 02 05:58:16 2010 +0000
+++ b/sys/uvm/uvm_fault.c Tue Feb 02 06:06:02 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_fault.c,v 1.152 2010/02/02 05:58:16 uebayasi Exp $ */
+/* $NetBSD: uvm_fault.c,v 1.153 2010/02/02 06:06:02 uebayasi Exp $ */
/*
*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.152 2010/02/02 05:58:16 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.153 2010/02/02 06:06:02 uebayasi Exp $");
#include "opt_uvmhist.h"
@@ -1462,11 +1462,6 @@
}
static int
-uvm_fault_upper_loan_break(
- struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
- struct vm_anon *anon, struct uvm_object **ruobj);
-
-static int
uvm_fault_upper_loan(
struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
struct vm_anon *anon, struct uvm_object **ruobj)
@@ -1499,7 +1494,7 @@
/* >1 case is already ok */
if (anon->an_ref == 1) {
- error = uvm_fault_upper_loan_break(ufi, flt, anon, ruobj);
+ error = uvm_loanbreak_anon(anon, ruobj);
if (error != 0) {
uvmfault_unlockall(ufi, amap, *ruobj, anon);
uvm_wait("flt_noram2");
@@ -1510,67 +1505,6 @@
return error;
}
-/* XXXUEBS consider to move this elsewhere */
-static int
-uvm_fault_upper_loan_break(
- struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
- struct vm_anon *anon, struct uvm_object **ruobj)
-{
- struct vm_page *pg;
-
- /* get new un-owned replacement page */
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (pg == NULL) {
- return ENOMEM;
- }
-
- /*
- * copy data, kill loan, and drop uobj lock
- * (if any)
- */
- /* copy old -> new */
- uvm_pagecopy(anon->an_page, pg);
-
- /* force reload */
- pmap_page_protect(anon->an_page, VM_PROT_NONE);
- mutex_enter(&uvm_pageqlock); /* KILL loan */
-
- anon->an_page->uanon = NULL;
- /* in case we owned */
- anon->an_page->pqflags &= ~PQ_ANON;
-
- if (*ruobj) {
- /* if we were receiver of loan */
- anon->an_page->loan_count--;
- } else {
- /*
- * we were the lender (A->K); need
- * to remove the page from pageq's.
- */
- uvm_pagedequeue(anon->an_page);
- }
-
- if (*ruobj) {
- mutex_exit(&(*ruobj)->vmobjlock);
- *ruobj = NULL;
- }
-
- /* install new page in anon */
- anon->an_page = pg;
- pg->uanon = anon;
- pg->pqflags |= PQ_ANON;
-
- uvm_pageactivate(pg);
- mutex_exit(&uvm_pageqlock);
-
- pg->flags &= ~(PG_BUSY|PG_FAKE);
- UVM_PAGE_OWN(pg, NULL);
-
- /* done! */
-
- return 0;
-}
-
static int
uvm_fault_upper1(
struct uvm_faultinfo *ufi, struct uvm_faultctx *flt,
diff -r 68a70cfd0232 -r 161d2007ac5f sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c Tue Feb 02 05:58:16 2010 +0000
+++ b/sys/uvm/uvm_loan.c Tue Feb 02 06:06:02 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_loan.c,v 1.74 2009/12/05 22:34:43 pooka Exp $ */
+/* $NetBSD: uvm_loan.c,v 1.75 2010/02/02 06:06:02 uebayasi Exp $ */
/*
*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.74 2009/12/05 22:34:43 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.75 2010/02/02 06:06:02 uebayasi Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1182,3 +1182,61 @@
return pg;
}
+
+int
+uvm_loanbreak_anon(struct vm_anon *anon, struct uvm_object **ruobj)
+{
+ struct vm_page *pg;
+
+ /* get new un-owned replacement page */
+ pg = uvm_pagealloc(NULL, 0, NULL, 0);
+ if (pg == NULL) {
+ return ENOMEM;
+ }
+
+ /*
+ * copy data, kill loan, and drop uobj lock
+ * (if any)
+ */
+ /* copy old -> new */
+ uvm_pagecopy(anon->an_page, pg);
+
+ /* force reload */
+ pmap_page_protect(anon->an_page, VM_PROT_NONE);
+ mutex_enter(&uvm_pageqlock); /* KILL loan */
+
+ anon->an_page->uanon = NULL;
+ /* in case we owned */
+ anon->an_page->pqflags &= ~PQ_ANON;
+
+ if (*ruobj) {
+ /* if we were receiver of loan */
+ anon->an_page->loan_count--;
+ } else {
+ /*
+ * we were the lender (A->K); need
+ * to remove the page from pageq's.
+ */
+ uvm_pagedequeue(anon->an_page);
+ }
+
+ if (*ruobj) {
+ mutex_exit(&(*ruobj)->vmobjlock);
+ *ruobj = NULL;
+ }
+
+ /* install new page in anon */
+ anon->an_page = pg;
+ pg->uanon = anon;
+ pg->pqflags |= PQ_ANON;
+
+ uvm_pageactivate(pg);
+ mutex_exit(&uvm_pageqlock);
+
+ pg->flags &= ~(PG_BUSY|PG_FAKE);
+ UVM_PAGE_OWN(pg, NULL);
+
+ /* done! */
+
+ return 0;
+}
diff -r 68a70cfd0232 -r 161d2007ac5f sys/uvm/uvm_loan.h
--- a/sys/uvm/uvm_loan.h Tue Feb 02 05:58:16 2010 +0000
+++ b/sys/uvm/uvm_loan.h Tue Feb 02 06:06:02 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_loan.h,v 1.14 2005/12/11 12:25:29 christos Exp $ */
+/* $NetBSD: uvm_loan.h,v 1.15 2010/02/02 06:06:02 uebayasi Exp $ */
/*
*
@@ -56,6 +56,7 @@
int uvm_loanuobjpages(struct uvm_object *, voff_t, int,
struct vm_page **);
struct vm_page *uvm_loanbreak(struct vm_page *);
+int uvm_loanbreak_anon(struct vm_anon *, struct uvm_object **);
#endif /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index