From fdc53cc7c5e423755fd5e68cf77e4cb58ce34679 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 21 Feb 2010 18:33:43 -0800 Subject: [PATCH] kernel - SWAP CACHE part 22/many - Fix counter overflow introduced in part 21 * vm_swapcache_inactive_heuristic can overflow, making it extremely negative and causing swapcache writing to cease for a long period of time. * Two-in-one fix. Check if it is too negative and reset it. This also automatically adjusts the heuristic if the sysop manually changes the hysteresis to a smaller value. --- sys/vm/vm_swapcache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/vm/vm_swapcache.c b/sys/vm/vm_swapcache.c index 790f029356..a0150882c8 100644 --- a/sys/vm/vm_swapcache.c +++ b/sys/vm/vm_swapcache.c @@ -253,11 +253,16 @@ vm_swapcache_writing(vm_page_t marker) int count; /* + * Deal with an overflow of the heuristic counter or if the user + * manually changes the hysteresis. + * * Try to avoid small incremental pageouts by waiting for enough * pages to buildup in the inactive queue to hopefully get a good * burst in. This heuristic is bumped by the VM system and reset * when our scan hits the end of the queue. */ + if (vm_swapcache_inactive_heuristic < -vm_swapcache_hysteresis) + vm_swapcache_inactive_heuristic = -vm_swapcache_hysteresis; if (vm_swapcache_inactive_heuristic < 0) return; -- 2.41.0