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

Function cache_drain

freebsd/vm/uma_core.c:1185–1221  ·  view source on GitHub ↗

* Drains the per cpu caches for a zone. * * NOTE: This may only be called while the zone is being torn down, and not * during normal operation. This is necessary in order that we do not have * to migrate CPUs to drain the per-CPU caches. * * Arguments: * zone The zone to drain, must be unlocked. * * Returns: * Nothing */

Source from the content-addressed store, hash-verified

1183 * Nothing
1184 */
1185static void
1186cache_drain(uma_zone_t zone)
1187{
1188 uma_cache_t cache;
1189 uma_bucket_t bucket;
1190 smr_seq_t seq;
1191 int cpu;
1192
1193 /*
1194 * XXX: It is safe to not lock the per-CPU caches, because we're
1195 * tearing down the zone anyway. I.e., there will be no further use
1196 * of the caches at this point.
1197 *
1198 * XXX: It would good to be able to assert that the zone is being
1199 * torn down to prevent improper use of cache_drain().
1200 */
1201 seq = SMR_SEQ_INVALID;
1202 if ((zone->uz_flags & UMA_ZONE_SMR) != 0)
1203 seq = smr_advance(zone->uz_smr);
1204 CPU_FOREACH(cpu) {
1205 cache = &zone->uz_cpu[cpu];
1206 bucket = cache_bucket_unload_alloc(cache);
1207 if (bucket != NULL)
1208 bucket_free(zone, bucket, NULL);
1209 bucket = cache_bucket_unload_free(cache);
1210 if (bucket != NULL) {
1211 bucket->ub_seq = seq;
1212 bucket_free(zone, bucket, NULL);
1213 }
1214 bucket = cache_bucket_unload_cross(cache);
1215 if (bucket != NULL) {
1216 bucket->ub_seq = seq;
1217 bucket_free(zone, bucket, NULL);
1218 }
1219 }
1220 bucket_cache_reclaim(zone, true);
1221}
1222
1223static void
1224cache_shrink(uma_zone_t zone, void *unused)

Callers 1

zone_dtorFunction · 0.85

Calls 6

smr_advanceFunction · 0.85
cache_bucket_unload_freeFunction · 0.85
bucket_cache_reclaimFunction · 0.85
bucket_freeFunction · 0.70

Tested by

no test coverage detected