Initial merge from Joyent including the vmem_allocator strategy additions.
This commit is contained in:
parent
5cc22b9326
commit
f8c1c0e968
20 changed files with 2261 additions and 2179 deletions
42
envvar.c
42
envvar.c
|
@ -22,9 +22,10 @@
|
|||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)envvar.c 1.5 05/06/08 SMI" */
|
||||
|
@ -91,6 +92,7 @@ typedef struct umem_env_item {
|
|||
|
||||
#ifndef UMEM_STANDALONE
|
||||
static arg_process_t umem_backend_process;
|
||||
static arg_process_t umem_allocator_process;
|
||||
#endif
|
||||
|
||||
#ifdef __GLIBC__
|
||||
|
@ -127,6 +129,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,
|
||||
|
@ -501,6 +508,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
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)init_lib.c 1.2 05/06/08 SMI" */
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
|
|
5
malloc.c
5
malloc.c
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
|
@ -431,5 +432,3 @@ realloc(void *buf_arg, size_t newsize)
|
|||
free(buf_arg);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
6
misc.c
6
misc.c
|
@ -19,12 +19,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)misc.c 1.6 05/06/08 SMI" */
|
||||
|
|
8
misc.h
8
misc.h
|
@ -19,12 +19,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _MISC_H
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
|
|
|
@ -22,9 +22,8 @@
|
|||
/*
|
||||
* Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_VMEM_IMPL_USER_H
|
||||
|
|
42
umem.c
42
umem.c
|
@ -2,7 +2,7 @@
|
|||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License.
|
||||
* Common Development and Distribution License (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
|
@ -18,12 +18,14 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)umem.c 1.11 05/06/08 SMI" */
|
||||
|
@ -389,6 +391,17 @@
|
|||
* lh_lock
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* 7. Changing UMEM_MAXBUF
|
||||
* -----------------------
|
||||
*
|
||||
* When changing UMEM_MAXBUF extra care has to be taken. It is not sufficient to
|
||||
* simply increase this number. First, one must update the umem_alloc_table to
|
||||
* have the appropriate number of entires based upon the new size. If this is
|
||||
* not done, this will lead to libumem blowing an assertion.
|
||||
*
|
||||
* The second place to update, which is not required, is the umem_alloc_sizes.
|
||||
* These determine the default cache sizes that we're going to support.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -469,6 +482,8 @@ static int umem_alloc_sizes[] = {
|
|||
P2ALIGN(8192 / 1, 64), 9216,
|
||||
4096 * 3,
|
||||
UMEM_MAXBUF, /* = 8192 * 2 */
|
||||
24576, 32768, 40960, 49152, 57344, 65536, 73728, 81920,
|
||||
90112, 98304, 106496, 114688, 122880, UMEM_MAXBUF, /* 128k */
|
||||
/* 24 slots for user expansion */
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
@ -644,6 +659,20 @@ umem_cache_t umem_null_cache = {
|
|||
ALLOC_TABLE_64, ALLOC_TABLE_64, ALLOC_TABLE_64, ALLOC_TABLE_64
|
||||
|
||||
static umem_cache_t *umem_alloc_table[UMEM_MAXBUF >> UMEM_ALIGN_SHIFT] = {
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024,
|
||||
ALLOC_TABLE_1024
|
||||
};
|
||||
|
@ -3029,7 +3058,12 @@ umem_cache_init(void)
|
|||
* umem_startup() is called early on, and must be called explicitly if we're
|
||||
* the standalone version.
|
||||
*/
|
||||
#ifdef UMEM_STANDALONE
|
||||
void
|
||||
#else
|
||||
/* #pragma init(umem_startup) */
|
||||
static void
|
||||
#endif
|
||||
umem_startup(caddr_t start, size_t len, size_t pagesize, caddr_t minstack,
|
||||
caddr_t maxstack)
|
||||
{
|
||||
|
|
|
@ -22,9 +22,8 @@
|
|||
/*
|
||||
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)umem_agent_support.c 1.2 05/06/08 SMI" */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)umem_fail.c 1.4 05/06/08 SMI" */
|
||||
|
|
|
@ -21,10 +21,11 @@
|
|||
*/
|
||||
/*
|
||||
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _UMEM_IMPL_H
|
||||
|
@ -374,7 +375,7 @@ typedef struct umem_cpu {
|
|||
uint32_t cpu_number;
|
||||
} umem_cpu_t;
|
||||
|
||||
#define UMEM_MAXBUF 16384
|
||||
#define UMEM_MAXBUF 16384 /* Solaris/SmartOS defines this as 131072 */
|
||||
|
||||
#define UMEM_ALIGN 8 /* min guaranteed alignment */
|
||||
#define UMEM_ALIGN_SHIFT 3 /* log2(UMEM_ALIGN) */
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)umem_update_thread.c 1.2 05/06/08 SMI" */
|
||||
|
|
4
vmem.c
4
vmem.c
|
@ -18,9 +18,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)vmem.c 1.10 05/06/08 SMI" */
|
||||
|
@ -1083,6 +1086,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);
|
||||
|
|
|
@ -18,9 +18,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)vmem_base.c 1.6 05/06/08 SMI" */
|
||||
|
@ -31,6 +34,7 @@
|
|||
#include "umem_base.h"
|
||||
|
||||
uint_t vmem_backend = 0;
|
||||
uint_t vmem_allocator = VM_BESTFIT;
|
||||
|
||||
vmem_t *
|
||||
vmem_heap_arena(vmem_alloc_t **allocp, vmem_free_t **freep)
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
/*
|
||||
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*
|
||||
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _VMEM_BASE_H
|
||||
|
@ -66,6 +68,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;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)vmem_mmap.c 1.2 05/06/08 SMI" */
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
/*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc.
|
||||
*
|
||||
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #pragma ident "@(#)vmem_sbrk.c 1.4 05/06/08 SMI" */
|
||||
|
|
Loading…
Reference in a new issue