MCPcopy Create free account
hub / github.com/F-Stack/f-stack / hash_alloc

Function hash_alloc

freebsd/vm/uma_core.c:1044–1067  ·  view source on GitHub ↗

* Allocate and zero fill the next sized hash table from the appropriate * backing store. * * Arguments: * hash A new hash structure with the old hash size in uh_hashsize * * Returns: * 1 on success and 0 on failure. */

Source from the content-addressed store, hash-verified

1042 * 1 on success and 0 on failure.
1043 */
1044static int
1045hash_alloc(struct uma_hash *hash, u_int size)
1046{
1047 size_t alloc;
1048
1049 KASSERT(powerof2(size), ("hash size must be power of 2"));
1050 if (size > UMA_HASH_SIZE_INIT) {
1051 hash->uh_hashsize = size;
1052 alloc = sizeof(hash->uh_slab_hash[0]) * hash->uh_hashsize;
1053 hash->uh_slab_hash = malloc(alloc, M_UMAHASH, M_NOWAIT);
1054 } else {
1055 alloc = sizeof(hash->uh_slab_hash[0]) * UMA_HASH_SIZE_INIT;
1056 hash->uh_slab_hash = zone_alloc_item(hashzone, NULL,
1057 UMA_ANYDOMAIN, M_WAITOK);
1058 hash->uh_hashsize = UMA_HASH_SIZE_INIT;
1059 }
1060 if (hash->uh_slab_hash) {
1061 bzero(hash->uh_slab_hash, alloc);
1062 hash->uh_hashmask = hash->uh_hashsize - 1;
1063 return (1);
1064 }
1065
1066 return (0);
1067}
1068
1069/*
1070 * Expands the hash table for HASH zones. This is done from zone_timeout

Callers 2

zone_timeoutFunction · 0.85
keg_ctorFunction · 0.85

Calls 3

mallocFunction · 0.85
zone_alloc_itemFunction · 0.85
bzeroFunction · 0.85

Tested by

no test coverage detected