From: Matthias Goergens <matthias.goergens@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthias Goergens <matthias.goergens@gmail.com>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Michal Hocko <mhocko@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Nhat Pham <nphamcs@gmail.com>, Yosry Ahmed <yosry@kernel.org>,
Youngjun Park <youngjun.park@lge.com>,
Baoquan He <baoquan.he@linux.dev>, Barry Song <baohua@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, linux-api@vger.kernel.org,
Alejandro Colomar <alx@kernel.org>,
linux-man@vger.kernel.org, Karel Zak <kzak@redhat.com>,
util-linux@vger.kernel.org,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
"Rafael J . Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org
Subject: [RFC PATCH 0/3] mm/swap: reserve swap areas for deliberate offload
Date: Mon, 14 Sep 2026 18:44:58 +0800 [thread overview]
Message-ID: <20260914104501.3960616-1-matthias.goergens@gmail.com> (raw)
Some swap backends are useful for deliberate cold-page offload but are poor
dependencies for ordinary reclaim under acute memory pressure. Swap on ZFS
zvols is an existing example, with documented deadlocks under memory
pressure [3]. Compressed swap is another attractive target: accepting a
write may require memory for compression or storage even when logical swap
slots remain free.
This series adds an offload-only swap-area policy for such deployments,
alongside a conventional swap reserve for pressure reclaim.
Proactive offloading is already established by TMO/Senpai [4], which uses
pressure feedback to offload cold pages to compressed memory or SSDs.
DAMON_RECLAIM [5] also uses free-memory watermarks to suspend proactive
reclaim under severe pressure. These control when reclaim runs; this RFC
restricts which swap areas ordinary reclaim may write, including through
retained swap entries. The existing memory.zswap.writeback control [6]
restricts backing-swap writes per cgroup, rather than reserving individual
swap areas for explicitly admitted offload.
The minimum contract is that ordinary reclaim must not initiate a new,
non-zero backend write to an offload-only area. Reads, swapoff, zero-page
metadata, architecture preparation, and I/O that was already admitted remain
valid. If no eligible swap remains, existing reclaim and OOM behaviour applies.
This RFC does not promise a performance result or define a new workload policy.
Cgroup v2 memory.reclaim and per-node reclaim establish admission. Manual
MGLRU eviction currently does too, but its debugfs interface is not stable
ABI. Ordinary direct reclaim, kswapd, MADV_PAGEOUT and DAMON reclaim do not
gain access. This is an explicit operator policy; the kernel does not measure
physical headroom or automatically classify backends.
The three patches are based on mm-new as refreshed on 11 September, at
995829088503:
1. The complete swap-area policy, including eligible-capacity accounting and
recovery of eligible cache entries.
2. zram03/zram04 coverage for reclaim routing, zswap bypass, discard policy
and file workingset activation.
3. zram05 coverage for retained swap entries, including ordinary-write
refusal, proactive recovery, data integrity and checked teardown.
The implementation is intended to make these questions reviewable:
1. Should pressure eligibility be a durable property activated with the
physical swap area, or should it be selected late during backend migration?
2. Do provenance, allocation filtering, eligible capacity, and retained-entry
refusal provide a useful minimum contract for userspace and controllers?
3. Is redirtying or activating a retained dirty folio, with possible churn or
OOM, acceptable, or is backend migration a prerequisite?
4. How should persistent activation fail closed and remain auditable when
/proc/swaps and swapon --show do not expose the policy?
5. Should an ineligible fast-path cluster be invalidated immediately, and
should an offload-only area recover its own cache entries based on eligible
fullness rather than global swap fullness?
6. Should the workingset activation heuristic continue to count offload-only
capacity when pressure reclaim cannot allocate from it?
Build checks passed on x86 with i915 built-in or modular, and with swap or
memory cgroups disabled. The affected arm64 MTE objects also compiled.
The routing and workingset tests passed in x86 QEMU guests. In the
retained-entry test, ordinary reclaim wrote nothing to offload-only swap;
proactive reclaim then wrote the dirty folio, and all data verified
correctly. With the write guard removed, the same test failed because
ordinary reclaim wrote to the offload-only area.
Persistent fstab encoding remains unsettled. When hibernation is about to
save an image, an active offload-only area named by resume= is rejected as
the image target with -ENODEV. Virtual Swap Space v4 [1] separates swap
entries from their physical backing, while swap tiers v10 [2] proposes
per-cgroup backend selection. These raise the question of whether offload
eligibility belongs to physical swap areas or a later placement decision;
this RFC does not assume those interfaces are settled.
An explicit-only util-linux companion implementing swapon --offload-only
is prepared for separate submission.
Feedback on the eligibility contract, its placement in the swap stack,
and the unresolved ABI and reclaim-policy questions would be welcome.
[1] https://patchew.org/linux/20260825153238.2695446-1-nphamcs@gmail.com/
[2] https://patchew.org/linux/20260713025644.170839-1-youngjun.park@lge.com/
[3] https://openzfs.github.io/openzfs-docs/Project%20and%20Community/FAQ.html#using-a-zvol-for-a-swap-device-on-linux
[4] https://engineering.fb.com/2022/06/20/data-infrastructure/transparent-memory-offloading-more-memory-at-a-fraction-of-the-cost-and-power/
[5] https://www.kernel.org/doc/html/latest/admin-guide/mm/damon/reclaim.html
[6] https://www.kernel.org/doc/html/latest/admin-guide/mm/zswap.html
Matthias Goergens (3):
mm: restrict offload-only swap to proactive reclaim
selftests: zram: cover offload-only swap policy
selftests: zram: cover retained offload-only entries
Documentation/mm/swap.rst | 87 ++++
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 2 +-
.../gpu/drm/i915/gem/selftests/huge_pages.c | 6 +-
drivers/gpu/drm/msm/msm_gem_shrinker.c | 2 +-
drivers/gpu/drm/panthor/panthor_gem.c | 2 +-
drivers/gpu/drm/ttm/ttm_backup.c | 2 +-
drivers/gpu/drm/xe/tests/xe_bo.c | 2 +-
include/linux/swap.h | 29 +-
include/linux/vm_event_item.h | 1 +
mm/memcontrol.c | 20 +-
mm/page_io.c | 24 +-
mm/swapfile.c | 126 +++++-
mm/vmscan.c | 31 +-
mm/vmstat.c | 1 +
tools/testing/selftests/zram/.gitignore | 2 +
tools/testing/selftests/zram/Makefile | 4 +-
tools/testing/selftests/zram/config | 10 +-
tools/testing/selftests/zram/swap_offload.c | 402 ++++++++++++++++++
.../selftests/zram/workingset_offload.c | 206 +++++++++
tools/testing/selftests/zram/zram03.sh | 166 ++++++++
tools/testing/selftests/zram/zram04.sh | 149 +++++++
tools/testing/selftests/zram/zram05.sh | 360 ++++++++++++++++
tools/testing/selftests/zram/zram_lib.sh | 28 ++
23 files changed, 1620 insertions(+), 42 deletions(-)
create mode 100644 tools/testing/selftests/zram/swap_offload.c
create mode 100644 tools/testing/selftests/zram/workingset_offload.c
create mode 100755 tools/testing/selftests/zram/zram03.sh
create mode 100755 tools/testing/selftests/zram/zram04.sh
create mode 100755 tools/testing/selftests/zram/zram05.sh
base-commit: 9958290885035431e2494159f555e332c3c14906
--
2.55.0
next reply other threads:[~2026-09-14 10:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 10:44 Matthias Goergens [this message]
2026-09-14 10:44 ` [RFC PATCH 1/3] mm: restrict offload-only swap to proactive reclaim Matthias Goergens
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=20260914104501.3960616-1-matthias.goergens@gmail.com \
--to=matthias.goergens@gmail.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alx@kernel.org \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=cgroups@vger.kernel.org \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hannes@cmpxchg.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kasong@tencent.com \
--cc=kzak@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=nphamcs@gmail.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=shuah@kernel.org \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=util-linux@vger.kernel.org \
--cc=will@kernel.org \
--cc=yosry@kernel.org \
--cc=youngjun.park@lge.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