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

Function zone_fetch_bucket

freebsd/vm/uma_core.c:648–696  ·  view source on GitHub ↗

* Attempt to satisfy an allocation by retrieving a full bucket from one of the * zone's caches. If a bucket is found the zone is not locked on return. */

Source from the content-addressed store, hash-verified

646 * zone's caches. If a bucket is found the zone is not locked on return.
647 */
648static uma_bucket_t
649zone_fetch_bucket(uma_zone_t zone, uma_zone_domain_t zdom, bool reclaim)
650{
651 uma_bucket_t bucket;
652 int i;
653 bool dtor = false;
654
655 ZDOM_LOCK_ASSERT(zdom);
656
657 if ((bucket = STAILQ_FIRST(&zdom->uzd_buckets)) == NULL)
658 return (NULL);
659
660 /* SMR Buckets can not be re-used until readers expire. */
661 if ((zone->uz_flags & UMA_ZONE_SMR) != 0 &&
662 bucket->ub_seq != SMR_SEQ_INVALID) {
663 if (!smr_poll(zone->uz_smr, bucket->ub_seq, false))
664 return (NULL);
665 bucket->ub_seq = SMR_SEQ_INVALID;
666 dtor = (zone->uz_dtor != NULL) || UMA_ALWAYS_CTORDTOR;
667 if (STAILQ_NEXT(bucket, ub_link) != NULL)
668 zdom->uzd_seq = STAILQ_NEXT(bucket, ub_link)->ub_seq;
669 }
670 STAILQ_REMOVE_HEAD(&zdom->uzd_buckets, ub_link);
671
672 KASSERT(zdom->uzd_nitems >= bucket->ub_cnt,
673 ("%s: item count underflow (%ld, %d)",
674 __func__, zdom->uzd_nitems, bucket->ub_cnt));
675 KASSERT(bucket->ub_cnt > 0,
676 ("%s: empty bucket in bucket cache", __func__));
677 zdom->uzd_nitems -= bucket->ub_cnt;
678
679 /*
680 * Shift the bounds of the current WSS interval to avoid
681 * perturbing the estimate.
682 */
683 if (reclaim) {
684 zdom->uzd_imin -= lmin(zdom->uzd_imin, bucket->ub_cnt);
685 zone_domain_imax_sub(zdom, bucket->ub_cnt);
686 } else if (zdom->uzd_imin > zdom->uzd_nitems)
687 zdom->uzd_imin = zdom->uzd_nitems;
688
689 ZDOM_UNLOCK(zdom);
690 if (dtor)
691 for (i = 0; i < bucket->ub_cnt; i++)
692 item_dtor(zone, bucket->ub_bucket[i], zone->uz_size,
693 NULL, SKIP_NONE);
694
695 return (bucket);
696}
697
698/*
699 * Insert a full bucket into the specified cache. The "ws" parameter indicates

Callers 3

cache_fetch_bucketFunction · 0.85
bucket_cache_reclaimFunction · 0.85
uma_zalloc_domainFunction · 0.85

Calls 4

smr_pollFunction · 0.85
lminFunction · 0.85
zone_domain_imax_subFunction · 0.85
item_dtorFunction · 0.85

Tested by

no test coverage detected