Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/uma_core.c
Show First 20 Lines • Show All 616 Lines • ▼ Show 20 Lines | |||||
* hash A new hash structure with the old hash size in uh_hashsize | * hash A new hash structure with the old hash size in uh_hashsize | ||||
* | * | ||||
* Returns: | * Returns: | ||||
* 1 on success and 0 on failure. | * 1 on success and 0 on failure. | ||||
*/ | */ | ||||
static int | static int | ||||
hash_alloc(struct uma_hash *hash) | hash_alloc(struct uma_hash *hash) | ||||
{ | { | ||||
int oldsize; | u_int oldsize; | ||||
size_t alloc; | size_t alloc; | ||||
oldsize = hash->uh_hashsize; | oldsize = hash->uh_hashsize; | ||||
/* We're just going to go to a power of two greater */ | /* We're just going to go to a power of two greater */ | ||||
if (oldsize) { | if (oldsize) { | ||||
hash->uh_hashsize = oldsize * 2; | hash->uh_hashsize = oldsize * 2; | ||||
alloc = sizeof(hash->uh_slab_hash[0]) * hash->uh_hashsize; | alloc = sizeof(hash->uh_slab_hash[0]) * hash->uh_hashsize; | ||||
Show All 27 Lines | |||||
* Nothing | * Nothing | ||||
* | * | ||||
* Discussion: | * Discussion: | ||||
*/ | */ | ||||
static int | static int | ||||
hash_expand(struct uma_hash *oldhash, struct uma_hash *newhash) | hash_expand(struct uma_hash *oldhash, struct uma_hash *newhash) | ||||
{ | { | ||||
uma_slab_t slab; | uma_slab_t slab; | ||||
int hval; | u_int hval; | ||||
int i; | u_int idx; | ||||
if (!newhash->uh_slab_hash) | if (!newhash->uh_slab_hash) | ||||
return (0); | return (0); | ||||
if (oldhash->uh_hashsize >= newhash->uh_hashsize) | if (oldhash->uh_hashsize >= newhash->uh_hashsize) | ||||
return (0); | return (0); | ||||
/* | /* | ||||
* I need to investigate hash algorithms for resizing without a | * I need to investigate hash algorithms for resizing without a | ||||
* full rehash. | * full rehash. | ||||
*/ | */ | ||||
for (i = 0; i < oldhash->uh_hashsize; i++) | for (idx = 0; idx < oldhash->uh_hashsize; idx++) | ||||
while (!SLIST_EMPTY(&oldhash->uh_slab_hash[i])) { | while (!SLIST_EMPTY(&oldhash->uh_slab_hash[idx])) { | ||||
slab = SLIST_FIRST(&oldhash->uh_slab_hash[i]); | slab = SLIST_FIRST(&oldhash->uh_slab_hash[idx]); | ||||
SLIST_REMOVE_HEAD(&oldhash->uh_slab_hash[i], us_hlink); | SLIST_REMOVE_HEAD(&oldhash->uh_slab_hash[idx], us_hlink); | ||||
markj: The diff should avoid mixing style and functional changes. | |||||
hval = UMA_HASH(newhash, slab->us_data); | hval = UMA_HASH(newhash, slab->us_data); | ||||
SLIST_INSERT_HEAD(&newhash->uh_slab_hash[hval], | SLIST_INSERT_HEAD(&newhash->uh_slab_hash[hval], | ||||
slab, us_hlink); | slab, us_hlink); | ||||
} | } | ||||
return (1); | return (1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,533 Lines • Show Last 20 Lines |
The diff should avoid mixing style and functional changes.