| 1471 | } |
| 1472 | |
| 1473 | static void |
| 1474 | zone_reclaim(uma_zone_t zone, int waitok, bool drain) |
| 1475 | { |
| 1476 | |
| 1477 | /* |
| 1478 | * Set draining to interlock with zone_dtor() so we can release our |
| 1479 | * locks as we go. Only dtor() should do a WAITOK call since it |
| 1480 | * is the only call that knows the structure will still be available |
| 1481 | * when it wakes up. |
| 1482 | */ |
| 1483 | ZONE_LOCK(zone); |
| 1484 | while (zone->uz_flags & UMA_ZFLAG_RECLAIMING) { |
| 1485 | if (waitok == M_NOWAIT) |
| 1486 | goto out; |
| 1487 | msleep(zone, &ZDOM_GET(zone, 0)->uzd_lock, PVM, "zonedrain", |
| 1488 | 1); |
| 1489 | } |
| 1490 | zone->uz_flags |= UMA_ZFLAG_RECLAIMING; |
| 1491 | ZONE_UNLOCK(zone); |
| 1492 | bucket_cache_reclaim(zone, drain); |
| 1493 | |
| 1494 | /* |
| 1495 | * The DRAINING flag protects us from being freed while |
| 1496 | * we're running. Normally the uma_rwlock would protect us but we |
| 1497 | * must be able to release and acquire the right lock for each keg. |
| 1498 | */ |
| 1499 | if ((zone->uz_flags & UMA_ZFLAG_CACHE) == 0) |
| 1500 | keg_drain(zone->uz_keg); |
| 1501 | ZONE_LOCK(zone); |
| 1502 | zone->uz_flags &= ~UMA_ZFLAG_RECLAIMING; |
| 1503 | wakeup(zone); |
| 1504 | out: |
| 1505 | ZONE_UNLOCK(zone); |
| 1506 | } |
| 1507 | |
| 1508 | static void |
| 1509 | zone_drain(uma_zone_t zone, void *unused) |
no test coverage detected