* + zram-do-not-slot_free-written-back-slots.patch added to mm-hotfixes-unstable branch
@ 2026-03-19 22:44 Andrew Morton
2026-03-20 2:33 ` Sergey Senozhatsky
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2026-03-19 22:44 UTC (permalink / raw)
To: mm-commits, richardycc, minchan, bgeffon, senozhatsky, akpm
The patch titled
Subject: zram: do not slot_free() written-back slots
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
zram-do-not-slot_free-written-back-slots.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/zram-do-not-slot_free-written-back-slots.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: zram: do not slot_free() written-back slots
Date: Thu, 19 Mar 2026 12:44:56 +0900
slot_free() basically completely resets the slots by clearing all of its
flags and attributes. While zram_writeback_complete() restores some of
flags back (those that are necessary for async read decompression) we
still lose a lot of slot's metadata. For example, slot's ac-time, or
ZRAM_INCOMPRESSIBLE.
Do not slot_free() on writeback, instead clear only those flags/attrs that
we need to clear.
Link: https://lkml.kernel.org/r/20260319034912.1894770-1-senozhatsky@chromium.org
Fixes: d38fab605c667 ("zram: introduce compressed data writeback")
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: Richard Chang <richardycc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/block/zram/zram_drv.c | 39 +++++++++++---------------------
1 file changed, 14 insertions(+), 25 deletions(-)
--- a/drivers/block/zram/zram_drv.c~zram-do-not-slot_free-written-back-slots
+++ a/drivers/block/zram/zram_drv.c
@@ -917,9 +917,8 @@ static void zram_account_writeback_submi
static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)
{
- u32 size, index = req->pps->index;
- int err, prio;
- bool huge;
+ u32 index = req->pps->index;
+ int err;
err = blk_status_to_errno(req->bio.bi_status);
if (err) {
@@ -946,28 +945,13 @@ static int zram_writeback_complete(struc
goto out;
}
- if (zram->compressed_wb) {
- /*
- * ZRAM_WB slots get freed, we need to preserve data required
- * for read decompression.
- */
- size = get_slot_size(zram, index);
- prio = get_slot_comp_priority(zram, index);
- huge = test_slot_flag(zram, index, ZRAM_HUGE);
- }
-
- slot_free(zram, index);
- set_slot_flag(zram, index, ZRAM_WB);
+ clear_slot_flag(zram, index, ZRAM_IDLE);
+ if (test_slot_flag(zram, index, ZRAM_HUGE))
+ atomic64_dec(&zram->stats.huge_pages);
+ atomic64_sub(get_slot_size(zram, index), &zram->stats.compr_data_size);
+ zs_free(zram->mem_pool, get_slot_handle(zram, index));
set_slot_handle(zram, index, req->blk_idx);
-
- if (zram->compressed_wb) {
- if (huge)
- set_slot_flag(zram, index, ZRAM_HUGE);
- set_slot_size(zram, index, size);
- set_slot_comp_priority(zram, index, prio);
- }
-
- atomic64_inc(&zram->stats.pages_stored);
+ set_slot_flag(zram, index, ZRAM_WB);
out:
slot_unlock(zram, index);
@@ -2010,8 +1994,13 @@ static void slot_free(struct zram *zram,
set_slot_comp_priority(zram, index, 0);
if (test_slot_flag(zram, index, ZRAM_HUGE)) {
+ /*
+ * Writeback completion decrements ->huge_pages but keeps
+ * ZRAM_HUGE flag for deferred decompression path.
+ */
+ if (!test_slot_flag(zram, index, ZRAM_WB))
+ atomic64_dec(&zram->stats.huge_pages);
clear_slot_flag(zram, index, ZRAM_HUGE);
- atomic64_dec(&zram->stats.huge_pages);
}
if (test_slot_flag(zram, index, ZRAM_WB)) {
_
Patches currently in -mm which might be from senozhatsky@chromium.org are
zram-do-not-slot_free-written-back-slots.patch
zram-do-not-permit-params-change-after-init.patch
zram-do-not-autocorrect-bad-recompression-parameters.patch
zram-drop-num_active_comps.patch
zram-update-recompression-documentation.patch
zram-remove-chained-recompression.patch
zram-unify-and-harden-algo-priority-params-handling.patch
zram-propagate-read_from_bdev_async-errors.patch
zram-change-scan_slots-to-return-void.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: + zram-do-not-slot_free-written-back-slots.patch added to mm-hotfixes-unstable branch
2026-03-19 22:44 + zram-do-not-slot_free-written-back-slots.patch added to mm-hotfixes-unstable branch Andrew Morton
@ 2026-03-20 2:33 ` Sergey Senozhatsky
0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-03-20 2:33 UTC (permalink / raw)
To: Andrew Morton; +Cc: mm-commits, richardycc, minchan, bgeffon, senozhatsky
On (26/03/19 15:44), Andrew Morton wrote:
> The patch titled
> Subject: zram: do not slot_free() written-back slots
> has been added to the -mm mm-hotfixes-unstable branch. Its filename is
> zram-do-not-slot_free-written-back-slots.patch
>
> This patch will shortly appear at
> https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/zram-do-not-slot_free-written-back-slots.patch
>
> This patch will later appear in the mm-hotfixes-unstable branch at
> git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
>
> The -mm tree is included into linux-next via various
> branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there most days
>
> ------------------------------------------------------
> From: Sergey Senozhatsky <senozhatsky@chromium.org>
> Subject: zram: do not slot_free() written-back slots
> Date: Thu, 19 Mar 2026 12:44:56 +0900
>
> slot_free() basically completely resets the slots by clearing all of its
> flags and attributes. While zram_writeback_complete() restores some of
> flags back (those that are necessary for async read decompression) we
> still lose a lot of slot's metadata. For example, slot's ac-time, or
> ZRAM_INCOMPRESSIBLE.
>
> Do not slot_free() on writeback, instead clear only those flags/attrs that
> we need to clear.
Hello Andrew,
I just sent a v2 with updated commit message [1]
[1] https://lore.kernel.org/linux-mm/20260320023143.2372879-1-senozhatsky@chromium.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-20 2:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 22:44 + zram-do-not-slot_free-written-back-slots.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-03-20 2:33 ` Sergey Senozhatsky
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.