diff options
authorMark Johnston <markj@FreeBSD.org>2022-01-14 20:06:48 +0000
committerMark Johnston <markj@FreeBSD.org>2022-01-14 20:38:02 +0000
commita04ce833f9ba058ec3e04f686bd56fa0691bfcf0 (patch)
parent4a864f624a7097f1d032a0350ac70fa6c371179e (diff)
uma: Avoid polling for an invalid SMR sequence number
Buckets in an SMR-enabled zone can legitimately be tagged with SMR_SEQ_INVALID. This effectively means that the zone destructor (if any) was invoked on all items in the bucket, and the contained memory is safe to reuse. If the first bucket in the full bucket list was tagged this way, UMA would unnecessarily poll per-CPU state before attempting to fetch a full bucket from the list. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index e114e43184bd..f6f7b083133a 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1051,6 +1051,7 @@ cache_fetch_bucket(uma_zone_t zone, uma_cache_t cache, int domain)
uma_zone_domain_t zdom;
uma_bucket_t bucket;
+ smr_seq_t seq;
* Avoid the lock if possible.
@@ -1060,7 +1061,8 @@ cache_fetch_bucket(uma_zone_t zone, uma_cache_t cache, int domain)
return (NULL);
if ((cache_uz_flags(cache) & UMA_ZONE_SMR) != 0 &&
- !smr_poll(zone->uz_smr, zdom->uzd_seq, false))
+ (seq = atomic_load_32(&zdom->uzd_seq)) != SMR_SEQ_INVALID &&
+ !smr_poll(zone->uz_smr, seq, false))
return (NULL);