all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH zfsonlinux] fix #8278: d/patches: cherry-pick fix for ARC collapse on kernel 7.0
@ 2026-11-04 10:00 Bennet Gallein
  0 siblings, 0 replies; only message in thread
From: Bennet Gallein @ 2026-11-04 10:00 UTC (permalink / raw)
  To: pve-devel; +Cc: Bennet Gallein

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




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-04 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 10:00 [PATCH zfsonlinux] fix #8278: d/patches: cherry-pick fix for ARC collapse on kernel 7.0 Bennet Gallein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal