Cross Reference: vmem_impl_user.h
xref
: /
osnet-11
/
usr
/
src
/
lib
/
libumem
/
common
/
sys
/
vmem_impl_user.h
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
2
N/A
/*
2
N/A
* CDDL HEADER START
2
N/A
*
2
N/A
* The contents of this file are subject to the terms of the
2
N/A
* Common Development and Distribution License (the "License").
2
N/A
* You may not use this file except in compliance with the License.
2
N/A
*
2
N/A
* You can obtain a copy of the license at
usr
/
src
/
OPENSOLARIS.LICENSE
2
N/A
* or
http://www.opensolaris.org/os/licensing
.
2
N/A
* See the License for the specific language governing permissions
2
N/A
* and limitations under the License.
2
N/A
*
2
N/A
* When distributing Covered Code, include this CDDL HEADER in each
2
N/A
* file and include the License file at
usr
/
src
/
OPENSOLARIS.LICENSE
.
2
N/A
* If applicable, add the following below this CDDL HEADER, with the
2
N/A
* fields enclosed by brackets "[]" replaced with your own identifying
2
N/A
* information: Portions Copyright [yyyy] [name of copyright owner]
2
N/A
*
2
N/A
* CDDL HEADER END
2
N/A
*/
2
N/A
/*
2
N/A
* Copyright (c) 1999, 2002, Oracle
and
/
or
its affiliates. All rights reserved.
2
N/A
*/
2
N/A
2
N/A
#
ifndef
_SYS_VMEM_IMPL_USER_H
2
N/A
#
define
_SYS_VMEM_IMPL_USER_H
2
N/A
2
N/A
#
include
<
sys
/
kstat.h
>
2
N/A
#
include
<
sys
/
time.h
>
2
N/A
#
include
<
sys
/
vmem.h
>
2
N/A
#
include
<
thread.h
>
2
N/A
#
include
<
synch.h
>
2
N/A
2
N/A
#
ifdef
__cplusplus
2
N/A
extern
"C"
{
2
N/A
#
endif
2
N/A
2
N/A
typedef
struct
vmem_seg
vmem_seg_t
;
2
N/A
2
N/A
#
define
VMEM_STACK_DEPTH
20
2
N/A
2
N/A
struct
vmem_seg
{
2
N/A
/*
2
N/A
* The first four fields must match vmem_freelist_t exactly.
2
N/A
*/
2
N/A
uintptr_t
vs_start
;
/* start of segment (inclusive) */
2
N/A
uintptr_t
vs_end
;
/* end of segment (exclusive) */
2
N/A
vmem_seg_t
*
vs_knext
;
/* next of kin (alloc, free, span) */
2
N/A
vmem_seg_t
*
vs_kprev
;
/* prev of kin */
2
N/A
2
N/A
vmem_seg_t
*
vs_anext
;
/* next in arena */
2
N/A
vmem_seg_t
*
vs_aprev
;
/* prev in arena */
2
N/A
uint8_t
vs_type
;
/* alloc, free, span */
2
N/A
uint8_t
vs_import
;
/* non-zero if segment was imported */
2
N/A
uint8_t
vs_depth
;
/* stack depth if UMF_AUDIT active */
2
N/A
/*
2
N/A
* The following fields are present only when UMF_AUDIT is set.
2
N/A
*/
2
N/A
thread_t
vs_thread
;
2
N/A
hrtime_t
vs_timestamp
;
2
N/A
uintptr_t
vs_stack
[
VMEM_STACK_DEPTH
];
2
N/A
};
2
N/A
2
N/A
typedef
struct
vmem_freelist
{
2
N/A
uintptr_t
vs_start
;
/* always zero */
2
N/A
uintptr_t
vs_end
;
/* segment size */
2
N/A
vmem_seg_t
*
vs_knext
;
/* next of kin */
2
N/A
vmem_seg_t
*
vs_kprev
;
/* prev of kin */
2
N/A
}
vmem_freelist_t
;
2
N/A
2
N/A
#
define
VS_SIZE
(
vsp
) ((
vsp
)->
vs_end
- (
vsp
)->
vs_start
)
2
N/A
2
N/A
/*
2
N/A
* Segment hashing
2
N/A
*/
2
N/A
#
define
VMEM_HASH_INDEX
(a, s, q, m) \
2
N/A
((((a) + ((a) >> (s)) + ((a) >> ((s) <<
1
))) >> (q)) & (m))
2
N/A
2
N/A
#
define
VMEM_HASH
(
vmp
,
addr
) \
2
N/A
(&(
vmp
)->
vm_hash_table
[
VMEM_HASH_INDEX
(
addr
, \
2
N/A
(
vmp
)->
vm_hash_shift
, (
vmp
)->
vm_qshift
, (
vmp
)->
vm_hash_mask
)])
2
N/A
2
N/A
#
define
VMEM_NAMELEN
30
2
N/A
#
define
VMEM_HASH_INITIAL
16
2
N/A
#
define
VMEM_NQCACHE_MAX
16
2
N/A
#
define
VMEM_FREELISTS
(
sizeof
(
void
*) *
8
)
2
N/A
2
N/A
typedef
struct
vmem_kstat
{
2
N/A
uint64_t
vk_mem_inuse
;
/* memory in use */
2
N/A
uint64_t
vk_mem_import
;
/* memory imported */
2
N/A
uint64_t
vk_mem_total
;
/* total memory in arena */
2
N/A
uint32_t
vk_source_id
;
/* vmem id of vmem source */
2
N/A
uint64_t
vk_alloc
;
/* number of allocations */
2
N/A
uint64_t
vk_free
;
/* number of frees */
2
N/A
uint64_t
vk_wait
;
/* number of allocations that waited */
2
N/A
uint64_t
vk_fail
;
/* number of allocations that failed */
2
N/A
uint64_t
vk_lookup
;
/* hash lookup count */
2
N/A
uint64_t
vk_search
;
/* freelist search count */
2
N/A
uint64_t
vk_populate_wait
;
/* populates that waited */
2
N/A
uint64_t
vk_populate_fail
;
/* populates that failed */
2
N/A
uint64_t
vk_contains
;
/* vmem_contains() calls */
2
N/A
uint64_t
vk_contains_search
;
/* vmem_contains() search cnt */
2
N/A
}
vmem_kstat_t
;
2
N/A
2
N/A
struct
vmem
{
2
N/A
char
vm_name
[
VMEM_NAMELEN
];
/* arena name */
2
N/A
cond_t
vm_cv
;
/* cv for blocking allocations */
2
N/A
mutex_t
vm_lock
;
/* arena lock */
2
N/A
uint32_t
vm_id
;
/* vmem id */
2
N/A
uint32_t
vm_mtbf
;
/* induced alloc failure rate */
2
N/A
int
vm_cflags
;
/* arena creation flags */
2
N/A
int
vm_qshift
;
/* log2(vm_quantum) */
2
N/A
size_t
vm_quantum
;
/* vmem quantum */
2
N/A
size_t
vm_qcache_max
;
/* maximum size to front by umem */
2
N/A
vmem_alloc_t
*
vm_source_alloc
;
2
N/A
vmem_free_t
*
vm_source_free
;
2
N/A
vmem_t
*
vm_source
;
/* vmem source for imported memory */
2
N/A
vmem_t
*
vm_next
;
/* next in vmem_list */
2
N/A
ssize_t
vm_nsegfree
;
/* number of free vmem_seg_t's */
2
N/A
vmem_seg_t
*
vm_segfree
;
/* free vmem_seg_t list */
2
N/A
vmem_seg_t
**
vm_hash_table
;
/* allocated-segment hash table */
2
N/A
size_t
vm_hash_mask
;
/* hash_size - 1 */
2
N/A
size_t
vm_hash_shift
;
/* log2(vm_hash_mask + 1) */
2
N/A
ulong_t
vm_freemap
;
/* bitmap of non-empty freelists */
2
N/A
vmem_seg_t
vm_seg0
;
/* anchor segment */
2
N/A
vmem_seg_t
vm_rotor
;
/* rotor for VM_NEXTFIT allocations */
2
N/A
vmem_seg_t
*
vm_hash0
[
VMEM_HASH_INITIAL
];
/* initial hash table */
2
N/A
void
*
vm_qcache
[
VMEM_NQCACHE_MAX
];
/* quantum caches */
2
N/A
vmem_freelist_t
vm_freelist
[
VMEM_FREELISTS
+
1
];
/* power-of-2 flists */
2
N/A
vmem_kstat_t
vm_kstat
;
/* kstat data */
2
N/A
};
2
N/A
2
N/A
/*
2
N/A
* We cannot use a mutex_t and MUTEX_HELD, since that will not work
2
N/A
* when libthread is not linked.
2
N/A
*/
2
N/A
typedef
struct
vmem_populate_lock
{
2
N/A
mutex_t
vmpl_mutex
;
2
N/A
thread_t
vmpl_thr
;
2
N/A
}
vmem_populate_lock_t
;
2
N/A
2
N/A
#
define
VM_UMFLAGS
VM_KMFLAGS
2
N/A
2
N/A
#
ifdef
__cplusplus
2
N/A
}
2
N/A
#
endif
2
N/A
2
N/A
#
endif
/* _SYS_VMEM_IMPL_USER_H */