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 PR kern/55032 (rump/rumpkern/t_vm:...
details: https://anonhg.NetBSD.org/src/rev/cb1659dcb090
branches: trunk
changeset: 934021:cb1659dcb090
user: ad <ad%NetBSD.org@localhost>
date: Wed Jun 03 22:25:49 2020 +0000
description:
PR kern/55032 (rump/rumpkern/t_vm:uvmwait test case now fails)
Work around issues with rump's pagedaemon emulation, including one that's
sensitive to timing effects (i.e. scheduler changes). While here tidy up
some other stuff around the emulation of page alloc/free.
diffstat:
sys/rump/librump/rumpkern/vm.c | 62 +++++++++++++----------------------------
1 files changed, 20 insertions(+), 42 deletions(-)
diffs (144 lines):
diff -r 89368ad023ec -r cb1659dcb090 sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c Wed Jun 03 22:10:24 2020 +0000
+++ b/sys/rump/librump/rumpkern/vm.c Wed Jun 03 22:25:49 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm.c,v 1.187 2020/03/17 18:31:38 ad Exp $ */
+/* $NetBSD: vm.c,v 1.188 2020/06/03 22:25:49 ad Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.187 2020/03/17 18:31:38 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.188 2020/06/03 22:25:49 ad Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -69,7 +69,6 @@
#include <rump/rumpuser.h>
kmutex_t vmpage_lruqueue_lock; /* non-free page lock */
-kmutex_t uvm_fpageqlock; /* free page lock, non-gpl license */
kmutex_t uvm_swap_data_lock;
struct uvmexp uvmexp;
@@ -172,13 +171,6 @@
pg->offset = off;
pg->uobject = uobj;
- if (UVM_OBJ_IS_VNODE(uobj) && uobj->uo_npages == 0) {
- struct vnode *vp = (struct vnode *)uobj;
- mutex_enter(vp->v_interlock);
- vp->v_iflag |= VI_PAGES;
- mutex_exit(vp->v_interlock);
- }
-
if (radix_tree_insert_node(&uobj->uo_pages, off >> PAGE_SHIFT,
pg) != 0) {
pool_cache_put(&pagecache, pg);
@@ -186,6 +178,16 @@
}
uobj->uo_npages++;
+ if (UVM_OBJ_IS_VNODE(uobj)) {
+ if (uobj->uo_npages == 0) {
+ struct vnode *vp = (struct vnode *)uobj;
+ mutex_enter(vp->v_interlock);
+ vp->v_iflag |= VI_PAGES;
+ mutex_exit(vp->v_interlock);
+ }
+ pg->flags |= PG_FILE;
+ }
+
pg->flags = PG_CLEAN|PG_BUSY|PG_FAKE;
if (flags & UVM_PGA_ZERO) {
uvm_pagezero(pg);
@@ -201,6 +203,8 @@
mutex_enter(&vmpage_lruqueue_lock);
TAILQ_INSERT_TAIL(&vmpage_lruqueue, pg, pageq.queue);
mutex_exit(&vmpage_lruqueue_lock);
+ } else {
+ pg->flags |= PG_AOBJ;
}
return pg;
@@ -220,10 +224,7 @@
KASSERT(rw_write_held(uobj->vmobjlock));
mutex_enter(&pg->interlock);
- if (pg->pqflags & PQ_WANTED) {
- pg->pqflags &= ~PQ_WANTED;
- wakeup(pg);
- }
+ uvm_pagewakeup(pg);
mutex_exit(&pg->interlock);
uobj->uo_npages--;
@@ -367,11 +368,8 @@
mutex_init(&pagermtx, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&vmpage_lruqueue_lock, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&uvm_swap_data_lock, MUTEX_DEFAULT, IPL_NONE);
+ mutex_init(&pdaemonmtx, MUTEX_DEFAULT, IPL_NONE);
- /* just to appease linkage */
- mutex_init(&uvm_fpageqlock, MUTEX_SPIN, IPL_VM);
-
- mutex_init(&pdaemonmtx, MUTEX_DEFAULT, IPL_NONE);
cv_init(&pdaemoncv, "pdaemon");
cv_init(&oomwait, "oomwait");
@@ -1141,16 +1139,14 @@
mutex_enter(&pdaemonmtx);
for (;;) {
- if (!NEED_PAGEDAEMON()) {
- kernel_map->flags &= ~VM_MAP_WANTVA;
- }
-
if (pdaemon_waiters) {
pdaemon_waiters = 0;
cv_broadcast(&oomwait);
}
-
- cv_wait(&pdaemoncv, &pdaemonmtx);
+ if (!NEED_PAGEDAEMON()) {
+ kernel_map->flags &= ~VM_MAP_WANTVA;
+ cv_wait(&pdaemoncv, &pdaemonmtx);
+ }
uvmexp.pdwoke++;
/* tell the world that we are hungry */
@@ -1202,22 +1198,6 @@
mutex_exit(&vmpage_lruqueue_lock);
/*
- * Ok, someone is running with an object lock held.
- * We want to yield the host CPU to make sure the
- * thread is not parked on the host. nanosleep
- * for the smallest possible time and hope we're back in
- * the game soon.
- */
- if (cleaned == 0) {
- rumpuser_clock_sleep(RUMPUSER_CLOCK_RELWALL, 0, 1);
-
- skip = 0;
-
- /* and here we go again */
- goto again;
- }
-
- /*
* And of course we need to reclaim the page cache
* again to actually release memory.
*/
@@ -1249,8 +1229,6 @@
mutex_enter(&pdaemonmtx);
if (!succ && cleaned == 0 && pdaemon_waiters &&
uvmexp.paging == 0) {
- rumpuser_dprintf("pagedaemoness: failed to reclaim "
- "memory ... sleeping (deadlock?)\n");
kpause("pddlk", false, hz, &pdaemonmtx);
}
}
Home |
Main Index |
Thread Index |
Old Index