Page MenuHomeFreeBSD

D16610.id46384.diff
No OneTemporary

D16610.id46384.diff

Index: sys/vm/vm_swapout.c
===================================================================
--- sys/vm/vm_swapout.c
+++ sys/vm/vm_swapout.c
@@ -159,6 +159,7 @@
MTX_SYSINIT(vm_daemon, &vm_daemon_mtx, "vm daemon", MTX_DEF);
static int swapped_cnt;
+static int swap_inprogress; /* Current swap-ins done outside swapper. */
static void swapclear(struct proc *);
static int swapout(struct proc *);
@@ -634,6 +635,8 @@
sx_xlock(&allproc_lock);
MPASS(swapped_cnt > 0);
swapped_cnt--;
+ if (curthread != &thread0)
+ swap_inprogress++;
sx_xunlock(&allproc_lock);
/*
@@ -644,6 +647,12 @@
FOREACH_THREAD_IN_PROC(p, td)
vm_thread_swapin(td, oom_alloc);
+ if (curthread != &thread0) {
+ sx_xlock(&allproc_lock);
+ MPASS(swap_inprogress > 0);
+ swap_inprogress--;
+ sx_xunlock(&allproc_lock);
+ }
PROC_LOCK(p);
swapclear(p);
p->p_swtick = ticks;
@@ -721,6 +730,21 @@
}
PROC_UNLOCK(p);
}
+
+ /*
+ * If there is a parallel swapin, it happens outside the
+ * swapper thread. In this case, postpone swapping in
+ * non-WKILLED process by swapper, to avoid overloading io
+ * subsystem and because we do not know in advance if there
+ * would be enough memory for another process after that
+ * swapin ends.
+ *
+ * Note that we completed the iteration over the process list,
+ * to find all WKILLED processes requiring swaping.
+ */
+ if (swap_inprogress > 0)
+ res = NULL;
+
if (res != NULL)
PROC_LOCK(res);
return (res);

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 1:07 PM (18 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28581820
Default Alt Text
D16610.id46384.diff (1 KB)

Event Timeline