When considering the amount of free pages in the page daemon a small
amount is always kept for the buffer cache... except in one place.

The diff below gets rid of this exception.  This is important because
uvmpd_scan() is called conditionally using the following check:
  
  if (uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg) {
        ...
  }

So in case of swap shortage we might end up freeing fewer pages than
wanted.

ok?

Index: uvm/uvm_pdaemon.c
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_pdaemon.c,v
retrieving revision 1.98
diff -u -p -r1.98 uvm_pdaemon.c
--- uvm/uvm_pdaemon.c   4 May 2022 14:58:26 -0000       1.98
+++ uvm/uvm_pdaemon.c   5 May 2022 13:40:28 -0000
@@ -923,12 +923,13 @@ uvmpd_scan(void)
         * detect if we're not going to be able to page anything out
         * until we free some swap resources from active pages.
         */
+       free = uvmexp.free - BUFPAGES_DEFICIT;
        swap_shortage = 0;
-       if (uvmexp.free < uvmexp.freetarg &&
+       if (free < uvmexp.freetarg &&
            uvmexp.swpginuse == uvmexp.swpages &&
            !uvm_swapisfull() &&
            pages_freed == 0) {
-               swap_shortage = uvmexp.freetarg - uvmexp.free;
+               swap_shortage = uvmexp.freetarg - free;
        }
 
        for (p = TAILQ_FIRST(&uvm.page_active);

Reply via email to