summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2012-01-16 21:02:17 +0000
committerRobert Mustacchi <rm@joyent.com>2012-01-16 21:41:31 +0000
commit3c0c7a22cb3d25a40343dbabea38c3fe481213d1 (patch)
treed6717044e4e2cca1fc8a19b2e8017b148a5d6c5f
parentd39078e5cb9b528444b623c311246974e752e476 (diff)
downloadillumos-joyent-3c0c7a22cb3d25a40343dbabea38c3fe481213d1.tar.gz
OS-878 libumem should allow you to specify an allocator
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Bryan Cantrill <bryan@joyent.com>
-rw-r--r--usr/src/lib/libumem/common/envvar.c38
-rw-r--r--usr/src/lib/libumem/common/vmem.c2
-rw-r--r--usr/src/lib/libumem/common/vmem_base.c4
-rw-r--r--usr/src/lib/libumem/common/vmem_base.h5
4 files changed, 43 insertions, 6 deletions
diff --git a/usr/src/lib/libumem/common/envvar.c b/usr/src/lib/libumem/common/envvar.c
index 949d33ce16..fc3d490a01 100644
--- a/usr/src/lib/libumem/common/envvar.c
+++ b/usr/src/lib/libumem/common/envvar.c
@@ -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 @@ typedef struct umem_env_item {
#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 @@ static umem_env_item_t umem_options_items[] = {
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 @@ fail:
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
diff --git a/usr/src/lib/libumem/common/vmem.c b/usr/src/lib/libumem/common/vmem.c
index 040517a78f..c868e42977 100644
--- a/usr/src/lib/libumem/common/vmem.c
+++ b/usr/src/lib/libumem/common/vmem.c
@@ -22,6 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Joyent, Inc. All rights reserved.
*/
/*
@@ -1069,6 +1070,7 @@ vmem_alloc(vmem_t *vmp, size_t size, int vmflag)
int hb;
int flist = 0;
uint32_t mtbf;
+ vmflag |= vmem_allocator;
if (size - 1 < vmp->vm_qcache_max) {
ASSERT(vmflag & VM_NOSLEEP);
diff --git a/usr/src/lib/libumem/common/vmem_base.c b/usr/src/lib/libumem/common/vmem_base.c
index 6b1c07e1ba..d64f6362d6 100644
--- a/usr/src/lib/libumem/common/vmem_base.c
+++ b/usr/src/lib/libumem/common/vmem_base.c
@@ -22,14 +22,14 @@
/*
* 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 "vmem_base.h"
#include "umem_base.h"
uint_t vmem_backend = 0;
+uint_t vmem_allocator = 0;
vmem_t *
vmem_heap_arena(vmem_alloc_t **allocp, vmem_free_t **freep)
diff --git a/usr/src/lib/libumem/common/vmem_base.h b/usr/src/lib/libumem/common/vmem_base.h
index 46ed397343..a585520e0b 100644
--- a/usr/src/lib/libumem/common/vmem_base.h
+++ b/usr/src/lib/libumem/common/vmem_base.h
@@ -21,13 +21,12 @@
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Joyent, Inc. All rights reserved.
*/
#ifndef _VMEM_BASE_H
#define _VMEM_BASE_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/vmem.h>
#include <umem.h>
@@ -66,6 +65,8 @@ extern uint_t vmem_backend;
#define VMEM_BACKEND_MMAP 0x0000002
#define VMEM_BACKEND_STAND 0x0000003
+extern uint_t vmem_allocator;
+
extern vmem_t *vmem_heap;
extern vmem_alloc_t *vmem_heap_alloc;
extern vmem_free_t *vmem_heap_free;