From owner-dev-commits-src-branches@freebsd.org Wed Apr 28 14:09:51 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B01785F4BFA; Wed, 28 Apr 2021 14:09:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FVgW34NR9z4jYr; Wed, 28 Apr 2021 14:09:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 878AC6FDD; Wed, 28 Apr 2021 14:09:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13SE9pXN025308; Wed, 28 Apr 2021 14:09:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13SE9pCi025307; Wed, 28 Apr 2021 14:09:51 GMT (envelope-from git) Date: Wed, 28 Apr 2021 14:09:51 GMT Message-Id: <202104281409.13SE9pCi025307@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 6eddb6822c9a - stable/13 - uma: Split bucket_cache_drain() to permit per-domain reclamation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6eddb6822c9abe8a96fb1ad764aee231951ee87f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Apr 2021 14:09:51 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6eddb6822c9abe8a96fb1ad764aee231951ee87f commit 6eddb6822c9abe8a96fb1ad764aee231951ee87f Author: Mark Johnston AuthorDate: 2021-04-09 13:47:09 +0000 Commit: Mark Johnston CommitDate: 2021-04-28 14:00:41 +0000 uma: Split bucket_cache_drain() to permit per-domain reclamation Note that the per-domain variant does not shrink the target bucket size. No functional change intended. Sponsored by: The FreeBSD Foundation (cherry picked from commit 54f421f9e84234c4313f2d636e4ebd74009a74d6) --- sys/vm/uma_core.c | 78 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index b1762500c147..a030be0dad13 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -1307,11 +1307,50 @@ pcpu_cache_drain_safe(uma_zone_t zone) * estimated working set size. */ static void -bucket_cache_reclaim(uma_zone_t zone, bool drain) +bucket_cache_reclaim_domain(uma_zone_t zone, bool drain, int domain) { uma_zone_domain_t zdom; uma_bucket_t bucket; long target; + + /* + * The cross bucket is partially filled and not part of + * the item count. Reclaim it individually here. + */ + zdom = ZDOM_GET(zone, domain); + if ((zone->uz_flags & UMA_ZONE_SMR) == 0 || drain) { + ZONE_CROSS_LOCK(zone); + bucket = zdom->uzd_cross; + zdom->uzd_cross = NULL; + ZONE_CROSS_UNLOCK(zone); + if (bucket != NULL) + bucket_free(zone, bucket, NULL); + } + + /* + * If we were asked to drain the zone, we are done only once + * this bucket cache is empty. Otherwise, we reclaim items in + * excess of the zone's estimated working set size. If the + * difference nitems - imin is larger than the WSS estimate, + * then the estimate will grow at the end of this interval and + * we ignore the historical average. + */ + ZDOM_LOCK(zdom); + target = drain ? 0 : lmax(zdom->uzd_wss, zdom->uzd_nitems - + zdom->uzd_imin); + while (zdom->uzd_nitems > target) { + bucket = zone_fetch_bucket(zone, zdom, true); + if (bucket == NULL) + break; + bucket_free(zone, bucket, NULL); + ZDOM_LOCK(zdom); + } + ZDOM_UNLOCK(zdom); +} + +static void +bucket_cache_reclaim(uma_zone_t zone, bool drain) +{ int i; /* @@ -1321,41 +1360,8 @@ bucket_cache_reclaim(uma_zone_t zone, bool drain) if (zone->uz_bucket_size > zone->uz_bucket_size_min) zone->uz_bucket_size--; - for (i = 0; i < vm_ndomains; i++) { - /* - * The cross bucket is partially filled and not part of - * the item count. Reclaim it individually here. - */ - zdom = ZDOM_GET(zone, i); - if ((zone->uz_flags & UMA_ZONE_SMR) == 0 || drain) { - ZONE_CROSS_LOCK(zone); - bucket = zdom->uzd_cross; - zdom->uzd_cross = NULL; - ZONE_CROSS_UNLOCK(zone); - if (bucket != NULL) - bucket_free(zone, bucket, NULL); - } - - /* - * If we were asked to drain the zone, we are done only once - * this bucket cache is empty. Otherwise, we reclaim items in - * excess of the zone's estimated working set size. If the - * difference nitems - imin is larger than the WSS estimate, - * then the estimate will grow at the end of this interval and - * we ignore the historical average. - */ - ZDOM_LOCK(zdom); - target = drain ? 0 : lmax(zdom->uzd_wss, zdom->uzd_nitems - - zdom->uzd_imin); - while (zdom->uzd_nitems > target) { - bucket = zone_fetch_bucket(zone, zdom, true); - if (bucket == NULL) - break; - bucket_free(zone, bucket, NULL); - ZDOM_LOCK(zdom); - } - ZDOM_UNLOCK(zdom); - } + for (i = 0; i < vm_ndomains; i++) + bucket_cache_reclaim_domain(zone, drain, i); } static void