svn commit: r354874 - head/sys/vm

Jeff Roberson jeff at FreeBSD.org
Wed Nov 20 01:57:34 UTC 2019


Author: jeff
Date: Wed Nov 20 01:57:33 2019
New Revision: 354874
URL: https://svnweb.freebsd.org/changeset/base/354874

Log:
  When we set OFFPAGE to limit fragmentation we should also set VTOSLAB
  so that we avoid the hashtables.  The hashtable is now only required if
  a zone is created with OFFPAGE specified initially, not internally.  This
  flag signals to UMA that it can't touch the allocated memory and so
  can't store a slab pointer in the containing page.
  
  Reviewed by:	markj
  Differential Revision:	https://reviews.freebsd.org/D22453

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c	Wed Nov 20 01:14:22 2019	(r354873)
+++ head/sys/vm/uma_core.c	Wed Nov 20 01:57:33 2019	(r354874)
@@ -585,7 +585,7 @@ zone_timeout(uma_zone_t zone)
 	uma_keg_t keg;
 	u_int slabs;
 
-	if ((zone->uz_flags & UMA_ZFLAG_CACHE) != 0)
+	if ((zone->uz_flags & UMA_ZONE_HASH) == 0)
 		goto update_wss;
 
 	keg = zone->uz_keg;
@@ -1568,7 +1568,14 @@ keg_small_init(uma_keg_t keg)
 		    "new wasted space = %d\n", keg->uk_name, keg, wastedspace,
 		    slabsize / UMA_MAX_WASTE, keg->uk_ipers,
 		    slabsize - keg->uk_ipers * keg->uk_rsize);
-		keg->uk_flags |= UMA_ZONE_OFFPAGE;
+		/*
+		 * If we had access to memory to embed a slab header we
+		 * also have a page structure to use vtoslab() instead of
+		 * hash to find slabs.  If the zone was explicitly created
+		 * OFFPAGE we can't necessarily touch the memory.
+		 */
+		if ((keg->uk_flags & UMA_ZONE_OFFPAGE) == 0)
+			keg->uk_flags |= UMA_ZONE_OFFPAGE | UMA_ZONE_VTOSLAB;
 	}
 
 	if ((keg->uk_flags & UMA_ZONE_OFFPAGE) &&
@@ -1608,7 +1615,7 @@ keg_large_init(uma_keg_t keg)
 		 * slab header.
 		 */
 		if ((keg->uk_flags & UMA_ZFLAG_INTERNAL) == 0)
-			keg->uk_flags |= UMA_ZONE_OFFPAGE;
+			keg->uk_flags |= UMA_ZONE_OFFPAGE | UMA_ZONE_VTOSLAB;
 		else
 			keg->uk_ppera++;
 	}


More information about the svn-src-head mailing list