From c78fe96446794f71a2db7d7e3d43cb15658590a3 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Fri, 16 Sep 2016 04:39:02 +0200 Subject: VM: improve pageout deadlock workaround Commit 5dd4f67522ad0d49a2cecdb9b109251f546d4dd1 makes VM map entry allocation done with VM privilege, so that a VM map isn't held locked while physical allocations are paused, which may block the default pager during page eviction, causing a system-wide deadlock. First, it turns out that map entries aren't the only buffers allocated, and second, their number can't be easily determined, which makes a preallocation strategy very hard to implement. This change generalizes the strategy of VM privilege increase when a VM map is locked. * device/ds_routines.c (io_done_thread): Use integer values instead of booleans when setting VM privilege. * kern/thread.c (thread_init, thread_wire): Likewise. * vm/vm_pageout.c (vm_pageout): Likewise. * kern/thread.h (struct thread): Turn member `vm_privilege' into an unsigned integer. * vm/vm_map.c (vm_map_lock): New function, where VM privilege is temporarily increased. (vm_map_unlock): New function, where VM privilege is decreased. (_vm_map_entry_create): Remove VM privilege workaround from this function. * vm/vm_map.h (vm_map_lock, vm_map_unlock): Turn into functions. --- kern/thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'kern/thread.c') diff --git a/kern/thread.c b/kern/thread.c index 7db1f3d2..0ac7c535 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -342,7 +342,7 @@ void thread_init(void) /* thread_template.sched_stamp (later) */ thread_template.recover = (vm_offset_t) 0; - thread_template.vm_privilege = FALSE; + thread_template.vm_privilege = 0; thread_template.user_stop_count = 1; @@ -2233,11 +2233,11 @@ thread_wire( thread_lock(thread); if (wired) { - thread->vm_privilege = TRUE; + thread->vm_privilege = 1; stack_privilege(thread); } else { - thread->vm_privilege = FALSE; + thread->vm_privilege = 0; /*XXX stack_unprivilege(thread); */ thread->stack_privilege = 0; } -- cgit v1.2.3