From f516131b3cdc4a00d4665ce4b60d8b7cd6964b63 Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Sat, 8 Aug 2009 13:44:00 +0000 Subject: fix the page daemon to back off the buffer cache correctly even in the case where we are below the inactive page target. This fixes a problem with a large buffer cache on low memory machines where the the page daemon would woken up, however the buffer cache would never be backed off because we were below the inactive page target, which could result in constant paging and basically a livelock condition. ok oga@ art@ --- sys/uvm/uvm_pdaemon.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sys/uvm') diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 000ef14d0a2..483ac2ae6ba 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.53 2009/08/02 16:28:40 beck Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.54 2009/08/08 13:43:59 beck Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -212,6 +212,7 @@ uvm_pageout(void *arg) */ for (;;) { + int scanned = 0; uvm_lock_fpageq(); UVMHIST_LOG(pdhist," <>",0,0,0,0); msleep(&uvm.pagedaemon, &uvm.fpageqlock, PVM | PNORELOCK, @@ -241,13 +242,18 @@ uvm_pageout(void *arg) /* * get pages from the buffer cache, or scan if needed */ - if (uvmexp.inactive < uvmexp.inactarg) - uvmpd_scan(); - else if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) { - if (bufbackoff() == -1) + if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) { + if (bufbackoff() == -1) { uvmpd_scan(); + scanned = 1; + } else + scanned = 0; } + if (!scanned && (uvmexp.inactive < uvmexp.inactarg)) + uvmpd_scan(); + + /* * if there's any free memory to be had, * wake up any waiters. -- cgit v1.2.3