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

Function zone_timeout

freebsd/vm/uma_core.c:976–1032  ·  view source on GitHub ↗

* Routine to perform timeout driven calculations. This expands the * hashes and does per cpu statistics aggregation. * * Returns nothing. */

Source from the content-addressed store, hash-verified

974 * Returns nothing.
975 */
976static void
977zone_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
1029update_wss:
1030 for (int i = 0; i < vm_ndomains; i++)
1031 zone_domain_update_wss(ZDOM_GET(zone, i));
1032}
1033

Callers

nothing calls this directly

Calls 5

hash_allocFunction · 0.85
hash_expandFunction · 0.85
hash_freeFunction · 0.85
zone_domain_update_wssFunction · 0.85
flsFunction · 0.50

Tested by

no test coverage detected