commit 17df0c1968e3cbf69567d8e0ea97da14cd797074
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Wed Mar 25 22:42:02 2026 +0100

    pageout: evict inactive pages from various segments before active ones
    
    Otherwise we can be keeping evicting active pages from the highmem
    segment, while we may have a lot of inactive pages in other segments.

diff --git a/vm/vm_page.c b/vm/vm_page.c
index a656aa01..0becb262 100644
--- a/vm/vm_page.c
+++ b/vm/vm_page.c
@@ -2040,12 +2040,22 @@ vm_page_evict_once(boolean_t alloc_paused)
      * segments first.
      */
 
+    /* Try to evict inactive pages first */
     for (i = vm_page_segs_size - 1; i < vm_page_segs_size; i--) {
         struct vm_page_seg *seg = vm_page_seg_get(i);
 
+	/* Try to evict external pages first */
 	if (vm_page_seg_evict(seg, TRUE, FALSE, alloc_paused) ||
-	    vm_page_seg_evict(seg, FALSE, FALSE, alloc_paused) ||
-	    vm_page_seg_evict(seg, TRUE, TRUE, alloc_paused) ||
+	    vm_page_seg_evict(seg, FALSE, FALSE, alloc_paused))
+	  return TRUE;
+    }
+
+    /* Then try to evict active pages */
+    for (i = vm_page_segs_size - 1; i < vm_page_segs_size; i--) {
+        struct vm_page_seg *seg = vm_page_seg_get(i);
+
+	/* Try to evict external pages first */
+	if (vm_page_seg_evict(seg, TRUE, TRUE, alloc_paused) ||
 	    vm_page_seg_evict(seg, FALSE, TRUE, alloc_paused))
 	  return TRUE;
     }
