Date: Sat, 6 Nov 2010 09:56:14 +0000 (UTC) From: Lawrence Stewart <lstewart@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r214861 - stable/8/sys/vm Message-ID: <201011060956.oA69uEjn025967@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: lstewart Date: Sat Nov 6 09:56:14 2010 New Revision: 214861 URL: http://svn.freebsd.org/changeset/base/214861 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. Reviewed by: jeffr Modified: stable/8/sys/vm/uma.h stable/8/sys/vm/uma_core.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/vm/uma.h ============================================================================== --- stable/8/sys/vm/uma.h Sat Nov 6 09:42:41 2010 (r214860) +++ stable/8/sys/vm/uma.h Sat Nov 6 09:56:14 2010 (r214861) @@ -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: stable/8/sys/vm/uma_core.c ============================================================================== --- stable/8/sys/vm/uma_core.c Sat Nov 6 09:42:41 2010 (r214860) +++ stable/8/sys/vm/uma_core.c Sat Nov 6 09:56:14 2010 (r214861) @@ -2803,6 +2803,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?201011060956.oA69uEjn025967>