From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 533041FF0C0 for ; Wed, 04 Nov 2026 11:00:46 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 40FA12124F; Wed, 04 Nov 2026 11:00:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bennetgallein.de; s=he217959; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=xgKmlwLxR1B9FpjfSXThzvvgVjqdf9KM1o5BPN02VcM=; t=1793786437; x=1794218437; b=ALRZEw8+Gq+bxciZkVCEebIpfv7bNxkbY/yD1dw1G1lapdDUn6egO1hFtsNSoR3FK8CgF5yIF52 GeDZLxHUtEZFgfx3Rq1o+TT16JveLIj0VWhMNbAHrZWPt27cpWcyuPIC2DH6NxPDRB4QUXFkxKYKB W8t7uibZReb+5+XFnFqN0ERIw5dqcBuZahJynjtw0IWoeZq53ywPVUrjfZ5+IaVVD1bae/5C0ygTv C6pZwwUw8wFqL9u3W1tlyeBE/WNq+/f7Rusxp6RrdL63p00zy1DHQM3/B7mic2z16rl0Jt0SLuq3P beVQm9SUriwKMsXBa219s/QU5Ah+yEmNFIFA==; From: Bennet Gallein To: pve-devel@lists.proxmox.com Subject: [PATCH zfsonlinux] fix #8278: d/patches: cherry-pick fix for ARC collapse on kernel 7.0 Date: Wed, 4 Nov 2026 11:00:03 +0100 Message-ID: <20261104100003.106703-1-me@bennetgallein.de> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;me@bennetgallein.de;1793786437;298ca6f4; X-HE-SMSGID: 1xOXn1-009gCE-0F X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_MISSING 0.1 Missing DMARC policy SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: IKIJQOFQB32WMB2CW3UPK3HZKCPPNPSF X-Message-ID-Hash: IKIJQOFQB32WMB2CW3UPK3HZKCPPNPSF X-MailFrom: me@bennetgallein.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Bennet Gallein X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: https://bugzilla.proxmox.com/show_bug.cgi?id=8278 is fixed in upstream master by a0c443a85 ("Linux: avoid waking kswapd when growing vmem slabs") Since Linux 7.0, vmalloc() first tries high-order pages and wakes kswapd on every failed attempt. Growing the 1-8 MiB zio_buf_comb slabs hits this constantly on hosts with fragmented memory, so kswapd keeps shrinking the ARC down to zfs_arc_min while tens of GiB stay free. The fix is not yet on zfs-2.4.5-staging. cherry-pick it from upstream/master; it applies cleanly on top of the current series. Signed-off-by: Bennet Gallein --- ...aking-kswapd-when-growing-vmem-slabs.patch | 59 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 60 insertions(+) create mode 100644 debian/patches/0027-Linux-avoid-waking-kswapd-when-growing-vmem-slabs.patch diff --git a/debian/patches/0027-Linux-avoid-waking-kswapd-when-growing-vmem-slabs.patch b/debian/patches/0027-Linux-avoid-waking-kswapd-when-growing-vmem-slabs.patch new file mode 100644 index 000000000..7c85c7c59 --- /dev/null +++ b/debian/patches/0027-Linux-avoid-waking-kswapd-when-growing-vmem-slabs.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: jomplox <21096700+jomplox@users.noreply.github.com> +Date: Mon, 19 Oct 2026 17:19:08 -0600 +Subject: [PATCH] Linux: avoid waking kswapd when growing vmem slabs + +Since Linux 7.0, vm_area_alloc_pages() first tries to back a vmalloc +area with pages of order up to ilog2(nr_pages). Those attempts clear +__GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM, so every failed +attempt wakes kswapd even though the order-0 fallback succeeds. + +SPL slabs of the zio_buf_comb caches are 1-8 MiB (obj_per_slab x +object size), so their growth requests orders 8-10. On a host whose +free memory is fragmented these attempts fail continuously during +I/O, kswapd reclaims the ARC (down to arc_c_min) and then swaps +anonymous memory, while tens of GiB stay free. + +Slabs are grown asynchronously from spl_cache_grow_work(), which can +sleep and reclaim directly. Clear __GFP_KSWAPD_RECLAIM for these +allocations. The high-order attempts then fail quietly, and the +order-0 path keeps direct reclaim and retries, so a grow cannot fail +where it would not have failed before. + +Assisted-by: Claude Code +Reviewed-by: Brian Behlendorf +Signed-off-by: Jose Vega <21096700+jomplox@users.noreply.github.com> +Closes #18893 +Closes #19276 +(cherry picked from commit a0c443a85ee88cc612dd1c2f57b09ba6865a6994) +Signed-off-by: Bennet Gallein +--- + module/os/linux/spl/spl-kmem-cache.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/module/os/linux/spl/spl-kmem-cache.c b/module/os/linux/spl/spl-kmem-cache.c +index 6d496e685..7aedc9387 100644 +--- a/module/os/linux/spl/spl-kmem-cache.c ++++ b/module/os/linux/spl/spl-kmem-cache.c +@@ -142,7 +142,20 @@ kv_alloc(spl_kmem_cache_t *skc, int size, int flags) + gfp_t lflags = kmem_flags_convert(flags | KM_VMEM); + void *ptr; + +- ptr = spl_vmalloc(size, lflags); ++ /* ++ * Since Linux 7.0, vmalloc() first tries to back large areas with ++ * high-order pages. Those attempts already skip direct reclaim, ++ * but each failure still wakes kswapd, although the order-0 ++ * fallback then succeeds. Slabs are large enough to trigger this ++ * on every grow, so on a fragmented system kswapd keeps reclaiming ++ * the ARC and swapping while plenty of memory is free. ++ * ++ * Slabs are only grown from spl_cache_grow_work(), which can sleep ++ * and reclaim directly, so don't wake kswapd from here. The order-0 ++ * allocations keep direct reclaim, so this cannot fail where it ++ * would not have failed before. ++ */ ++ ptr = spl_vmalloc(size, lflags & ~__GFP_KSWAPD_RECLAIM); + + /* Resulting allocated memory will be page aligned */ + ASSERT(IS_P2ALIGNED(ptr, PAGE_SIZE)); diff --git a/debian/patches/series b/debian/patches/series index d330c0098..f0d82b016 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -23,3 +23,4 @@ 0023-L2ARC-Preserve-L2HDR-in-arc_release-for-in-flight-wr.patch 0024-arc-fix-race-between-arc_release-and-arc_read_done.patch 0026-scripts-make_gitrev.sh-prefer-version-from-d-changel.patch +0027-Linux-avoid-waking-kswapd-when-growing-vmem-slabs.patch -- 2.47.3