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

Function bucket_cache_reclaim

freebsd/vm/uma_core.c:1311–1361  ·  view source on GitHub ↗

* Reclaim cached buckets from a zone. All buckets are reclaimed if the caller * requested a drain, otherwise the per-domain caches are trimmed to either * estimated working set size. */

Source from the content-addressed store, hash-verified

1309 * estimated working set size.
1310 */
1311static void
1312bucket_cache_reclaim(uma_zone_t zone, bool drain)
1313{
1314 uma_zone_domain_t zdom;
1315 uma_bucket_t bucket;
1316 long target;
1317 int i;
1318
1319 /*
1320 * Shrink the zone bucket size to ensure that the per-CPU caches
1321 * don't grow too large.
1322 */
1323 if (zone->uz_bucket_size > zone->uz_bucket_size_min)
1324 zone->uz_bucket_size--;
1325
1326 for (i = 0; i < vm_ndomains; i++) {
1327 /*
1328 * The cross bucket is partially filled and not part of
1329 * the item count. Reclaim it individually here.
1330 */
1331 zdom = ZDOM_GET(zone, i);
1332 if ((zone->uz_flags & UMA_ZONE_SMR) == 0 || drain) {
1333 ZONE_CROSS_LOCK(zone);
1334 bucket = zdom->uzd_cross;
1335 zdom->uzd_cross = NULL;
1336 ZONE_CROSS_UNLOCK(zone);
1337 if (bucket != NULL)
1338 bucket_free(zone, bucket, NULL);
1339 }
1340
1341 /*
1342 * If we were asked to drain the zone, we are done only once
1343 * this bucket cache is empty. Otherwise, we reclaim items in
1344 * excess of the zone's estimated working set size. If the
1345 * difference nitems - imin is larger than the WSS estimate,
1346 * then the estimate will grow at the end of this interval and
1347 * we ignore the historical average.
1348 */
1349 ZDOM_LOCK(zdom);
1350 target = drain ? 0 : lmax(zdom->uzd_wss, zdom->uzd_nitems -
1351 zdom->uzd_imin);
1352 while (zdom->uzd_nitems > target) {
1353 bucket = zone_fetch_bucket(zone, zdom, true);
1354 if (bucket == NULL)
1355 break;
1356 bucket_free(zone, bucket, NULL);
1357 ZDOM_LOCK(zdom);
1358 }
1359 ZDOM_UNLOCK(zdom);
1360 }
1361}
1362
1363static void
1364keg_free_slab(uma_keg_t keg, uma_slab_t slab, int start)

Callers 2

cache_drainFunction · 0.85
zone_reclaimFunction · 0.85

Calls 3

lmaxFunction · 0.85
zone_fetch_bucketFunction · 0.85
bucket_freeFunction · 0.70

Tested by

no test coverage detected