Index: sys/vm/vm_pageout.c =================================================================== --- sys/vm/vm_pageout.c +++ sys/vm/vm_pageout.c @@ -1743,11 +1743,11 @@ void vm_pageout_oom(int shortage) { - struct proc *p, *bigproc; + struct proc *p, *pp, *bigproc; vm_offset_t size, bigsize; struct thread *td; struct vmspace *vm; - int now; + int now, wokeup; bool breakout; /* @@ -1781,11 +1781,25 @@ */ bigproc = NULL; bigsize = 0; + wokeup = 0; sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); /* + * If we find a zombie or killed process, fault in its parent to + * give a chance to collect the child exit status and cleanup. + */ + if ((p->p_state == PRS_ZOMBIE) || P_KILLED(p)) { + pp = p->p_pptr; + PROC_UNLOCK(p); + PROC_LOCK(pp); + faultin(pp); + PROC_UNLOCK(pp); + wokeup++; + continue; + } + /* * If this is a system, protected or killed process, skip it. */ if (p->p_state != PRS_NORMAL || (p->p_flag & (P_INEXEC | @@ -1855,6 +1869,14 @@ } } sx_sunlock(&allproc_lock); + /* + * If wake up calls are sent, defer killing another process. + */ + if (wokeup > 0) { + _PRELE(bigproc); + return; + } + if (bigproc != NULL) { if (vm_panic_on_oom != 0) panic("out of swap space");