Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jan 2014 23:35:34 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r260300 - stable/10/sys/vm
Message-ID:  <201401042335.s04NZYLN059796@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Jan  4 23:35:34 2014
New Revision: 260300
URL: http://svnweb.freebsd.org/changeset/base/260300

Log:
  MFC r258336:
  Implement soft pressure on UMA cache bucket sizes.
  
  Every time system detects low memory condition decrease bucket sizes for
  each zone by one item.  As result, higher memory pressure will push to
  smaller bucket sizes and so smaller per-CPU caches and so more efficient
  memory use.
  
  Before this change there was no force to oppose buckets growth as result
  of practically inevitable zone lock conflicts, and after some run time
  per-CPU caches could consume enough RAM to kill the system.

Modified:
  stable/10/sys/vm/uma_core.c
  stable/10/sys/vm/uma_int.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/vm/uma_core.c
==============================================================================
--- stable/10/sys/vm/uma_core.c	Sat Jan  4 23:31:34 2014	(r260299)
+++ stable/10/sys/vm/uma_core.c	Sat Jan  4 23:35:34 2014	(r260300)
@@ -702,6 +702,13 @@ bucket_cache_drain(uma_zone_t zone)
 		bucket_free(zone, bucket, NULL);
 		ZONE_LOCK(zone);
 	}
+
+	/*
+	 * Shrink further bucket sizes.  Price of single zone lock collision
+	 * is probably lower then price of global cache drain.
+	 */
+	if (zone->uz_count > zone->uz_count_min)
+		zone->uz_count--;
 }
 
 static void
@@ -1462,6 +1469,7 @@ zone_ctor(void *mem, int size, void *uda
 	zone->uz_fails = 0;
 	zone->uz_sleeps = 0;
 	zone->uz_count = 0;
+	zone->uz_count_min = 0;
 	zone->uz_flags = 0;
 	zone->uz_warning = NULL;
 	timevalclear(&zone->uz_ratecheck);
@@ -1553,6 +1561,7 @@ out:
 		zone->uz_count = bucket_select(zone->uz_size);
 	else
 		zone->uz_count = BUCKET_MAX;
+	zone->uz_count_min = zone->uz_count;
 
 	return (0);
 }

Modified: stable/10/sys/vm/uma_int.h
==============================================================================
--- stable/10/sys/vm/uma_int.h	Sat Jan  4 23:31:34 2014	(r260299)
+++ stable/10/sys/vm/uma_int.h	Sat Jan  4 23:35:34 2014	(r260300)
@@ -300,7 +300,8 @@ struct uma_zone {
 	volatile u_long	uz_fails;	/* Total number of alloc failures */
 	volatile u_long	uz_frees;	/* Total number of frees */
 	uint64_t	uz_sleeps;	/* Total number of alloc sleeps */
-	uint16_t	uz_count;	/* Highest amount of items in bucket */
+	uint16_t	uz_count;	/* Amount of items in full bucket */
+	uint16_t	uz_count_min;	/* Minimal amount of items there */
 
 	/* The next three fields are used to print a rate-limited warnings. */
 	const char	*uz_warning;	/* Warning to print on failure */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401042335.s04NZYLN059796>