* 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 */
| 1183 | * Nothing |
| 1184 | */ |
| 1185 | static void |
| 1186 | cache_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 | |
| 1223 | static void |
| 1224 | cache_shrink(uma_zone_t zone, void *unused) |
no test coverage detected