Re: [RFC PATCH 00/16] mm: add in-memory compression of reclaimed pages

From: Kairui Song

Date: Tue Nov 17 2026 - 11:28:38 EST


Hi nakixii,

Thanks for sharing this, I do like new ideas on memory compression /
eviction :-D. However, this approach is wrong in many ways.

Posting a mega-sized chunk of LLM generated unreviewable code is not
helpful for anyone. And it's based on a rather old kernel, considering the
parts you are trying to work on have changed significantly since then.
It also lacks a convincing realistic workload, e.g. almost nothing is
measured under sustained memory pressure.

I think you can start by describing the problem and goal clearly instead.

> This is a proof of concept, posted to ask whether the approach is worth
> pursuing. It is not meant for merging. The series is based on Linux
> 6.12.23, not on mm-unstable, and has not been ported to the swap-table
> and zpool changes that have landed since. If there is interest, the
> next version will be rebased onto mm-unstable.

But anyway I took a look at the series (also with help of LLM :P),
IIUC, the main goal is to cut down the intermediate layers for better
swap performance.

Then basing on 6.12 is a bad start, those updates you ignored already
achieved that, or are focusing on and getting close: Zpool layer is
removed; Swap table & cluster allocator removed the Xarray layer and
multiple synchronization layers and reduced contention and overhead;
we are also flattening the zsmalloc handlers, and many more are being
done step by step. You can check recent git log and upstream mails for
the updates on these parts.

So in mainline, the win you measured is no longer there.

I asked an AI agent to try this out yesterday and it reported this today
(256M anon, all paged out, 20k random single page faults, page-cluster=0,
best of 3, canary filtered, same compressor on both sides):

pageout us/page p50 p99
6.12.23 memcomp lz4 1.11 0.96 us 1.63 us
6.12.23 zram lz4 1.31 1.13 us 7.75 us
7.4-rc1 zram lz4 1.13 1.04 us 2.42 us

6.12.23 memcomp zstd 4.15 2.42 us 3.21 us
7.4-rc1 zram zstd 4.92 2.63 us 4.08 us
7.4-rc1 zswap zstd 4.89 2.58 us 4.04 us

Against a 6.12 baseline your point reproduces (7.75 -> 1.63 us). But for
mainline the p50 / avg are close to identical, and the p99 is only 26-33%
better instead of the 2x you measured; considering the ongoing
optimizations I'm pretty sure mainline will bypass that without bloating
up the LOC, or while reducing it.

And I think there is a major misunderstanding here: you didn't bypass
swap, you just re-invented it. And there is no "direct memorey
compression", everything goes through a page fault, unless you have
some fancy hardware support like CRAM.

So TLDR: the 46K LOC for an ambiguous performance gain is really not a
good idea, it is basically a poorman's reimplementation of swap with many
essential parts stripped to be fast (broken OOM handling, no cgroup
control, many statistics and counters missing), and still not really
fast. So don't reinvent wheels.

One thing to keep though: patch 1 (UFFDIO_MOVE exclusivity) seem
valid? And it has a Fixes tag, so please double check and send
it on its own and maybe we can review it :-)

Anyway, still thanks for sharing this - a good reminder that everyone is
chasing every nanosecond of swap performance :).

Thanks.