aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2025-09-08 17:37:35 +0000
committerOlivier Certner <olce@FreeBSD.org>2025-10-08 16:59:47 +0000
commit781802df7a2bfe224ef17596d56cf83c49517655 (patch)
tree5a918e4976f1797275fa3c1a5c325964df359e17
parentd5d1e05efbedf67f1ef8e8428f9107401e369a0b (diff)
uma_core: Rely on domainset iterator to wait on M_WAITOK
Commit 8b987a77691d ("Use per-domain keg locks.") removed the need to lock the keg entirely, replacing it with per-domain keg locks. In particular, it removed the need to hold a lock over waiting for a domain to grow free memory. Simplify the code of keg_fetch_slab() and uma_prealloc() by removing the M_WAITOK -> M_NOWAIT downgrade and the local call to vm_wait_doms() (which used to necessitate temporary dropping the keg lock) which the iterator machinery already handles on M_WAITOK (and compatibly with vm_domainset_iter_ignore() at that, although that does not matter now). Reviewed by: bnovkov, markj Tested by: bnovkov MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52441
-rw-r--r--sys/vm/uma_core.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 679b2e20e88b..b80b5cc781f7 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -4009,21 +4009,15 @@ restart:
/*
* Use the keg's policy if upper layers haven't already specified a
* domain (as happens with first-touch zones).
- *
- * To avoid races we run the iterator with the keg lock held, but that
- * means that we cannot allow the vm_domainset layer to sleep. Thus,
- * clear M_WAITOK and handle low memory conditions locally.
*/
rr = rdomain == UMA_ANYDOMAIN;
+ aflags = flags;
if (rr) {
- aflags = (flags & ~M_WAITOK) | M_NOWAIT;
if (vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain,
&aflags) != 0)
return (NULL);
- } else {
- aflags = flags;
+ } else
domain = rdomain;
- }
for (;;) {
slab = keg_fetch_free_slab(keg, domain, rr, flags);
@@ -4053,13 +4047,8 @@ restart:
if ((flags & M_WAITOK) == 0)
break;
vm_wait_domain(domain);
- } else if (vm_domainset_iter_policy(&di, &domain) != 0) {
- if ((flags & M_WAITOK) != 0) {
- vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0);
- goto restart;
- }
+ } else if (vm_domainset_iter_policy(&di, &domain) != 0)
break;
- }
}
/*
@@ -5245,7 +5234,7 @@ uma_prealloc(uma_zone_t zone, int items)
KEG_GET(zone, keg);
slabs = howmany(items, keg->uk_ipers);
while (slabs-- > 0) {
- aflags = M_NOWAIT;
+ aflags = M_WAITOK;
if (vm_domainset_iter_policy_ref_init(&di, &keg->uk_dr, &domain,
&aflags) != 0)
panic("%s: Domainset is empty", __func__);
@@ -5266,7 +5255,8 @@ uma_prealloc(uma_zone_t zone, int items)
break;
}
if (vm_domainset_iter_policy(&di, &domain) != 0)
- vm_wait_doms(&keg->uk_dr.dr_policy->ds_mask, 0);
+ panic("%s: Cannot allocate from any domain",
+ __func__);
}
}
}