1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1993-2001, 2003 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_KMEM_IMPL_H 28*0Sstevel@tonic-gate #define _SYS_KMEM_IMPL_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/kmem.h> 33*0Sstevel@tonic-gate #include <sys/vmem.h> 34*0Sstevel@tonic-gate #include <sys/thread.h> 35*0Sstevel@tonic-gate #include <sys/t_lock.h> 36*0Sstevel@tonic-gate #include <sys/time.h> 37*0Sstevel@tonic-gate #include <sys/kstat.h> 38*0Sstevel@tonic-gate #include <sys/cpuvar.h> 39*0Sstevel@tonic-gate #include <sys/systm.h> 40*0Sstevel@tonic-gate #include <vm/page.h> 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #ifdef __cplusplus 43*0Sstevel@tonic-gate extern "C" { 44*0Sstevel@tonic-gate #endif 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate /* 47*0Sstevel@tonic-gate * kernel memory allocator: implementation-private data structures 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate #define KMF_AUDIT 0x00000001 /* transaction auditing */ 51*0Sstevel@tonic-gate #define KMF_DEADBEEF 0x00000002 /* deadbeef checking */ 52*0Sstevel@tonic-gate #define KMF_REDZONE 0x00000004 /* redzone checking */ 53*0Sstevel@tonic-gate #define KMF_CONTENTS 0x00000008 /* freed-buffer content logging */ 54*0Sstevel@tonic-gate #define KMF_STICKY 0x00000010 /* if set, override /etc/system */ 55*0Sstevel@tonic-gate #define KMF_NOMAGAZINE 0x00000020 /* disable per-cpu magazines */ 56*0Sstevel@tonic-gate #define KMF_FIREWALL 0x00000040 /* put all bufs before unmapped pages */ 57*0Sstevel@tonic-gate #define KMF_LITE 0x00000100 /* lightweight debugging */ 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate #define KMF_HASH 0x00000200 /* cache has hash table */ 60*0Sstevel@tonic-gate #define KMF_RANDOMIZE 0x00000400 /* randomize other kmem_flags */ 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate #define KMF_BUFTAG (KMF_DEADBEEF | KMF_REDZONE) 63*0Sstevel@tonic-gate #define KMF_TOUCH (KMF_BUFTAG | KMF_LITE | KMF_CONTENTS) 64*0Sstevel@tonic-gate #define KMF_RANDOM (KMF_TOUCH | KMF_AUDIT | KMF_NOMAGAZINE) 65*0Sstevel@tonic-gate #define KMF_DEBUG (KMF_RANDOM | KMF_FIREWALL) 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate #define KMEM_STACK_DEPTH 15 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate #define KMEM_FREE_PATTERN 0xdeadbeefdeadbeefULL 70*0Sstevel@tonic-gate #define KMEM_UNINITIALIZED_PATTERN 0xbaddcafebaddcafeULL 71*0Sstevel@tonic-gate #define KMEM_REDZONE_PATTERN 0xfeedfacefeedfaceULL 72*0Sstevel@tonic-gate #define KMEM_REDZONE_BYTE 0xbb 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* 75*0Sstevel@tonic-gate * Redzone size encodings for kmem_alloc() / kmem_free(). We encode the 76*0Sstevel@tonic-gate * allocation size, rather than storing it directly, so that kmem_free() 77*0Sstevel@tonic-gate * can distinguish frees of the wrong size from redzone violations. 78*0Sstevel@tonic-gate * 79*0Sstevel@tonic-gate * A size of zero is never valid. 80*0Sstevel@tonic-gate */ 81*0Sstevel@tonic-gate #define KMEM_SIZE_ENCODE(x) (251 * (x) + 1) 82*0Sstevel@tonic-gate #define KMEM_SIZE_DECODE(x) ((x) / 251) 83*0Sstevel@tonic-gate #define KMEM_SIZE_VALID(x) ((x) % 251 == 1 && (x) != 1) 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* 86*0Sstevel@tonic-gate * The bufctl (buffer control) structure keeps some minimal information 87*0Sstevel@tonic-gate * about each buffer: its address, its slab, and its current linkage, 88*0Sstevel@tonic-gate * which is either on the slab's freelist (if the buffer is free), or 89*0Sstevel@tonic-gate * on the cache's buf-to-bufctl hash table (if the buffer is allocated). 90*0Sstevel@tonic-gate * In the case of non-hashed, or "raw", caches (the common case), only 91*0Sstevel@tonic-gate * the freelist linkage is necessary: the buffer address is at a fixed 92*0Sstevel@tonic-gate * offset from the bufctl address, and the slab is at the end of the page. 93*0Sstevel@tonic-gate * 94*0Sstevel@tonic-gate * NOTE: bc_next must be the first field; raw buffers have linkage only. 95*0Sstevel@tonic-gate */ 96*0Sstevel@tonic-gate typedef struct kmem_bufctl { 97*0Sstevel@tonic-gate struct kmem_bufctl *bc_next; /* next bufctl struct */ 98*0Sstevel@tonic-gate void *bc_addr; /* address of buffer */ 99*0Sstevel@tonic-gate struct kmem_slab *bc_slab; /* controlling slab */ 100*0Sstevel@tonic-gate } kmem_bufctl_t; 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate /* 103*0Sstevel@tonic-gate * The KMF_AUDIT version of the bufctl structure. The beginning of this 104*0Sstevel@tonic-gate * structure must be identical to the normal bufctl structure so that 105*0Sstevel@tonic-gate * pointers are interchangeable. 106*0Sstevel@tonic-gate */ 107*0Sstevel@tonic-gate typedef struct kmem_bufctl_audit { 108*0Sstevel@tonic-gate struct kmem_bufctl *bc_next; /* next bufctl struct */ 109*0Sstevel@tonic-gate void *bc_addr; /* address of buffer */ 110*0Sstevel@tonic-gate struct kmem_slab *bc_slab; /* controlling slab */ 111*0Sstevel@tonic-gate kmem_cache_t *bc_cache; /* controlling cache */ 112*0Sstevel@tonic-gate hrtime_t bc_timestamp; /* transaction time */ 113*0Sstevel@tonic-gate kthread_t *bc_thread; /* thread doing transaction */ 114*0Sstevel@tonic-gate struct kmem_bufctl *bc_lastlog; /* last log entry */ 115*0Sstevel@tonic-gate void *bc_contents; /* contents at last free */ 116*0Sstevel@tonic-gate int bc_depth; /* stack depth */ 117*0Sstevel@tonic-gate pc_t bc_stack[KMEM_STACK_DEPTH]; /* pc stack */ 118*0Sstevel@tonic-gate } kmem_bufctl_audit_t; 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * A kmem_buftag structure is appended to each buffer whenever any of the 122*0Sstevel@tonic-gate * KMF_BUFTAG flags (KMF_DEADBEEF, KMF_REDZONE, KMF_VERIFY) are set. 123*0Sstevel@tonic-gate */ 124*0Sstevel@tonic-gate typedef struct kmem_buftag { 125*0Sstevel@tonic-gate uint64_t bt_redzone; /* 64-bit redzone pattern */ 126*0Sstevel@tonic-gate kmem_bufctl_t *bt_bufctl; /* bufctl */ 127*0Sstevel@tonic-gate intptr_t bt_bxstat; /* bufctl ^ (alloc/free) */ 128*0Sstevel@tonic-gate } kmem_buftag_t; 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate /* 131*0Sstevel@tonic-gate * A variant of the kmem_buftag structure used for KMF_LITE caches. 132*0Sstevel@tonic-gate * Previous callers are stored in reverse chronological order. (i.e. most 133*0Sstevel@tonic-gate * recent first) 134*0Sstevel@tonic-gate */ 135*0Sstevel@tonic-gate typedef struct kmem_buftag_lite { 136*0Sstevel@tonic-gate kmem_buftag_t bt_buftag; /* a normal buftag */ 137*0Sstevel@tonic-gate pc_t bt_history[1]; /* zero or more callers */ 138*0Sstevel@tonic-gate } kmem_buftag_lite_t; 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate #define KMEM_BUFTAG_LITE_SIZE(f) \ 141*0Sstevel@tonic-gate (offsetof(kmem_buftag_lite_t, bt_history[f])) 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate #define KMEM_BUFTAG(cp, buf) \ 144*0Sstevel@tonic-gate ((kmem_buftag_t *)((char *)(buf) + (cp)->cache_buftag)) 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate #define KMEM_BUFCTL(cp, buf) \ 147*0Sstevel@tonic-gate ((kmem_bufctl_t *)((char *)(buf) + (cp)->cache_bufctl)) 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate #define KMEM_BUF(cp, bcp) \ 150*0Sstevel@tonic-gate ((void *)((char *)(bcp) - (cp)->cache_bufctl)) 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate #define KMEM_SLAB(cp, buf) \ 153*0Sstevel@tonic-gate ((kmem_slab_t *)P2END((uintptr_t)(buf), (cp)->cache_slabsize) - 1) 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate #define KMEM_CPU_CACHE(cp) \ 156*0Sstevel@tonic-gate (kmem_cpu_cache_t *)((char *)cp + CPU->cpu_cache_offset) 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate #define KMEM_MAGAZINE_VALID(cp, mp) \ 159*0Sstevel@tonic-gate (((kmem_slab_t *)P2END((uintptr_t)(mp), PAGESIZE) - 1)->slab_cache == \ 160*0Sstevel@tonic-gate (cp)->cache_magtype->mt_cache) 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate #define KMEM_SLAB_MEMBER(sp, buf) \ 163*0Sstevel@tonic-gate ((size_t)(buf) - (size_t)(sp)->slab_base < \ 164*0Sstevel@tonic-gate (sp)->slab_cache->cache_slabsize) 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate #define KMEM_BUFTAG_ALLOC 0xa110c8edUL 167*0Sstevel@tonic-gate #define KMEM_BUFTAG_FREE 0xf4eef4eeUL 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate typedef struct kmem_slab { 170*0Sstevel@tonic-gate struct kmem_cache *slab_cache; /* controlling cache */ 171*0Sstevel@tonic-gate void *slab_base; /* base of allocated memory */ 172*0Sstevel@tonic-gate struct kmem_slab *slab_next; /* next slab on freelist */ 173*0Sstevel@tonic-gate struct kmem_slab *slab_prev; /* prev slab on freelist */ 174*0Sstevel@tonic-gate struct kmem_bufctl *slab_head; /* first free buffer */ 175*0Sstevel@tonic-gate long slab_refcnt; /* outstanding allocations */ 176*0Sstevel@tonic-gate long slab_chunks; /* chunks (bufs) in this slab */ 177*0Sstevel@tonic-gate } kmem_slab_t; 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate #define KMEM_HASH_INITIAL 64 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate #define KMEM_HASH(cp, buf) \ 182*0Sstevel@tonic-gate ((cp)->cache_hash_table + \ 183*0Sstevel@tonic-gate (((uintptr_t)(buf) >> (cp)->cache_hash_shift) & (cp)->cache_hash_mask)) 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate typedef struct kmem_magazine { 186*0Sstevel@tonic-gate void *mag_next; 187*0Sstevel@tonic-gate void *mag_round[1]; /* one or more rounds */ 188*0Sstevel@tonic-gate } kmem_magazine_t; 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate /* 191*0Sstevel@tonic-gate * The magazine types for fast per-cpu allocation 192*0Sstevel@tonic-gate */ 193*0Sstevel@tonic-gate typedef struct kmem_magtype { 194*0Sstevel@tonic-gate int mt_magsize; /* magazine size (number of rounds) */ 195*0Sstevel@tonic-gate int mt_align; /* magazine alignment */ 196*0Sstevel@tonic-gate size_t mt_minbuf; /* all smaller buffers qualify */ 197*0Sstevel@tonic-gate size_t mt_maxbuf; /* no larger buffers qualify */ 198*0Sstevel@tonic-gate kmem_cache_t *mt_cache; /* magazine cache */ 199*0Sstevel@tonic-gate } kmem_magtype_t; 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate #define KMEM_CPU_CACHE_SIZE 64 /* must be power of 2 */ 202*0Sstevel@tonic-gate #define KMEM_CPU_PAD (KMEM_CPU_CACHE_SIZE - sizeof (kmutex_t) - \ 203*0Sstevel@tonic-gate 2 * sizeof (uint64_t) - 2 * sizeof (void *) - 4 * sizeof (int)) 204*0Sstevel@tonic-gate #define KMEM_CACHE_SIZE(ncpus) \ 205*0Sstevel@tonic-gate ((size_t)(&((kmem_cache_t *)0)->cache_cpu[ncpus])) 206*0Sstevel@tonic-gate 207*0Sstevel@tonic-gate typedef struct kmem_cpu_cache { 208*0Sstevel@tonic-gate kmutex_t cc_lock; /* protects this cpu's local cache */ 209*0Sstevel@tonic-gate uint64_t cc_alloc; /* allocations from this cpu */ 210*0Sstevel@tonic-gate uint64_t cc_free; /* frees to this cpu */ 211*0Sstevel@tonic-gate kmem_magazine_t *cc_loaded; /* the currently loaded magazine */ 212*0Sstevel@tonic-gate kmem_magazine_t *cc_ploaded; /* the previously loaded magazine */ 213*0Sstevel@tonic-gate int cc_rounds; /* number of objects in loaded mag */ 214*0Sstevel@tonic-gate int cc_prounds; /* number of objects in previous mag */ 215*0Sstevel@tonic-gate int cc_magsize; /* number of rounds in a full mag */ 216*0Sstevel@tonic-gate int cc_flags; /* CPU-local copy of cache_flags */ 217*0Sstevel@tonic-gate char cc_pad[KMEM_CPU_PAD]; /* for nice alignment */ 218*0Sstevel@tonic-gate } kmem_cpu_cache_t; 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate /* 221*0Sstevel@tonic-gate * The magazine lists used in the depot. 222*0Sstevel@tonic-gate */ 223*0Sstevel@tonic-gate typedef struct kmem_maglist { 224*0Sstevel@tonic-gate kmem_magazine_t *ml_list; /* magazine list */ 225*0Sstevel@tonic-gate long ml_total; /* number of magazines */ 226*0Sstevel@tonic-gate long ml_min; /* min since last update */ 227*0Sstevel@tonic-gate long ml_reaplimit; /* max reapable magazines */ 228*0Sstevel@tonic-gate uint64_t ml_alloc; /* allocations from this list */ 229*0Sstevel@tonic-gate } kmem_maglist_t; 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate #define KMEM_CACHE_NAMELEN 31 232*0Sstevel@tonic-gate 233*0Sstevel@tonic-gate struct kmem_cache { 234*0Sstevel@tonic-gate /* 235*0Sstevel@tonic-gate * Statistics 236*0Sstevel@tonic-gate */ 237*0Sstevel@tonic-gate uint64_t cache_slab_create; /* slab creates */ 238*0Sstevel@tonic-gate uint64_t cache_slab_destroy; /* slab destroys */ 239*0Sstevel@tonic-gate uint64_t cache_slab_alloc; /* slab layer allocations */ 240*0Sstevel@tonic-gate uint64_t cache_slab_free; /* slab layer frees */ 241*0Sstevel@tonic-gate uint64_t cache_alloc_fail; /* total failed allocations */ 242*0Sstevel@tonic-gate uint64_t cache_buftotal; /* total buffers */ 243*0Sstevel@tonic-gate uint64_t cache_bufmax; /* max buffers ever */ 244*0Sstevel@tonic-gate uint64_t cache_rescale; /* # of hash table rescales */ 245*0Sstevel@tonic-gate uint64_t cache_lookup_depth; /* hash lookup depth */ 246*0Sstevel@tonic-gate uint64_t cache_depot_contention; /* mutex contention count */ 247*0Sstevel@tonic-gate uint64_t cache_depot_contention_prev; /* previous snapshot */ 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate /* 250*0Sstevel@tonic-gate * Cache properties 251*0Sstevel@tonic-gate */ 252*0Sstevel@tonic-gate char cache_name[KMEM_CACHE_NAMELEN + 1]; 253*0Sstevel@tonic-gate size_t cache_bufsize; /* object size */ 254*0Sstevel@tonic-gate size_t cache_align; /* object alignment */ 255*0Sstevel@tonic-gate int (*cache_constructor)(void *, void *, int); 256*0Sstevel@tonic-gate void (*cache_destructor)(void *, void *); 257*0Sstevel@tonic-gate void (*cache_reclaim)(void *); 258*0Sstevel@tonic-gate void *cache_private; /* opaque arg to callbacks */ 259*0Sstevel@tonic-gate vmem_t *cache_arena; /* vmem source for slabs */ 260*0Sstevel@tonic-gate int cache_cflags; /* cache creation flags */ 261*0Sstevel@tonic-gate int cache_flags; /* various cache state info */ 262*0Sstevel@tonic-gate uint32_t cache_mtbf; /* induced alloc failure rate */ 263*0Sstevel@tonic-gate uint32_t cache_pad1; /* to align cache_lock */ 264*0Sstevel@tonic-gate kstat_t *cache_kstat; /* exported statistics */ 265*0Sstevel@tonic-gate kmem_cache_t *cache_next; /* forward cache linkage */ 266*0Sstevel@tonic-gate kmem_cache_t *cache_prev; /* backward cache linkage */ 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate /* 269*0Sstevel@tonic-gate * Slab layer 270*0Sstevel@tonic-gate */ 271*0Sstevel@tonic-gate kmutex_t cache_lock; /* protects slab layer */ 272*0Sstevel@tonic-gate size_t cache_chunksize; /* buf + alignment [+ debug] */ 273*0Sstevel@tonic-gate size_t cache_slabsize; /* size of a slab */ 274*0Sstevel@tonic-gate size_t cache_bufctl; /* buf-to-bufctl distance */ 275*0Sstevel@tonic-gate size_t cache_buftag; /* buf-to-buftag distance */ 276*0Sstevel@tonic-gate size_t cache_verify; /* bytes to verify */ 277*0Sstevel@tonic-gate size_t cache_contents; /* bytes of saved content */ 278*0Sstevel@tonic-gate size_t cache_color; /* next slab color */ 279*0Sstevel@tonic-gate size_t cache_mincolor; /* maximum slab color */ 280*0Sstevel@tonic-gate size_t cache_maxcolor; /* maximum slab color */ 281*0Sstevel@tonic-gate size_t cache_hash_shift; /* get to interesting bits */ 282*0Sstevel@tonic-gate size_t cache_hash_mask; /* hash table mask */ 283*0Sstevel@tonic-gate kmem_slab_t *cache_freelist; /* slab free list */ 284*0Sstevel@tonic-gate kmem_slab_t cache_nullslab; /* end of freelist marker */ 285*0Sstevel@tonic-gate kmem_cache_t *cache_bufctl_cache; /* source of bufctls */ 286*0Sstevel@tonic-gate kmem_bufctl_t **cache_hash_table; /* hash table base */ 287*0Sstevel@tonic-gate void *cache_pad2; /* to align depot_lock */ 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate /* 290*0Sstevel@tonic-gate * Depot layer 291*0Sstevel@tonic-gate */ 292*0Sstevel@tonic-gate kmutex_t cache_depot_lock; /* protects depot */ 293*0Sstevel@tonic-gate kmem_magtype_t *cache_magtype; /* magazine type */ 294*0Sstevel@tonic-gate void *cache_pad3; /* to align cache_cpu */ 295*0Sstevel@tonic-gate kmem_maglist_t cache_full; /* full magazines */ 296*0Sstevel@tonic-gate kmem_maglist_t cache_empty; /* empty magazines */ 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate /* 299*0Sstevel@tonic-gate * Per-CPU layer 300*0Sstevel@tonic-gate */ 301*0Sstevel@tonic-gate kmem_cpu_cache_t cache_cpu[1]; /* max_ncpus actual elements */ 302*0Sstevel@tonic-gate }; 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate typedef struct kmem_cpu_log_header { 305*0Sstevel@tonic-gate kmutex_t clh_lock; 306*0Sstevel@tonic-gate char *clh_current; 307*0Sstevel@tonic-gate size_t clh_avail; 308*0Sstevel@tonic-gate int clh_chunk; 309*0Sstevel@tonic-gate int clh_hits; 310*0Sstevel@tonic-gate char clh_pad[64 - sizeof (kmutex_t) - sizeof (char *) - 311*0Sstevel@tonic-gate sizeof (size_t) - 2 * sizeof (int)]; 312*0Sstevel@tonic-gate } kmem_cpu_log_header_t; 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate typedef struct kmem_log_header { 315*0Sstevel@tonic-gate kmutex_t lh_lock; 316*0Sstevel@tonic-gate char *lh_base; 317*0Sstevel@tonic-gate int *lh_free; 318*0Sstevel@tonic-gate size_t lh_chunksize; 319*0Sstevel@tonic-gate int lh_nchunks; 320*0Sstevel@tonic-gate int lh_head; 321*0Sstevel@tonic-gate int lh_tail; 322*0Sstevel@tonic-gate int lh_hits; 323*0Sstevel@tonic-gate kmem_cpu_log_header_t lh_cpu[1]; /* ncpus actually allocated */ 324*0Sstevel@tonic-gate } kmem_log_header_t; 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gate #define KMEM_ALIGN 8 /* min guaranteed alignment */ 327*0Sstevel@tonic-gate #define KMEM_ALIGN_SHIFT 3 /* log2(KMEM_ALIGN) */ 328*0Sstevel@tonic-gate #define KMEM_VOID_FRACTION 8 /* never waste more than 1/8 of slab */ 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate #ifdef __cplusplus 331*0Sstevel@tonic-gate } 332*0Sstevel@tonic-gate #endif 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate #endif /* _SYS_KMEM_IMPL_H */ 335