Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Oct 2010 04:41:45 +0000 (UTC)
From:      Lawrence Stewart <lstewart@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r213911 - in head: share/man/man9 sys/vm
Message-ID:  <201010160441.o9G4fj9K014659@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: lstewart
Date: Sat Oct 16 04:41:45 2010
New Revision: 213911
URL: http://svn.freebsd.org/changeset/base/213911

Log:
  Change uma_zone_set_max to return the effective value of "nitems" after
  rounding. The same value can also be obtained with uma_zone_get_max, but this
  change avoids a caller having to make two back-to-back calls.
  
  Sponsored by:	FreeBSD Foundation
  Reviewed by:	gnn, jhb

Modified:
  head/share/man/man9/zone.9
  head/sys/vm/uma.h
  head/sys/vm/uma_core.c

Modified: head/share/man/man9/zone.9
==============================================================================
--- head/share/man/man9/zone.9	Sat Oct 16 04:14:45 2010	(r213910)
+++ head/share/man/man9/zone.9	Sat Oct 16 04:41:45 2010	(r213911)
@@ -59,7 +59,7 @@
 .Fn uma_zfree_arg "uma_zone_t zone" "void *item" "void *arg"
 .Ft void
 .Fn uma_zdestroy "uma_zone_t zone"
-.Ft void
+.Ft int
 .Fn uma_zone_set_max "uma_zone_t zone" "int nitems"
 .Ft int
 .Fn uma_zone_get_max "uma_zone_t zone"
@@ -185,9 +185,9 @@ that can be allocated to
 The
 .Fa nitems
 argument specifies the requested upper limit number of items.
-The effective limit may end up being higher than requested, as the
-implementation will round up to ensure all memory pages allocated to the zone
-are utilised to capacity.
+The effective limit is returned to the caller, as it may end up being higher
+than requested due to the implementation rounding up to ensure all memory pages
+allocated to the zone are utilised to capacity.
 The limit applies to the total number of items in the zone, which includes
 allocated items, free items and free items in the per-cpu caches.
 On systems with more than one CPU it may not be possible to allocate

Modified: head/sys/vm/uma.h
==============================================================================
--- head/sys/vm/uma.h	Sat Oct 16 04:14:45 2010	(r213910)
+++ head/sys/vm/uma.h	Sat Oct 16 04:41:45 2010	(r213911)
@@ -452,11 +452,12 @@ int uma_zone_set_obj(uma_zone_t zone, st
  *
  * Arguments:
  *	zone  The zone to limit
+ *	nitems  The requested upper limit on the number of items allowed
  *
  * Returns:
- *	Nothing
+ *	int  The effective value of nitems after rounding up based on page size
  */
-void uma_zone_set_max(uma_zone_t zone, int nitems);
+int uma_zone_set_max(uma_zone_t zone, int nitems);
 
 /*
  * Obtains the effective limit on the number of items in a zone

Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c	Sat Oct 16 04:14:45 2010	(r213910)
+++ head/sys/vm/uma_core.c	Sat Oct 16 04:41:45 2010	(r213911)
@@ -2782,7 +2782,7 @@ zone_free_item(uma_zone_t zone, void *it
 }
 
 /* See uma.h */
-void
+int
 uma_zone_set_max(uma_zone_t zone, int nitems)
 {
 	uma_keg_t keg;
@@ -2792,8 +2792,10 @@ uma_zone_set_max(uma_zone_t zone, int ni
 	keg->uk_maxpages = (nitems / keg->uk_ipers) * keg->uk_ppera;
 	if (keg->uk_maxpages * keg->uk_ipers < nitems)
 		keg->uk_maxpages += keg->uk_ppera;
-
+	nitems = keg->uk_maxpages * keg->uk_ipers;
 	ZONE_UNLOCK(zone);
+
+	return (nitems);
 }
 
 /* See uma.h */



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