* Expands the hash table for HASH zones. This is done from zone_timeout * to reduce collisions. This must not be done in the regular allocation * path, otherwise, we can recurse on the vm while allocating pages. * * Arguments: * oldhash The hash you want to expand * newhash The hash structure for the new table * * Returns: * Nothing * * Discussion: */
| 1081 | * Discussion: |
| 1082 | */ |
| 1083 | static int |
| 1084 | hash_expand(struct uma_hash *oldhash, struct uma_hash *newhash) |
| 1085 | { |
| 1086 | uma_hash_slab_t slab; |
| 1087 | u_int hval; |
| 1088 | u_int idx; |
| 1089 | |
| 1090 | if (!newhash->uh_slab_hash) |
| 1091 | return (0); |
| 1092 | |
| 1093 | if (oldhash->uh_hashsize >= newhash->uh_hashsize) |
| 1094 | return (0); |
| 1095 | |
| 1096 | /* |
| 1097 | * I need to investigate hash algorithms for resizing without a |
| 1098 | * full rehash. |
| 1099 | */ |
| 1100 | |
| 1101 | for (idx = 0; idx < oldhash->uh_hashsize; idx++) |
| 1102 | while (!LIST_EMPTY(&oldhash->uh_slab_hash[idx])) { |
| 1103 | slab = LIST_FIRST(&oldhash->uh_slab_hash[idx]); |
| 1104 | LIST_REMOVE(slab, uhs_hlink); |
| 1105 | hval = UMA_HASH(newhash, slab->uhs_data); |
| 1106 | LIST_INSERT_HEAD(&newhash->uh_slab_hash[hval], |
| 1107 | slab, uhs_hlink); |
| 1108 | } |
| 1109 | |
| 1110 | return (1); |
| 1111 | } |
| 1112 | |
| 1113 | /* |
| 1114 | * Free the hash bucket to the appropriate backing store. |