uma_int.h (99072) | uma_int.h (103531) |
---|---|
1/* 2 * Copyright (c) 2002, Jeffrey Roberson <jroberson@chesapeake.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 2002, Jeffrey Roberson <jroberson@chesapeake.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/vm/uma_int.h 99072 2002-06-29 17:26:22Z julian $ | 26 * $FreeBSD: head/sys/vm/uma_int.h 103531 2002-09-18 08:26:30Z jeff $ |
27 * 28 */ 29 30/* 31 * 32 * Jeff Roberson <jroberson@chesapeake.net> 33 * 34 * This file includes definitions, structures, prototypes, and inlines that --- 63 unchanged lines hidden (view full) --- 98 * |slab header| | 99 * |___________|---* 100 * 101 */ 102 103#ifndef VM_UMA_INT_H 104#define VM_UMA_INT_H 105 | 27 * 28 */ 29 30/* 31 * 32 * Jeff Roberson <jroberson@chesapeake.net> 33 * 34 * This file includes definitions, structures, prototypes, and inlines that --- 63 unchanged lines hidden (view full) --- 98 * |slab header| | 99 * |___________|---* 100 * 101 */ 102 103#ifndef VM_UMA_INT_H 104#define VM_UMA_INT_H 105 |
106#include <sys/mutex.h> 107 | |
108#define UMA_SLAB_SIZE PAGE_SIZE /* How big are our slabs? */ 109#define UMA_SLAB_MASK (PAGE_SIZE - 1) /* Mask to get back to the page */ 110#define UMA_SLAB_SHIFT PAGE_SHIFT /* Number of bits PAGE_MASK */ 111 112#define UMA_BOOT_PAGES 30 /* Number of pages allocated for startup */ 113#define UMA_WORKING_TIME 20 /* Seconds worth of items to keep */ 114 115 --- 54 unchanged lines hidden (view full) --- 170SLIST_HEAD(slabhead, uma_slab); 171 172struct uma_hash { 173 struct slabhead *uh_slab_hash; /* Hash table for slabs */ 174 int uh_hashsize; /* Current size of the hash table */ 175 int uh_hashmask; /* Mask used during hashing */ 176}; 177 | 106#define UMA_SLAB_SIZE PAGE_SIZE /* How big are our slabs? */ 107#define UMA_SLAB_MASK (PAGE_SIZE - 1) /* Mask to get back to the page */ 108#define UMA_SLAB_SHIFT PAGE_SHIFT /* Number of bits PAGE_MASK */ 109 110#define UMA_BOOT_PAGES 30 /* Number of pages allocated for startup */ 111#define UMA_WORKING_TIME 20 /* Seconds worth of items to keep */ 112 113 --- 54 unchanged lines hidden (view full) --- 168SLIST_HEAD(slabhead, uma_slab); 169 170struct uma_hash { 171 struct slabhead *uh_slab_hash; /* Hash table for slabs */ 172 int uh_hashsize; /* Current size of the hash table */ 173 int uh_hashmask; /* Mask used during hashing */ 174}; 175 |
178extern struct uma_hash *mallochash; 179 | |
180/* 181 * Structures for per cpu queues. 182 */ 183 184/* 185 * This size was chosen so that the struct bucket size is roughly 186 * 128 * sizeof(void *). This is exactly true for x86, and for alpha 187 * it will would be 32bits smaller if it didn't have alignment adjustments. --- 81 unchanged lines hidden (view full) --- 269 270#define UMA_ZFLAG_OFFPAGE 0x0001 /* Struct slab/freelist off page */ 271#define UMA_ZFLAG_PRIVALLOC 0x0002 /* Zone has supplied it's own alloc */ 272#define UMA_ZFLAG_INTERNAL 0x0004 /* Internal zone, no offpage no PCPU */ 273#define UMA_ZFLAG_MALLOC 0x0008 /* Zone created by malloc */ 274#define UMA_ZFLAG_NOFREE 0x0010 /* Don't free data from this zone */ 275#define UMA_ZFLAG_FULL 0x0020 /* This zone reached uz_maxpages */ 276#define UMA_ZFLAG_BUCKETCACHE 0x0040 /* Only allocate buckets from cache */ | 176/* 177 * Structures for per cpu queues. 178 */ 179 180/* 181 * This size was chosen so that the struct bucket size is roughly 182 * 128 * sizeof(void *). This is exactly true for x86, and for alpha 183 * it will would be 32bits smaller if it didn't have alignment adjustments. --- 81 unchanged lines hidden (view full) --- 265 266#define UMA_ZFLAG_OFFPAGE 0x0001 /* Struct slab/freelist off page */ 267#define UMA_ZFLAG_PRIVALLOC 0x0002 /* Zone has supplied it's own alloc */ 268#define UMA_ZFLAG_INTERNAL 0x0004 /* Internal zone, no offpage no PCPU */ 269#define UMA_ZFLAG_MALLOC 0x0008 /* Zone created by malloc */ 270#define UMA_ZFLAG_NOFREE 0x0010 /* Don't free data from this zone */ 271#define UMA_ZFLAG_FULL 0x0020 /* This zone reached uz_maxpages */ 272#define UMA_ZFLAG_BUCKETCACHE 0x0040 /* Only allocate buckets from cache */ |
273#define UMA_ZFLAG_HASH 0x0080 /* Look up slab via hash */ |
|
277 278/* This lives in uflags */ 279#define UMA_ZONE_INTERNAL 0x1000 /* Internal zone for uflags */ 280 281/* Internal prototypes */ 282static __inline uma_slab_t hash_sfind(struct uma_hash *hash, u_int8_t *data); 283void *uma_large_malloc(int size, int wait); 284void uma_large_free(uma_slab_t slab); --- 56 unchanged lines hidden (view full) --- 341 342 SLIST_FOREACH(slab, &hash->uh_slab_hash[hval], us_hlink) { 343 if ((u_int8_t *)slab->us_data == data) 344 return (slab); 345 } 346 return (NULL); 347} 348 | 274 275/* This lives in uflags */ 276#define UMA_ZONE_INTERNAL 0x1000 /* Internal zone for uflags */ 277 278/* Internal prototypes */ 279static __inline uma_slab_t hash_sfind(struct uma_hash *hash, u_int8_t *data); 280void *uma_large_malloc(int size, int wait); 281void uma_large_free(uma_slab_t slab); --- 56 unchanged lines hidden (view full) --- 338 339 SLIST_FOREACH(slab, &hash->uh_slab_hash[hval], us_hlink) { 340 if ((u_int8_t *)slab->us_data == data) 341 return (slab); 342 } 343 return (NULL); 344} 345 |
346static __inline uma_slab_t 347vtoslab(vm_offset_t va) 348{ 349 vm_page_t p; 350 uma_slab_t slab; |
|
349 | 351 |
352 p = PHYS_TO_VM_PAGE(pmap_kextract(va)); 353 slab = (uma_slab_t )p->object; 354 355 if (p->flags & PG_SLAB) 356 return (slab); 357 else 358 return (NULL); 359} 360 361static __inline void 362vsetslab(vm_offset_t va, uma_slab_t slab) 363{ 364 vm_page_t p; 365 366 p = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)va)); 367 p->object = (vm_object_t)slab; 368 p->flags |= PG_SLAB; 369} 370 371static __inline void 372vsetobj(vm_offset_t va, vm_object_t obj) 373{ 374 vm_page_t p; 375 376 p = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)va)); 377 p->object = obj; 378 p->flags &= ~PG_SLAB; 379} 380 |
|
350#endif /* VM_UMA_INT_H */ | 381#endif /* VM_UMA_INT_H */ |