svn commit: r332968 - head/sys/vm

Mark Johnston markj at FreeBSD.org
Tue Apr 24 20:05:47 UTC 2018


Author: markj
Date: Tue Apr 24 20:05:45 2018
New Revision: 332968
URL: https://svnweb.freebsd.org/changeset/base/332968

Log:
  Add a UMA zone flag to disable the use of buckets.
  
  This allows the creation of zones which don't do any caching in front of
  the keg. If the zone is a cache zone, this means that UMA will not
  attempt any memory allocations when allocating an item from the backend.
  This is intended for use after a panic by netdump, but likely has other
  applications.
  
  Reviewed by:	kib
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D15184

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

Modified: head/sys/vm/uma.h
==============================================================================
--- head/sys/vm/uma.h	Tue Apr 24 19:55:12 2018	(r332967)
+++ head/sys/vm/uma.h	Tue Apr 24 20:05:45 2018	(r332968)
@@ -265,8 +265,8 @@ uma_zone_t uma_zcache_create(char *name, int size, uma
 					 * information in the vm_page.
 					 */
 #define	UMA_ZONE_SECONDARY	0x0200	/* Zone is a Secondary Zone */
-/*				0x0400	   Unused */
-#define	UMA_ZONE_MAXBUCKET	0x0800	/* Use largest buckets */
+#define	UMA_ZONE_NOBUCKET	0x0400	/* Do not use buckets. */
+#define	UMA_ZONE_MAXBUCKET	0x0800	/* Use largest buckets. */
 #define	UMA_ZONE_CACHESPREAD	0x1000	/*
 					 * Spread memory start locations across
 					 * all possible cache lines.  May

Modified: head/sys/vm/uma_core.c
==============================================================================
--- head/sys/vm/uma_core.c	Tue Apr 24 19:55:12 2018	(r332967)
+++ head/sys/vm/uma_core.c	Tue Apr 24 20:05:45 2018	(r332968)
@@ -1681,10 +1681,15 @@ zone_ctor(void *mem, int size, void *udata, int flags)
 	}
 
 out:
-	if ((arg->flags & UMA_ZONE_MAXBUCKET) == 0)
-		zone->uz_count = bucket_select(zone->uz_size);
-	else
+	KASSERT((arg->flags & (UMA_ZONE_MAXBUCKET | UMA_ZONE_NOBUCKET)) !=
+	    (UMA_ZONE_MAXBUCKET | UMA_ZONE_NOBUCKET),
+	    ("Invalid zone flag combination"));
+	if ((arg->flags & UMA_ZONE_MAXBUCKET) != 0)
 		zone->uz_count = BUCKET_MAX;
+	else if ((arg->flags & UMA_ZONE_NOBUCKET) != 0)
+		zone->uz_count = 0;
+	else
+		zone->uz_count = bucket_select(zone->uz_size);
 	zone->uz_count_min = zone->uz_count;
 
 	return (0);


More information about the svn-src-all mailing list