Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/uma_int.h
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | |||||
* hash table. Otherwise slabs are found with vtoslab(). | * hash table. Otherwise slabs are found with vtoslab(). | ||||
*/ | */ | ||||
#define UMA_HASH_SIZE_INIT 32 | #define UMA_HASH_SIZE_INIT 32 | ||||
#define UMA_HASH(h, s) ((((uintptr_t)s) >> UMA_SLAB_SHIFT) & (h)->uh_hashmask) | #define UMA_HASH(h, s) ((((uintptr_t)s) >> UMA_SLAB_SHIFT) & (h)->uh_hashmask) | ||||
#define UMA_HASH_INSERT(h, s, mem) \ | #define UMA_HASH_INSERT(h, s, mem) \ | ||||
LIST_INSERT_HEAD(&(h)->uh_slab_hash[UMA_HASH((h), \ | LIST_INSERT_HEAD(&(h)->uh_slab_hash[UMA_HASH((h), \ | ||||
(mem))], (uma_hash_slab_t)(s), uhs_hlink) | (mem))], slab_tohashslab(s), uhs_hlink) | ||||
#define UMA_HASH_REMOVE(h, s) \ | #define UMA_HASH_REMOVE(h, s) \ | ||||
LIST_REMOVE((uma_hash_slab_t)(s), uhs_hlink) | LIST_REMOVE(slab_tohashslab(s), uhs_hlink) | ||||
LIST_HEAD(slabhashhead, uma_hash_slab); | LIST_HEAD(slabhashhead, uma_hash_slab); | ||||
struct uma_hash { | struct uma_hash { | ||||
struct slabhashhead *uh_slab_hash; /* Hash table for slabs */ | struct slabhashhead *uh_slab_hash; /* Hash table for slabs */ | ||||
u_int uh_hashsize; /* Current size of the hash table */ | u_int uh_hashsize; /* Current size of the hash table */ | ||||
u_int uh_hashmask; /* Mask used during hashing */ | u_int uh_hashmask; /* Mask used during hashing */ | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | struct uma_keg { | ||||
uma_init uk_init; /* Keg's init routine */ | uma_init uk_init; /* Keg's init routine */ | ||||
uma_fini uk_fini; /* Keg's fini routine */ | uma_fini uk_fini; /* Keg's fini routine */ | ||||
uma_alloc uk_allocf; /* Allocation function */ | uma_alloc uk_allocf; /* Allocation function */ | ||||
uma_free uk_freef; /* Free routine */ | uma_free uk_freef; /* Free routine */ | ||||
u_long uk_offset; /* Next free offset from base KVA */ | u_long uk_offset; /* Next free offset from base KVA */ | ||||
vm_offset_t uk_kva; /* Zone base KVA */ | vm_offset_t uk_kva; /* Zone base KVA */ | ||||
uma_zone_t uk_slabzone; /* Slab zone backing us, if OFFPAGE */ | |||||
uint32_t uk_pgoff; /* Offset to uma_slab struct */ | uint32_t uk_pgoff; /* Offset to uma_slab struct */ | ||||
uint16_t uk_ppera; /* pages per allocation from backend */ | uint16_t uk_ppera; /* pages per allocation from backend */ | ||||
uint16_t uk_ipers; /* Items per slab */ | uint16_t uk_ipers; /* Items per slab */ | ||||
uint32_t uk_flags; /* Internal flags */ | uint32_t uk_flags; /* Internal flags */ | ||||
/* Least used fields go to the last cache line. */ | /* Least used fields go to the last cache line. */ | ||||
const char *uk_name; /* Name of creating zone. */ | const char *uk_name; /* Name of creating zone. */ | ||||
Show All 9 Lines | #define KEG_ASSERT_COLD(k) \ | ||||
KASSERT(uma_keg_get_allocs((k)) == 0, \ | KASSERT(uma_keg_get_allocs((k)) == 0, \ | ||||
("keg %s initialization after use.", (k)->uk_name)) | ("keg %s initialization after use.", (k)->uk_name)) | ||||
/* | /* | ||||
* Free bits per-slab. | * Free bits per-slab. | ||||
*/ | */ | ||||
#define SLAB_MAX_SETSIZE (PAGE_SIZE / UMA_SMALLEST_UNIT) | #define SLAB_MAX_SETSIZE (PAGE_SIZE / UMA_SMALLEST_UNIT) | ||||
#define SLAB_MIN_SETSIZE _BITSET_BITS | #define SLAB_MIN_SETSIZE _BITSET_BITS | ||||
BITSET_DEFINE(slabbits, SLAB_MAX_SETSIZE); | |||||
BITSET_DEFINE(noslabbits, 0); | BITSET_DEFINE(noslabbits, 0); | ||||
/* | /* | ||||
* The slab structure manages a single contiguous allocation from backing | * The slab structure manages a single contiguous allocation from backing | ||||
* store and subdivides it into individually allocatable items. | * store and subdivides it into individually allocatable items. | ||||
*/ | */ | ||||
struct uma_slab { | struct uma_slab { | ||||
LIST_ENTRY(uma_slab) us_link; /* slabs in zone */ | LIST_ENTRY(uma_slab) us_link; /* slabs in zone */ | ||||
Show All 25 Lines | |||||
size_t slab_space(int nitems); | size_t slab_space(int nitems); | ||||
int slab_ipers(size_t size, int align); | int slab_ipers(size_t size, int align); | ||||
/* | /* | ||||
* Slab structure with a full sized bitset and hash link for both | * Slab structure with a full sized bitset and hash link for both | ||||
* HASH and OFFPAGE zones. | * HASH and OFFPAGE zones. | ||||
*/ | */ | ||||
struct uma_hash_slab { | struct uma_hash_slab { | ||||
struct uma_slab uhs_slab; /* Must be first. */ | |||||
struct slabbits uhs_bits1; /* Must be second. */ | |||||
#ifdef INVARIANTS | |||||
struct slabbits uhs_bits2; /* Must be third. */ | |||||
#endif | |||||
LIST_ENTRY(uma_hash_slab) uhs_hlink; /* Link for hash table */ | LIST_ENTRY(uma_hash_slab) uhs_hlink; /* Link for hash table */ | ||||
uint8_t *uhs_data; /* First item */ | uint8_t *uhs_data; /* First item */ | ||||
struct uma_slab uhs_slab; /* Must be last. */ | |||||
}; | }; | ||||
typedef struct uma_hash_slab * uma_hash_slab_t; | typedef struct uma_hash_slab * uma_hash_slab_t; | ||||
static inline uma_hash_slab_t | |||||
slab_tohashslab(uma_slab_t slab) | |||||
jeff: At this point it feels something like a historical accident to call them hash slabs. | |||||
markjUnsubmitted Not Done Inline Actionsuma_offpage_slab_t? markj: uma_offpage_slab_t? | |||||
rlibbyAuthorUnsubmitted Done Inline ActionsI agree, it puts the emphasis in the wrong place. I'd like to leave it alone for this commit at least though. rlibby: I agree, it puts the emphasis in the wrong place. I'd like to leave it alone for this commit… | |||||
{ | |||||
return (__containerof(slab, struct uma_hash_slab, uhs_slab)); | |||||
} | |||||
static inline void * | static inline void * | ||||
slab_data(uma_slab_t slab, uma_keg_t keg) | slab_data(uma_slab_t slab, uma_keg_t keg) | ||||
{ | { | ||||
if ((keg->uk_flags & UMA_ZFLAG_OFFPAGE) == 0) | if ((keg->uk_flags & UMA_ZFLAG_OFFPAGE) == 0) | ||||
return ((void *)((uintptr_t)slab - keg->uk_pgoff)); | return ((void *)((uintptr_t)slab - keg->uk_pgoff)); | ||||
else | else | ||||
return (((uma_hash_slab_t)slab)->uhs_data); | return slab_tohashslab(slab)->uhs_data; | ||||
markjUnsubmitted Done Inline ActionsMissing parens. markj: Missing parens. | |||||
} | } | ||||
static inline void * | static inline void * | ||||
slab_item(uma_slab_t slab, uma_keg_t keg, int index) | slab_item(uma_slab_t slab, uma_keg_t keg, int index) | ||||
{ | { | ||||
uintptr_t data; | uintptr_t data; | ||||
data = (uintptr_t)slab_data(slab, keg); | data = (uintptr_t)slab_data(slab, keg); | ||||
▲ Show 20 Lines • Show All 247 Lines • Show Last 20 Lines |
At this point it feels something like a historical accident to call them hash slabs.