aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_swapout.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2018-01-01 19:27:33 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2018-01-01 19:27:33 +0000
commit9997c0481c4cab04e55cf001dde0a614decb8e8e (patch)
treebeebe0b43075cf13885470ff83e22ddb3f78651b /sys/vm/vm_swapout.c
parent133d84f4d1832aac3caebc83e9dc5e2f059f82ab (diff)
downloadsrc-9997c0481c4cab04e55cf001dde0a614decb8e8e.tar.gz
src-9997c0481c4cab04e55cf001dde0a614decb8e8e.zip
Do not let vm_daemon run unbounded.
On a load where single anonymous object consumes almost all memory on the large system, swapout code executes the iteration over the corresponding object page queue for long time, owning the map and object locks. This blocks pagedaemon which tries to lock the object, and blocks other threads in the process in vm_fault() waiting for the map lock. Handle the issue by terminating the deactivation loop if we executed too long and by yielding at the top level in vm_daemon. Reported by: peterj, pho Reviewed by: alc Tested by: pho (as part of the larger patch) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D13671
Notes
Notes: svn path=/head/; revision=327468
Diffstat (limited to 'sys/vm/vm_swapout.c')
-rw-r--r--sys/vm/vm_swapout.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/vm/vm_swapout.c b/sys/vm/vm_swapout.c
index 6e04417ae30c..62eb828cbfb2 100644
--- a/sys/vm/vm_swapout.c
+++ b/sys/vm/vm_swapout.c
@@ -203,6 +203,8 @@ vm_swapout_object_deactivate_pages(pmap_t pmap, vm_object_t first_object,
TAILQ_FOREACH(p, &object->memq, listq) {
if (pmap_resident_count(pmap) <= desired)
goto unlock_return;
+ if (should_yield())
+ goto unlock_return;
if (vm_page_busied(p))
continue;
VM_CNT_INC(v_pdpages);
@@ -516,8 +518,10 @@ again:
PRELE(p);
}
sx_sunlock(&allproc_lock);
- if (tryagain != 0 && attempts <= 10)
+ if (tryagain != 0 && attempts <= 10) {
+ maybe_yield();
goto again;
+ }
}
}