Initial merge from Joyent including the vmem_allocator strategy additions.

This commit is contained in:
Gregory Burd 2012-03-17 11:32:48 -04:00
parent 5cc22b9326
commit f8c1c0e968
20 changed files with 2261 additions and 2179 deletions

View file

@ -22,9 +22,10 @@
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2012 Joyent, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc. *
* Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
*/ */
/* #pragma ident "@(#)envvar.c 1.5 05/06/08 SMI" */ /* #pragma ident "@(#)envvar.c 1.5 05/06/08 SMI" */
@ -91,6 +92,7 @@ typedef struct umem_env_item {
#ifndef UMEM_STANDALONE #ifndef UMEM_STANDALONE
static arg_process_t umem_backend_process; static arg_process_t umem_backend_process;
static arg_process_t umem_allocator_process;
#endif #endif
#ifdef __GLIBC__ #ifdef __GLIBC__
@ -127,6 +129,11 @@ static umem_env_item_t umem_options_items[] = {
NULL, 0, NULL, NULL, NULL, 0, NULL, NULL,
&umem_backend_process &umem_backend_process
}, },
{ "allocator", "Evolving", ITEM_SPECIAL,
"=best, =first, =next, or =instant",
NULL, 0, NULL, NULL,
&umem_allocator_process
},
#endif #endif
{ "concurrency", "Private", ITEM_UINT, { "concurrency", "Private", ITEM_UINT,
@ -501,6 +508,35 @@ fail:
CURRENT, name, name, name); CURRENT, name, name, name);
return (ARG_BAD); 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 #endif
static int static int

View file

@ -20,7 +20,7 @@
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ */
/* /*

View file

@ -19,12 +19,12 @@
* *
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)init_lib.c 1.2 05/06/08 SMI" */ /* #pragma ident "@(#)init_lib.c 1.2 05/06/08 SMI" */

View file

@ -19,8 +19,9 @@
* *
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ */

View file

@ -19,8 +19,9 @@
* *
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ */
@ -431,5 +432,3 @@ realloc(void *buf_arg, size_t newsize)
free(buf_arg); free(buf_arg);
return (buf); return (buf);
} }

6
misc.c
View file

@ -19,12 +19,12 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)misc.c 1.6 05/06/08 SMI" */ /* #pragma ident "@(#)misc.c 1.6 05/06/08 SMI" */

8
misc.h
View file

@ -19,12 +19,12 @@
* *
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
#ifndef _MISC_H #ifndef _MISC_H

View file

@ -19,8 +19,9 @@
* *
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ */

View file

@ -22,9 +22,8 @@
/* /*
* Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
#ifndef _SYS_VMEM_IMPL_USER_H #ifndef _SYS_VMEM_IMPL_USER_H

4304
umem.c

File diff suppressed because it is too large Load diff

View file

@ -22,9 +22,8 @@
/* /*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)umem_agent_support.c 1.2 05/06/08 SMI" */ /* #pragma ident "@(#)umem_agent_support.c 1.2 05/06/08 SMI" */

View file

@ -20,7 +20,7 @@
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ */

View file

@ -19,12 +19,12 @@
* *
* CDDL HEADER END * 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. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)umem_fail.c 1.4 05/06/08 SMI" */ /* #pragma ident "@(#)umem_fail.c 1.4 05/06/08 SMI" */

View file

@ -21,10 +21,11 @@
*/ */
/* /*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
*
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
#ifndef _UMEM_IMPL_H #ifndef _UMEM_IMPL_H
@ -374,7 +375,7 @@ typedef struct umem_cpu {
uint32_t cpu_number; uint32_t cpu_number;
} umem_cpu_t; } 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 8 /* min guaranteed alignment */
#define UMEM_ALIGN_SHIFT 3 /* log2(UMEM_ALIGN) */ #define UMEM_ALIGN_SHIFT 3 /* log2(UMEM_ALIGN) */

View file

@ -18,12 +18,12 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)umem_update_thread.c 1.2 05/06/08 SMI" */ /* #pragma ident "@(#)umem_update_thread.c 1.2 05/06/08 SMI" */

4
vmem.c
View file

@ -18,9 +18,12 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
*/ */
/* #pragma ident "@(#)vmem.c 1.10 05/06/08 SMI" */ /* #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 hb;
int flist = 0; int flist = 0;
uint32_t mtbf; uint32_t mtbf;
vmflag |= vmem_allocator;
if (size - 1 < vmp->vm_qcache_max) { if (size - 1 < vmp->vm_qcache_max) {
ASSERT(vmflag & VM_NOSLEEP); ASSERT(vmflag & VM_NOSLEEP);

View file

@ -18,9 +18,12 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * 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" */ /* #pragma ident "@(#)vmem_base.c 1.6 05/06/08 SMI" */
@ -31,6 +34,7 @@
#include "umem_base.h" #include "umem_base.h"
uint_t vmem_backend = 0; uint_t vmem_backend = 0;
uint_t vmem_allocator = VM_BESTFIT;
vmem_t * vmem_t *
vmem_heap_arena(vmem_alloc_t **allocp, vmem_free_t **freep) vmem_heap_arena(vmem_alloc_t **allocp, vmem_free_t **freep)

View file

@ -21,6 +21,8 @@
/* /*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*
* Portions Copyright 2012 Joyent, Inc. All rights reserved.
*/ */
#ifndef _VMEM_BASE_H #ifndef _VMEM_BASE_H
@ -66,6 +68,8 @@ extern uint_t vmem_backend;
#define VMEM_BACKEND_MMAP 0x0000002 #define VMEM_BACKEND_MMAP 0x0000002
#define VMEM_BACKEND_STAND 0x0000003 #define VMEM_BACKEND_STAND 0x0000003
extern uint_t vmem_allocator;
extern vmem_t *vmem_heap; extern vmem_t *vmem_heap;
extern vmem_alloc_t *vmem_heap_alloc; extern vmem_alloc_t *vmem_heap_alloc;
extern vmem_free_t *vmem_heap_free; extern vmem_free_t *vmem_heap_free;

View file

@ -18,12 +18,12 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)vmem_mmap.c 1.2 05/06/08 SMI" */ /* #pragma ident "@(#)vmem_mmap.c 1.2 05/06/08 SMI" */

View file

@ -18,12 +18,12 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ *
/* * Portions Copyright 2006-2008 Message Systems, Inc. All rights reserved.
* Portions Copyright 2006-2008 Message Systems, Inc.
*/ */
/* #pragma ident "@(#)vmem_sbrk.c 1.4 05/06/08 SMI" */ /* #pragma ident "@(#)vmem_sbrk.c 1.4 05/06/08 SMI" */