Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpkern * unlock object in "error" branch
details: https://anonhg.NetBSD.org/src/rev/3cc1781d25d5
branches: trunk
changeset: 757651:3cc1781d25d5
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Sep 09 12:23:06 2010 +0000
description:
* unlock object in "error" branch
* fix typo (not in comment)
* improve indentation tailspin
diffstat:
sys/rump/librump/rumpkern/vm.c | 61 ++++++++++++++++++++++++-----------------
1 files changed, 35 insertions(+), 26 deletions(-)
diffs (121 lines):
diff -r 712853233aea -r 3cc1781d25d5 sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c Thu Sep 09 12:18:39 2010 +0000
+++ b/sys/rump/librump/rumpkern/vm.c Thu Sep 09 12:23:06 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm.c,v 1.94 2010/09/09 10:02:14 pooka Exp $ */
+/* $NetBSD: vm.c,v 1.95 2010/09/09 12:23:06 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.94 2010/09/09 10:02:14 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.95 2010/09/09 12:23:06 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -207,6 +207,7 @@
struct uvm_object *uobj = pg->uobject;
KASSERT(mutex_owned(&uvm_pageqlock));
+ KASSERT(mutex_owned(&uobj->vmobjlock));
if (pg->flags & PG_WANTED)
wakeup(pg);
@@ -815,6 +816,28 @@
/* could wakeup waiters, but just let the pagedaemon do it */
}
+static bool
+processpage(struct vm_page *pg)
+{
+ struct uvm_object *uobj;
+
+ uobj = pg->uobject;
+ if (mutex_tryenter(&uobj->vmobjlock)) {
+ if ((pg->flags & PG_BUSY) == 0) {
+ mutex_exit(&uvm_pageqlock);
+ uobj->pgops->pgo_put(uobj, pg->offset,
+ pg->offset + PAGE_SIZE,
+ PGO_CLEANIT|PGO_FREE);
+ KASSERT(!mutex_owned(&uobj->vmobjlock));
+ return true;
+ } else {
+ mutex_exit(&uobj->vmobjlock);
+ }
+ }
+
+ return false;
+}
+
/*
* The Diabolical pageDaemon Director (DDD).
*/
@@ -832,21 +855,16 @@
for (;;) {
if (succ) {
kernel_map->flags &= ~VM_MAP_WANTVA;
- kmem_map->flags &= VM_MAP_WANTVA;
+ kmem_map->flags &= ~VM_MAP_WANTVA;
timo = 0;
+ if (pdaemon_waiters) {
+ pdaemon_waiters = 0;
+ cv_broadcast(&oomwait);
+ }
}
succ = false;
- /*
- * Wake up everyone regardless of perceived success.
- * They will just resleep if we're stil out of juice.
- */
- if (pdaemon_waiters) {
- pdaemon_waiters = 0;
- cv_broadcast(&oomwait);
- }
-
- cv_timedwait(&pdaemoncv, &pdaemonmtx, 0);
+ cv_timedwait(&pdaemoncv, &pdaemonmtx, timo);
uvmexp.pdwoke++;
/* tell the world that we are hungry */
@@ -881,7 +899,6 @@
while (cleaned < PAGEDAEMON_OBJCHUNK) {
skipped = 0;
TAILQ_FOREACH(pg, &vmpage_lruqueue, pageq.queue) {
- struct uvm_object *uobj;
/*
* skip over pages we _might_ have tried
@@ -892,17 +909,9 @@
while (skipped++ < skip)
continue;
- uobj = pg->uobject;
- if (mutex_tryenter(&uobj->vmobjlock)) {
- if ((pg->flags & PG_BUSY) == 0) {
- mutex_exit(&uvm_pageqlock);
- uobj->pgops->pgo_put(uobj,
- pg->offset,
- pg->offset + PAGE_SIZE,
- PGO_CLEANIT|PGO_FREE);
- cleaned++;
- goto again;
- }
+ if (processpage(pg)) {
+ cleaned++;
+ goto again;
}
skip++;
@@ -957,7 +966,7 @@
if (!succ) {
rumpuser_dprintf("pagedaemoness: failed to reclaim "
"memory ... sleeping (deadlock?)\n");
- kpause("dpdd", false, hz, NULL);
+ timo = hz;
}
mutex_enter(&pdaemonmtx);
Home |
Main Index |
Thread Index |
Old Index