Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/yamt-pagecache]: src/sys - fix page loaning XXX make O->A loaning further
details: https://anonhg.NetBSD.org/src/rev/2a5c48509f4a
branches: yamt-pagecache
changeset: 770836:2a5c48509f4a
user: yamt <yamt%NetBSD.org@localhost>
date: Sun Nov 20 10:52:33 2011 +0000
description:
- fix page loaning XXX make O->A loaning further
- add some statistics
diffstat:
sys/kern/init_main.c | 8 +--
sys/uvm/uvm.h | 15 +++++-
sys/uvm/uvm_extern.h | 16 ++++++-
sys/uvm/uvm_init.c | 14 +++++-
sys/uvm/uvm_loan.c | 108 +++++++++++++++++++++++++++++++--------------
sys/uvm/uvm_meter.c | 21 ++++++++-
sys/uvm/uvm_page.c | 56 +++++++++++++----------
sys/uvm/uvm_page.h | 6 ++-
sys/uvm/uvm_page_status.c | 27 ++++++++--
9 files changed, 193 insertions(+), 78 deletions(-)
diffs (truncated from 707 to 300 lines):
diff -r b2c52e3e6f82 -r 2a5c48509f4a sys/kern/init_main.c
--- a/sys/kern/init_main.c Sun Nov 20 10:49:20 2011 +0000
+++ b/sys/kern/init_main.c Sun Nov 20 10:52:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.436.2.1 2011/11/02 21:53:59 yamt Exp $ */
+/* $NetBSD: init_main.c,v 1.436.2.2 2011/11/20 10:52:33 yamt Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.436.2.1 2011/11/02 21:53:59 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.436.2.2 2011/11/20 10:52:33 yamt Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@@ -324,10 +324,6 @@
percpu_init();
- /* Initialize lock caches. */
- mutex_obj_init();
- rw_obj_init();
-
/* Passive serialization. */
pserialize_init();
diff -r b2c52e3e6f82 -r 2a5c48509f4a sys/uvm/uvm.h
--- a/sys/uvm/uvm.h Sun Nov 20 10:49:20 2011 +0000
+++ b/sys/uvm/uvm.h Sun Nov 20 10:52:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm.h,v 1.62.4.2 2011/11/12 02:54:04 yamt Exp $ */
+/* $NetBSD: uvm.h,v 1.62.4.3 2011/11/20 10:52:33 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -88,6 +88,19 @@
* [1] anonymous (PQ_SWAPBACKED)
*/
int64_t pagestate[2][UVM_PAGE_NUM_STATUS];
+
+ int64_t loan_obj; /* O->K loan */
+ int64_t unloan_obj; /* O->K unloan */
+ int64_t loanbreak_obj; /* O->K loan resolved on write */
+ int64_t loanfree_obj; /* O->K loan resolved on free */
+
+ int64_t loan_anon; /* A->K loan */
+ int64_t unloan_anon; /* A->K unloan */
+ int64_t loanbreak_anon; /* A->K loan resolved on write */
+ int64_t loanfree_anon; /* A->K loan resolved on free */
+
+ int64_t loan_zero; /* O->K loan (zero) */
+ int64_t unloan_zero; /* O->K unloan (zero) */
};
/*
diff -r b2c52e3e6f82 -r 2a5c48509f4a sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Sun Nov 20 10:49:20 2011 +0000
+++ b/sys/uvm/uvm_extern.h Sun Nov 20 10:52:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.176.2.3 2011/11/14 14:24:54 yamt Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.176.2.4 2011/11/20 10:52:33 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -456,12 +456,26 @@
int64_t colorhit;
int64_t colormiss;
int64_t ncolors;
+
int64_t possiblydirtypages;
int64_t cleanpages;
int64_t dirtypages;
int64_t possiblydirtyanonpages;
int64_t cleananonpages;
int64_t dirtyanonpages;
+
+ int64_t loan_obj; /* O->K loan */
+ int64_t unloan_obj; /* O->K unloan */
+ int64_t loanbreak_obj; /* O->K loan resolved on write */
+ int64_t loanfree_obj; /* O->K loan resolved on free */
+
+ int64_t loan_anon; /* A->K loan */
+ int64_t unloan_anon; /* A->K unloan */
+ int64_t loanbreak_anon; /* A->K loan resolved on write */
+ int64_t loanfree_anon; /* A->K loan resolved on free */
+
+ int64_t loan_zero; /* O->K loan (zero) */
+ int64_t unloan_zero; /* O->K unloan (zero) */
};
#ifdef _KERNEL
diff -r b2c52e3e6f82 -r 2a5c48509f4a sys/uvm/uvm_init.c
--- a/sys/uvm/uvm_init.c Sun Nov 20 10:49:20 2011 +0000
+++ b/sys/uvm/uvm_init.c Sun Nov 20 10:52:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_init.c,v 1.41 2011/04/24 03:56:50 rmind Exp $ */
+/* $NetBSD: uvm_init.c,v 1.41.4.1 2011/11/20 10:52:33 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.41 2011/04/24 03:56:50 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.41.4.1 2011/11/20 10:52:33 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -42,6 +42,8 @@
#include <sys/resourcevar.h>
#include <sys/kmem.h>
#include <sys/mman.h>
+#include <sys/mutex.h>
+#include <sys/rwlock.h>
#include <sys/vnode.h>
#include <uvm/uvm.h>
@@ -157,7 +159,15 @@
kmem_init();
/*
+ * Initialize lock caches.
+ */
+
+ mutex_obj_init();
+ rw_obj_init();
+
+ /*
* Initialize the uvm_loan() facility.
+ * REQUIRE: mutex_obj_init
*/
uvm_loan_init();
diff -r b2c52e3e6f82 -r 2a5c48509f4a sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c Sun Nov 20 10:49:20 2011 +0000
+++ b/sys/uvm/uvm_loan.c Sun Nov 20 10:52:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_loan.c,v 1.81.2.3 2011/11/18 00:57:33 yamt Exp $ */
+/* $NetBSD: uvm_loan.c,v 1.81.2.4 2011/11/20 10:52:33 yamt 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.81.2.3 2011/11/18 00:57:33 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.81.2.4 2011/11/20 10:52:33 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -340,6 +340,7 @@
uvm_loananon(struct uvm_faultinfo *ufi, void ***output, int flags,
struct vm_anon *anon)
{
+ struct uvm_cpu *ucpu;
struct vm_page *pg;
int error;
@@ -428,6 +429,11 @@
/* unlock and return success */
if (pg->uobject)
mutex_exit(pg->uobject->vmobjlock);
+
+ ucpu = uvm_cpu_get();
+ ucpu->loan_anon++;
+ uvm_cpu_put(ucpu);
+
UVMHIST_LOG(loanhist, "->K done", 0,0,0,0);
return (1);
}
@@ -444,6 +450,7 @@
static int
uvm_loanpage(struct vm_page **pgpp, int npages)
{
+ struct uvm_cpu *ucpu;
int i;
int error = 0;
@@ -475,15 +482,20 @@
uvm_page_unbusy(pgpp, npages);
- if (error) {
- /*
- * backout what we've done
- */
- kmutex_t *slock = pgpp[0]->uobject->vmobjlock;
+ if (i > 0) {
+ ucpu = uvm_cpu_get();
+ ucpu->loan_obj += i;
+ uvm_cpu_put(ucpu);
+ if (error) {
+ /*
+ * backout what we've done
+ */
+ kmutex_t *slock = pgpp[0]->uobject->vmobjlock;
- mutex_exit(slock);
- uvm_unloan(pgpp, i, UVM_LOAN_TOPAGE);
- mutex_enter(slock);
+ mutex_exit(slock);
+ uvm_unloan(pgpp, i, UVM_LOAN_TOPAGE);
+ mutex_enter(slock);
+ }
}
UVMHIST_LOG(loanhist, "done %d", error,0,0,0);
@@ -829,7 +841,6 @@
*/
static struct uvm_object uvm_loanzero_object;
-static kmutex_t uvm_loanzero_lock;
static int
uvm_loanzero(struct uvm_faultinfo *ufi, void ***output, int flags)
@@ -871,12 +882,17 @@
}
if ((flags & UVM_LOAN_TOANON) == 0) { /* loaning to kernel-page */
+ struct uvm_cpu *ucpu;
+
mutex_enter(&uvm_pageqlock);
pg->loan_count++;
mutex_exit(&uvm_pageqlock);
mutex_exit(uvm_loanzero_object.vmobjlock);
**output = pg;
(*output)++;
+ ucpu = uvm_cpu_get();
+ ucpu->loan_zero++;
+ uvm_cpu_put(ucpu);
return (1);
}
@@ -965,6 +981,10 @@
mutex_enter(&uvm_pageqlock);
while (npages-- > 0) {
+ struct uvm_object *obj;
+ struct vm_anon *anon;
+ struct uvm_cpu *ucpu;
+
pg = *ploans++;
/*
@@ -998,22 +1018,35 @@
* an anon) or free it (if the page is now unowned).
*/
+ obj = pg->uobject;
+ anon = pg->uanon;
KASSERT(pg->loan_count > 0);
pg->loan_count--;
- if (pg->uobject == NULL && pg->uanon != NULL &&
+ if (obj == NULL && anon != NULL &&
(pg->pqflags & PQ_ANON) == 0) {
KASSERT(pg->loan_count > 0);
pg->loan_count--;
pg->pqflags |= PQ_ANON;
}
- if (pg->loan_count == 0 && pg->uobject == NULL &&
- pg->uanon == NULL) {
+ if (pg->loan_count == 0 && obj == NULL && anon == NULL) {
KASSERT((pg->flags & PG_BUSY) == 0);
uvm_pagefree(pg);
}
if (slock != NULL) {
mutex_exit(slock);
}
+ ucpu = uvm_cpu_get();
+ if (obj != NULL) {
+ KASSERT(anon == NULL); /* XXX no O->A loan */
+ if (obj == &uvm_loanzero_object) {
+ ucpu->unloan_zero++;
+ } else {
+ ucpu->unloan_obj++;
+ }
+ } else if (anon != NULL) {
+ ucpu->unloan_anon++;
+ }
+ uvm_cpu_put(ucpu);
}
mutex_exit(&uvm_pageqlock);
}
@@ -1087,10 +1120,7 @@
uvm_loan_init(void)
{
- mutex_init(&uvm_loanzero_lock, MUTEX_DEFAULT, IPL_NONE);
- uvm_obj_init(&uvm_loanzero_object, &ulz_pager, false, 0);
- uvm_obj_setlock(&uvm_loanzero_object, &uvm_loanzero_lock);
-
+ uvm_obj_init(&uvm_loanzero_object, &ulz_pager, true, 0);
UVMHIST_INIT(loanhist, 300);
}
Home |
Main Index |
Thread Index |
Old Index