From: Jihan LIN via B4 Relay <devnull+linjh22s.gmail.com@kernel.org>
To: Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
Jihan LIN <linjh22s@gmail.com>
Subject: [PATCH RFC 0/3] zram: Allow zcomps to manage their own streams
Date: Wed, 04 Feb 2026 13:48:50 +0000 [thread overview]
Message-ID: <20260204-b4_zcomp_stream-v1-0-35c06ce1d332@gmail.com> (raw)
Hi all,
This RFC series introduces a new interface to allow zram compression
backends to manage their own streams, in addition to the existing
per-CPU stream model.
Current zram manages compression contexts via preemptive per-CPU
streams, which strictly limits concurrency to the number of online CPUs.
In contrast, hardware accelerators specialized for page compression
generally process PAGE_SIZE payloads (e.g. 4K) using standard
algorithms. These devices expose the limitations of this model due to
the following features:
- These devices utilize a hardware queue to batch requests. A typical
queue depth (e.g., 256) far exceeds the number of available CPUs.
- These devices are asymmetric. Submission is generally fast and
asynchronous, but completion implies latency.
- Some devices only support compression requests, leaving decompression
to be handled by software.
This exposes the limitations of the current zcomp architecture, which
assumes a model where streams are inherently tied to CPU execution
contexts. This design is not flexible enough to integrate with such
backends, as it forces a one-size-fits-all model that limits the ability
to offload compression operations from CPU.
This series proposes a hybrid approach. While maintaining full backward
compatibility with existing backends, this series introduces a new set
of operations, op->{get, put}_streams(), for backends that wish to
manage their own streams. This allows the backend to handle contentions
internally and dynamically select an execution path for the acquired
streams. A new flag is also introduced to indicate this capability at
runtime. zram_write_page() now prefers streams managed by the backend if
a bio is considered asynchronous.
Some design decisions as follows.
1. The proposed get_stream() does not take gfp_t flags to keep the
interface minimal. By design, backends are fully responsible for
allocation safety.
2. The default per-cpu streams now also imply synchronous path for the
backends.
3. The recompression path currently relies on the default per-cpu
streams. This is a trade-off, since recompression is primarily for
memory saving, and hardware accelerators typically prioritize
throughput over compression ratio.
4. zstrm->lock is restricted to the default per-cpu streams. Backends
must implement internal locking if required. While currently exposed
in struct zstrm, this mutex is an implementation detail of the
default path. Future work may involve making the default stream
locking mechanism opaque to the backends, ensuring they interact only
with the necessary stream interfaces.
Although I do not have access to an Intel IAA accelerator and other
accelerators may not be generally available, this series seems to give
a good start for supporting batched asynchronous operations in zram.
The next step would be to introduce an interface that allows
non-blocking compression submission and validate its real-world
performance once such hardware accelerators become available.
Signed-off-by: Jihan LIN <linjh22s@gmail.com>
---
Jihan LIN (3):
zram: Rename zcomp_strm_{init, free}()
zram: Introduce zcomp-managed streams
zram: Use zcomp-managed streams for async write requests
drivers/block/zram/zcomp.c | 37 ++++++++++++++++++++++++++++++-------
drivers/block/zram/zcomp.h | 23 +++++++++++++++++++++--
drivers/block/zram/zram_drv.c | 28 ++++++++++++++++++++++------
3 files changed, 73 insertions(+), 15 deletions(-)
---
base-commit: 24d479d26b25bce5faea3ddd9fa8f3a6c3129ea7
change-id: 20260202-b4_zcomp_stream-7e9f7884e128
Best regards,
--
Jihan LIN <linjh22s@gmail.com>
next reply other threads:[~2026-02-04 13:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 13:48 Jihan LIN via B4 Relay [this message]
2026-02-04 13:48 ` [PATCH RFC 1/3] zram: Rename zcomp_strm_{init, free}() Jihan LIN via B4 Relay
2026-02-04 13:48 ` [PATCH RFC 2/3] zram: Introduce zcomp-managed streams Jihan LIN via B4 Relay
2026-02-04 13:48 ` [PATCH RFC 3/3] zram: Use zcomp-managed streams for async write requests Jihan LIN via B4 Relay
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=20260204-b4_zcomp_stream-v1-0-35c06ce1d332@gmail.com \
--to=devnull+linjh22s.gmail.com@kernel.org \
--cc=axboe@kernel.dk \
--cc=linjh22s@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
/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
all inboxes | Powered by JetHome®