From d6713642cff5cc0be36b12ca27841b5a0756b2ce Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 18 May 2016 10:47:02 -0700 Subject: [PATCH 1/5] Address over-eager OOM kills Right now, vm_page_free_wakeup() and hence vm_page_free() will clear vm_pages_needed if the free page count is above v_free_min. If the pagedaemon is starved for pages (because of a runaway process or because all deactivated pages are dirty), but other threads are occasionally freeing pages, and v_free_min <= v_free_count <= pageout_wakeup_thresh, concurrent vm_page_free() and vm_page_alloc() calls will respectively clear and set vm_pages_needed, waking up the pagedaemon in the process. In the worst case, the pagedaemon reaches vm_pageout_oom_seq very quickly, leading to a spurious OOM kill in the case where all pages deactivated by the pagedaemon end up in the laundry queue. Fix this by modifying vm_page_free_wakeup() to not clear vm_pages_needed until v_free_count > pageout_wakeup_thresh. --- sys/vm/vm_page.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index ab44d26..464dc21 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2910,7 +2910,8 @@ vm_page_free_wakeup(void) * lots of memory. this process will swapin processes. */ if (vm_pages_needed && !vm_page_count_min()) { - vm_pages_needed = 0; + if (!vm_paging_needed()) + vm_pages_needed = 0; wakeup(&vm_cnt.v_free_count); } } -- 2.8.1