svn commit: r339968 - stable/12/sys/vm

Mark Johnston markj at FreeBSD.org
Wed Oct 31 19:28:07 UTC 2018


Author: markj
Date: Wed Oct 31 19:28:05 2018
New Revision: 339968
URL: https://svnweb.freebsd.org/changeset/base/339968

Log:
  MFC r339601, r339603:
  Swap in processes unless there's a global memory shortage.
  
  Approved by:	re (gjb)

Modified:
  stable/12/sys/vm/vm_glue.c
  stable/12/sys/vm/vm_swapout.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/vm/vm_glue.c
==============================================================================
--- stable/12/sys/vm/vm_glue.c	Wed Oct 31 19:19:13 2018	(r339967)
+++ stable/12/sys/vm/vm_glue.c	Wed Oct 31 19:28:05 2018	(r339968)
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/domainset.h>
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
@@ -298,7 +299,7 @@ vm_sync_icache(vm_map_t map, vm_offset_t va, vm_offset
 
 struct kstack_cache_entry *kstack_cache;
 static int kstack_cache_size = 128;
-static int kstacks;
+static int kstacks, kstack_domain_iter;
 static struct mtx kstack_cache_mtx;
 MTX_SYSINIT(kstack_cache, &kstack_cache_mtx, "kstkch", MTX_DEF);
 
@@ -367,6 +368,17 @@ vm_thread_new(struct thread *td, int pages)
 		printf("vm_thread_new: kstack allocation failed\n");
 		vm_object_deallocate(ksobj);
 		return (0);
+	}
+
+	/*
+	 * Ensure that kstack objects can draw pages from any memory
+	 * domain.  Otherwise a local memory shortage can block a process
+	 * swap-in.
+	 */
+	if (vm_ndomains > 1) {
+		ksobj->domain.dr_policy = DOMAINSET_RR();
+		ksobj->domain.dr_iterator =
+		    atomic_fetchadd_int(&kstack_domain_iter, 1);
 	}
 
 	atomic_add_int(&kstacks, 1);

Modified: stable/12/sys/vm/vm_swapout.c
==============================================================================
--- stable/12/sys/vm/vm_swapout.c	Wed Oct 31 19:19:13 2018	(r339967)
+++ stable/12/sys/vm/vm_swapout.c	Wed Oct 31 19:28:05 2018	(r339968)
@@ -742,7 +742,8 @@ swapper_selector(bool wkilled_only)
 /*
  * Limit swapper to swap in one non-WKILLED process in MAXSLP/2
  * interval, assuming that there is:
- * - no memory shortage;
+ * - there exists at least one domain that is not suffering from a shortage of
+ *   free memory;
  * - no parallel swap-ins;
  * - no other swap-ins in the current SWAPIN_INTERVAL.
  */
@@ -750,7 +751,7 @@ static bool
 swapper_wkilled_only(void)
 {
 
-	return (vm_page_count_min() || swap_inprogress > 0 ||
+	return (vm_page_count_min_set(&all_domains) || swap_inprogress > 0 ||
 	    (u_int)(ticks - last_swapin) < SWAPIN_INTERVAL);
 }
 


More information about the svn-src-all mailing list