Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Aug 2010 14:24:00 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211396 - head/sys/vm
Message-ID:  <201008161424.o7GEO0WV000794@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Mon Aug 16 14:24:00 2010
New Revision: 211396
URL: http://svn.freebsd.org/changeset/base/211396

Log:
  Add uma_zone_get_max() to obtain the effective limit after a call
  to uma_zone_set_max().
  
  The UMA zone limit is not exactly set to the value supplied but
  rounded up to completely fill the backing store increment (a page
  normally).  This can lead to surprising situations where the number
  of elements allocated from UMA is higher than the supplied limit
  value.  The new get function reads back the effective value so that
  the supplied limit value can be adjusted to the real limit.
  
  Reviewed by:	jeffr
  MFC after:	1 week

Modified:
  head/sys/vm/uma.h
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma.h
==============================================================================
--- head/sys/vm/uma.h	Mon Aug 16 12:37:17 2010	(r211395)
+++ head/sys/vm/uma.h	Mon Aug 16 14:24:00 2010	(r211396)
@@ -459,6 +459,18 @@ int uma_zone_set_obj(uma_zone_t zone, st
 void uma_zone_set_max(uma_zone_t zone, int nitems);
 
 /*
+ * Obtains the effective limit on the number of items in a zone
+ *
+ * Arguments:
+ *	zone  The zone to obtain the effective limit from
+ *
+ * Return:
+ *	0  No limit
+ *	int  The effective limit of the zone
+ */
+int uma_zone_get_max(uma_zone_t zone);
+
+/*
  * The following two routines (uma_zone_set_init/fini)
  * are used to set the backend init/fini pair which acts on an
  * object as it becomes allocated and is placed in a slab within

Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c	Mon Aug 16 12:37:17 2010	(r211395)
+++ head/sys/vm/uma_core.c	Mon Aug 16 14:24:00 2010	(r211396)
@@ -2797,6 +2797,24 @@ uma_zone_set_max(uma_zone_t zone, int ni
 }
 
 /* See uma.h */
+int
+uma_zone_get_max(uma_zone_t zone)
+{
+	int nitems;
+	uma_keg_t keg;
+
+	ZONE_LOCK(zone);
+	keg = zone_first_keg(zone);
+	if (keg->uk_maxpages)
+		nitems = keg->uk_maxpages * keg->uk_ipers;
+	else
+		nitems = 0;
+	ZONE_UNLOCK(zone);
+
+	return (nitems);
+}
+
+/* See uma.h */
 void
 uma_zone_set_init(uma_zone_t zone, uma_init uminit)
 {



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