public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Bennet Gallein <me@bennetgallein.de>
To: pve-devel@lists.proxmox.com
Cc: Bennet Gallein <me@bennetgallein.de>
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	[thread overview]
Message-ID: <20261104100003.106703-1-me@bennetgallein.de> (raw)

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 <me@bennetgallein.de>
---
 ...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 <behlendorf1@llnl.gov>
+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 <me@bennetgallein.de>
+---
+ 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




                 reply	other threads:[~2026-11-04 10:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261104100003.106703-1-me@bennetgallein.de \
    --to=me@bennetgallein.de \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal