* Routine to perform timeout driven calculations. This expands the * hashes and does per cpu statistics aggregation. * * Returns nothing. */
| 974 | * Returns nothing. |
| 975 | */ |
| 976 | static void |
| 977 | zone_timeout(uma_zone_t zone, void *unused) |
| 978 | { |
| 979 | uma_keg_t keg; |
| 980 | u_int slabs, pages; |
| 981 | |
| 982 | if ((zone->uz_flags & UMA_ZFLAG_HASH) == 0) |
| 983 | goto update_wss; |
| 984 | |
| 985 | keg = zone->uz_keg; |
| 986 | |
| 987 | /* |
| 988 | * Hash zones are non-numa by definition so the first domain |
| 989 | * is the only one present. |
| 990 | */ |
| 991 | KEG_LOCK(keg, 0); |
| 992 | pages = keg->uk_domain[0].ud_pages; |
| 993 | |
| 994 | /* |
| 995 | * Expand the keg hash table. |
| 996 | * |
| 997 | * This is done if the number of slabs is larger than the hash size. |
| 998 | * What I'm trying to do here is completely reduce collisions. This |
| 999 | * may be a little aggressive. Should I allow for two collisions max? |
| 1000 | */ |
| 1001 | if ((slabs = pages / keg->uk_ppera) > keg->uk_hash.uh_hashsize) { |
| 1002 | struct uma_hash newhash; |
| 1003 | struct uma_hash oldhash; |
| 1004 | int ret; |
| 1005 | |
| 1006 | /* |
| 1007 | * This is so involved because allocating and freeing |
| 1008 | * while the keg lock is held will lead to deadlock. |
| 1009 | * I have to do everything in stages and check for |
| 1010 | * races. |
| 1011 | */ |
| 1012 | KEG_UNLOCK(keg, 0); |
| 1013 | ret = hash_alloc(&newhash, 1 << fls(slabs)); |
| 1014 | KEG_LOCK(keg, 0); |
| 1015 | if (ret) { |
| 1016 | if (hash_expand(&keg->uk_hash, &newhash)) { |
| 1017 | oldhash = keg->uk_hash; |
| 1018 | keg->uk_hash = newhash; |
| 1019 | } else |
| 1020 | oldhash = newhash; |
| 1021 | |
| 1022 | KEG_UNLOCK(keg, 0); |
| 1023 | hash_free(&oldhash); |
| 1024 | goto update_wss; |
| 1025 | } |
| 1026 | } |
| 1027 | KEG_UNLOCK(keg, 0); |
| 1028 | |
| 1029 | update_wss: |
| 1030 | for (int i = 0; i < vm_ndomains; i++) |
| 1031 | zone_domain_update_wss(ZDOM_GET(zone, i)); |
| 1032 | } |
| 1033 |
nothing calls this directly
no test coverage detected