From nobody Wed Jan 15 17:23:19 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YYCWW4pzMz5kPNv; Wed, 15 Jan 2025 17:23:19 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YYCWW3RZlz44r5; Wed, 15 Jan 2025 17:23:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736961799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=986lJUKl3jocmWG3NB9uY1OUanIOIVLykbnO9RjIiLA=; b=qQLdyhYl7Yjo/FdhAiany/ubCjH7DpHYsHzLWMPsXCs3TuyUcvllT7tlKLucfoDaUabElY xEzHALqgZ2+jMlmMMgpzvThUuJlaLLgVxmRbOpaCa1bMtIYl9UBe2FJMH19wD8Cxaw3wzU sAYe0FUHVDOSsgS87kVpbpw8jDobhpWH3zMCsFj5nYi4X7Z+2UpRBpcbjBb36LGZGPHXfs 3Hh5h18JTEfzlhgfUcoXiIbIO/Z0NnObAcL+pP927zQX7wTlS37nXUfAnKt7mZSxBEZOI7 j/U7TwlRxmMxLKB7IzBuQL93dtQ31YJ4Tngn60LhWcpaM6fvdxFkTZR9pj+/wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736961799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=986lJUKl3jocmWG3NB9uY1OUanIOIVLykbnO9RjIiLA=; b=A1RCYPdD8nD2j9xgJvXJspixZS5a+GWg0QNELkvZFmiET5ebRZEicbIyA6cZnSWXt1vBDt sWDuhrZpZh+jQNP5g0kgpHk/FXKybUPPKXYtH8V0crChDjPL+HalDGJwFVwys9VIslxB18 M0vjNMzSPgnAEOHvvS66e7vSVTdIPCBa672H0TnZdLsepbJJp4BOgBOTcZLj5uN1FT3lNT CO0ZQRefkzdvxEno7TwQj51UU9b0npgqDOHlwlHCn8DzjlxzfJ3PyrEv61nmrQohYigMjp p/vVuhkaJEhxTqassL7TgaLv6063KI3M/2rYtq0Wap1KAP3Uk/UX5sSMZrKA6w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736961799; a=rsa-sha256; cv=none; b=UokdSimyYvNB2Z1aVyg58wVMEGkWlsmeq4k0choVYI/v/+8mFFciolm3zCnIZnH47Wu7na uiHKnP9xRoyJf0lidAqPhzwggTmjxu1Exzo7vLaOsel7RwmpOlQN9lcOCmz0W9WjKKwKHi XSQn6Z+ozQjlFyuaWfbx/A6gQcyYwnYU0JSC5p6mT3oCD7kqLP1HMKowXp0sl8XQ6BPcge BtGXjejm18G60mWOwARNAeJpNMxOWKhky7HfpL6YonaKKigUqOCDMzty75KK9rFknsKHwe hluAPXH3daUS99LESbYryfRI+Sp3f2LPvRWwR9iBPVptjMG10h/1XkTJ9JvAPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YYCWW2zPGzwLF; Wed, 15 Jan 2025 17:23:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50FHNJFV014745; Wed, 15 Jan 2025 17:23:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50FHNJB1014742; Wed, 15 Jan 2025 17:23:19 GMT (envelope-from git) Date: Wed, 15 Jan 2025 17:23:19 GMT Message-Id: <202501151723.50FHNJB1014742@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: cf9070746742 - main - Introduce the UMA_ZONE_NOTRIM uma zone type List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf907074674206b1825f79c6864c4c4a32089ecc Auto-Submitted: auto-generated The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=cf907074674206b1825f79c6864c4c4a32089ecc commit cf907074674206b1825f79c6864c4c4a32089ecc Author: Andrew Gallatin AuthorDate: 2025-01-15 17:11:51 +0000 Commit: Andrew Gallatin CommitDate: 2025-01-15 17:23:00 +0000 Introduce the UMA_ZONE_NOTRIM uma zone type The ktls buffer zone allocates 16k contiguous buffers, and often needs to call vm_page_reclaim_contig_domain_ext() to free up contiguous memory, which can be expensive. Web servers which have a daily pattern of peaks and troughs end up having UMA trim the ktls_buffer_zone when they are in their trough, and end up re-building it on the way to their peak. Rather than calling vm_page_reclaim_contig_domain_ext() multiple times on a daily basis, lets mark the ktls_buffer_zone with a new UMA flag, UMA_ZONE_NOTRIM. This disables UMA_RECLAIM_TRIM on the zone, but allows UMA_RECLAIM_DRAIN* operations, so that if we become extremely short of memory (vm_page_count_severe()), the uma reclaim worker can still free up memory. Note that UMA_ZONE_UNMANAGED already exists, but can never be drained or trimmed, so it may hold on to memory during times of severe memory pressure. Using UMA_ZONE_NOTRIM rather than UMA_ZONE_UNMANAGED is an attempt to keep this zone more reactive in the face of severe memory pressure. Sponsored by: Netflix Reviewed by: jhb, kib, markj (via slack) Differential Revision: https://reviews.freebsd.org/D48451 --- sys/kern/uipc_ktls.c | 2 +- sys/vm/uma.h | 1 + sys/vm/uma_core.c | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index 881825bf1d9f..6815667594a4 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -495,7 +495,7 @@ ktls_init(void) ktls_buffer_zone = uma_zcache_create("ktls_buffers", roundup2(ktls_maxlen, PAGE_SIZE), NULL, NULL, NULL, NULL, ktls_buffer_import, ktls_buffer_release, NULL, - UMA_ZONE_FIRSTTOUCH); + UMA_ZONE_FIRSTTOUCH | UMA_ZONE_NOTRIM); } /* diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 38865df7ae02..4f2b143a2fae 100644 --- a/sys/vm/uma.h +++ b/sys/vm/uma.h @@ -252,6 +252,7 @@ uma_zone_t uma_zcache_create(const char *name, int size, uma_ctor ctor, #define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */ #define UMA_ZONE_NOBUCKET 0x0400 /* Do not use buckets. */ #define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets. */ +#define UMA_ZONE_NOTRIM 0x1000 /* Don't trim this zone */ #define UMA_ZONE_CACHESPREAD 0x2000 /* * Spread memory start locations across * all possible cache lines. May diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index e93c561d759a..4de850afcb66 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -1222,7 +1222,7 @@ zone_timeout(uma_zone_t zone, void *unused) trim: /* Trim caches not used for a long time. */ - if ((zone->uz_flags & UMA_ZONE_UNMANAGED) == 0) { + if ((zone->uz_flags & (UMA_ZONE_UNMANAGED | UMA_ZONE_NOTRIM)) == 0) { for (int i = 0; i < vm_ndomains; i++) { if (bucket_cache_reclaim_domain(zone, false, false, i) && (zone->uz_flags & UMA_ZFLAG_CACHE) == 0) @@ -5306,8 +5306,13 @@ uma_reclaim_domain_cb(uma_zone_t zone, void *arg) struct uma_reclaim_args *args; args = arg; - if ((zone->uz_flags & UMA_ZONE_UNMANAGED) == 0) - uma_zone_reclaim_domain(zone, args->req, args->domain); + if ((zone->uz_flags & UMA_ZONE_UNMANAGED) != 0) + return; + if ((args->req == UMA_RECLAIM_TRIM) && + (zone->uz_flags & UMA_ZONE_NOTRIM) !=0) + return; + + uma_zone_reclaim_domain(zone, args->req, args->domain); } /* See uma.h */