usr/src/lib/libumem/common/envvar.c
changeset 13708 6d0517b1a52b
parent 6812 febeba71273d
--- a/usr/src/lib/libumem/common/envvar.c	Tue May 29 13:58:04 2012 -0700
+++ b/usr/src/lib/libumem/common/envvar.c	Tue May 29 18:11:49 2012 -0700
@@ -22,10 +22,9 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2012 Joyent, Inc. All rights reserved.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
@@ -84,6 +83,7 @@
 
 #ifndef UMEM_STANDALONE
 static arg_process_t umem_backend_process;
+static arg_process_t umem_allocator_process;
 #endif
 
 static arg_process_t umem_log_process;
@@ -100,6 +100,11 @@
 		NULL, 0, NULL, NULL,
 		&umem_backend_process
 	},
+	{ "allocator",		"Evolving",	ITEM_SPECIAL,
+		"=best, =first, =next, or =instant",
+		NULL, 0, NULL, NULL,
+		&umem_allocator_process
+	},
 #endif
 
 	{ "concurrency",	"Private",	ITEM_UINT,
@@ -473,6 +478,35 @@
 	    CURRENT, name, name, name);
 	return (ARG_BAD);
 }
+
+
+static int
+umem_allocator_process(const umem_env_item_t *item, const char *item_arg)
+{
+	const char *name = item->item_name;
+
+	if (item_arg == NULL)
+		goto fail;
+
+	if (strcmp(item_arg, "best") == 0)
+		vmem_allocator = VM_BESTFIT;
+	else if (strcmp(item_arg, "next") == 0)
+		vmem_allocator = VM_NEXTFIT;
+	else if (strcmp(item_arg, "first") == 0)
+		vmem_allocator = VM_FIRSTFIT;
+	else if (strcmp(item_arg, "instant") == 0)
+		vmem_allocator = 0;
+	else
+		goto fail;
+
+	return (ARG_SUCCESS);
+
+fail:
+	log_message("%s: %s: must be %s=best, %s=next or %s=first\n",
+	    CURRENT, name, name, name, name);
+	return (ARG_BAD);
+
+}
 #endif
 
 static int