4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _MTMALLOC_IMPL_H
28 #define _MTMALLOC_IMPL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Various data structures that define the guts of the mt malloc
37 #include <sys/types.h>
44 typedef struct cache
{
45 mutex_t mt_cache_lock
; /* lock for this data structure */
46 caddr_t mt_freelist
; /* free block bit mask */
47 caddr_t mt_arena
; /* addr of arena for actual dblks */
48 size_t mt_nfree
; /* how many freeblocks do we have */
49 size_t mt_size
; /* size of this cache */
50 size_t mt_span
; /* how long is this cache */
51 struct cache
*mt_next
; /* next cache in list */
52 int mt_hunks
; /* at creation time what chunk size */
55 typedef struct oversize
{
56 struct oversize
*next_bysize
;
57 struct oversize
*prev_bysize
;
58 struct oversize
*next_byaddr
;
59 struct oversize
*prev_byaddr
;
60 struct oversize
*hash_next
;
65 typedef struct cache_head
{
70 /* used to avoid false sharing, should be power-of-2 >= cache coherency size */
71 #define CACHE_COHERENCY_UNIT 64
73 #define PERCPU_SIZE CACHE_COHERENCY_UNIT
74 #define PERCPU_PAD (PERCPU_SIZE - sizeof (mutex_t) - \
75 sizeof (cache_head_t *))
77 typedef struct percpu
{
78 mutex_t mt_parent_lock
; /* used for hooking in new caches */
79 cache_head_t
*mt_caches
;
80 char mt_pad
[PERCPU_PAD
];
83 typedef uint_t (*curcpu_func
)(void);
89 * Oversize bit definitions: 3 bits to represent the oversize for
90 * head fragment, data itself, and tail fragment.
91 * If the head fragment is oversize, the first bit is on.
92 * If the data itself is oversize, the second bit is on.
93 * If the tail fragment is oversize, then the third bit is on.
95 #define NONE_OVERSIZE 0x0
96 #define HEAD_OVERSIZE 0x1
97 #define DATA_OVERSIZE 0x2
98 #define HEAD_AND_DATA_OVERSIZE 0x3
99 #define TAIL_OVERSIZE 0x4
100 #define HEAD_AND_TAIL_OVERSIZE 0x5
101 #define DATA_AND_TAIL_OVERSIZE 0x6
102 #define ALL_OVERSIZE 0x7
108 #endif /* _MTMALLOC_IMPL_H */