Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Nov 2021 13:52:18 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7585c5db25b7 - main - uma: Fix handling of reserves in zone_import()
Message-ID:  <202111011352.1A1DqIQq066870@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=7585c5db25b700d19baebd7afd7a1b2e03c29cda

commit 7585c5db25b700d19baebd7afd7a1b2e03c29cda
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-11-01 13:27:52 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-11-01 13:51:43 +0000

    uma: Fix handling of reserves in zone_import()
    
    Kegs with no items reserved have uk_reserve = 0.  So the check
    keg->uk_reserve >= dom->ud_free_items will be true once all slabs are
    depleted.  Then, rather than go and allocate a fresh slab, we return to
    the cache layer.
    
    The intent was to do this only when the keg actually has a reserve, so
    modify the check to verify this first.  Another approach would be to
    make uk_reserve signed and set it to -1 until uma_zone_reserve() is
    called, but this requires a few casts elsewhere.
    
    Fixes:  1b2dcc8c54a8 ("uma: Avoid depleting keg reserves when filling a bucket")
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32516
---
 sys/vm/uma_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index de9605a28bb6..7b83d81a423d 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -4038,7 +4038,8 @@ zone_import(void *arg, void **bucket, int max, int domain, int flags)
 		dom = &keg->uk_domain[slab->us_domain];
 		do {
 			bucket[i++] = slab_alloc_item(keg, slab);
-			if (dom->ud_free_items <= keg->uk_reserve) {
+			if (keg->uk_reserve > 0 &&
+			    dom->ud_free_items <= keg->uk_reserve) {
 				/*
 				 * Avoid depleting the reserve after a
 				 * successful item allocation, even if



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111011352.1A1DqIQq066870>