* Insert a full bucket into the specified cache. The "ws" parameter indicates * whether the bucket's contents should be counted as part of the zone's working * set. The bucket may be freed if it exceeds the bucket limit. */
| 701 | * set. The bucket may be freed if it exceeds the bucket limit. |
| 702 | */ |
| 703 | static void |
| 704 | zone_put_bucket(uma_zone_t zone, int domain, uma_bucket_t bucket, void *udata, |
| 705 | const bool ws) |
| 706 | { |
| 707 | uma_zone_domain_t zdom; |
| 708 | |
| 709 | /* We don't cache empty buckets. This can happen after a reclaim. */ |
| 710 | if (bucket->ub_cnt == 0) |
| 711 | goto out; |
| 712 | zdom = zone_domain_lock(zone, domain); |
| 713 | |
| 714 | /* |
| 715 | * Conditionally set the maximum number of items. |
| 716 | */ |
| 717 | zdom->uzd_nitems += bucket->ub_cnt; |
| 718 | if (__predict_true(zdom->uzd_nitems < zone->uz_bucket_max)) { |
| 719 | if (ws) |
| 720 | zone_domain_imax_set(zdom, zdom->uzd_nitems); |
| 721 | if (STAILQ_EMPTY(&zdom->uzd_buckets)) |
| 722 | zdom->uzd_seq = bucket->ub_seq; |
| 723 | |
| 724 | /* |
| 725 | * Try to promote reuse of recently used items. For items |
| 726 | * protected by SMR, try to defer reuse to minimize polling. |
| 727 | */ |
| 728 | if (bucket->ub_seq == SMR_SEQ_INVALID) |
| 729 | STAILQ_INSERT_HEAD(&zdom->uzd_buckets, bucket, ub_link); |
| 730 | else |
| 731 | STAILQ_INSERT_TAIL(&zdom->uzd_buckets, bucket, ub_link); |
| 732 | ZDOM_UNLOCK(zdom); |
| 733 | return; |
| 734 | } |
| 735 | zdom->uzd_nitems -= bucket->ub_cnt; |
| 736 | ZDOM_UNLOCK(zdom); |
| 737 | out: |
| 738 | bucket_free(zone, bucket, udata); |
| 739 | } |
| 740 | |
| 741 | /* Pops an item out of a per-cpu cache bucket. */ |
| 742 | static inline void * |
no test coverage detected