svn commit: r214881 - stable/7/sys/vm
Lawrence Stewart
lstewart at FreeBSD.org
Sat Nov 6 14:38:58 UTC 2010
Author: lstewart
Date: Sat Nov 6 14:38:57 2010
New Revision: 214881
URL: http://svn.freebsd.org/changeset/base/214881
Log:
MFC r211396 (originally committed by andre):
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.
The base code from r211396 was modified as part of this MFC in order to work
correctly on FreeBSD 7.
Reviewed by: jeffr
Modified:
stable/7/sys/vm/uma.h
stable/7/sys/vm/uma_core.c
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/vm/uma.h
==============================================================================
--- stable/7/sys/vm/uma.h Sat Nov 6 14:22:50 2010 (r214880)
+++ stable/7/sys/vm/uma.h Sat Nov 6 14:38:57 2010 (r214881)
@@ -431,6 +431,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: stable/7/sys/vm/uma_core.c
==============================================================================
--- stable/7/sys/vm/uma_core.c Sat Nov 6 14:22:50 2010 (r214880)
+++ stable/7/sys/vm/uma_core.c Sat Nov 6 14:38:57 2010 (r214881)
@@ -2521,6 +2521,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->uz_keg;
+ 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)
{
More information about the svn-src-stable
mailing list