* [PATCH] zram: Avoid duplicate slots in batched writeback
@ 2026-11-10 6:18 raoxu
2026-11-10 6:40 ` Sergey Senozhatsky
0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-11-10 6:18 UTC (permalink / raw)
To: minchan; +Cc: senozhatsky, axboe, linux-kernel, linux-block, raoxu
From: Xu Rao <raoxu@uniontech.com>
The writeback interface accepts multiple page_index and page_indexes
parameters in one operation. Their ranges can overlap, but
scan_slots_for_writeback() only excludes slots that are already being
written back or marked as same-filled.
A slot selected by an earlier range is placed on the post-processing list
and marked with ZRAM_PP_SLOT. Without checking that flag, an overlapping
range can enqueue the same slot again and submit it for writeback more
than once.
Skip slots already marked ZRAM_PP_SLOT while holding the slot lock. This
keeps each slot in a writeback scan session represented by at most one
post-processing entry and leaves the existing release and reuse paths
unchanged.
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
drivers/block/zram/zram_drv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index ab064c84b092..50a25989a23b 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1215,6 +1215,9 @@ static void scan_slots_for_writeback(struct zram *zram, u32 mode,
if (!slot_allocated(zram, index))
goto next;
+ if (test_slot_flag(zram, index, ZRAM_PP_SLOT))
+ goto next;
+
if (test_slot_flag(zram, index, ZRAM_WB) ||
test_slot_flag(zram, index, ZRAM_SAME))
goto next;
--
2.50.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] zram: Avoid duplicate slots in batched writeback
2026-11-10 6:18 [PATCH] zram: Avoid duplicate slots in batched writeback raoxu
@ 2026-11-10 6:40 ` Sergey Senozhatsky
0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-11-10 6:40 UTC (permalink / raw)
To: Andrew Morton, Jens Axboe, raoxu
Cc: minchan, senozhatsky, linux-kernel, linux-block
On (26/11/10 14:18), raoxu wrote:
> The writeback interface accepts multiple page_index and page_indexes
> parameters in one operation. Their ranges can overlap, but
> scan_slots_for_writeback() only excludes slots that are already being
> written back or marked as same-filled.
>
> A slot selected by an earlier range is placed on the post-processing list
> and marked with ZRAM_PP_SLOT. Without checking that flag, an overlapping
> range can enqueue the same slot again and submit it for writeback more
> than once.
>
> Skip slots already marked ZRAM_PP_SLOT while holding the slot lock. This
> keeps each slot in a writeback scan session represented by at most one
> post-processing entry and leaves the existing release and reuse paths
> unchanged.
>
> Signed-off-by: Xu Rao <raoxu@uniontech.com>
LGTM.
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Jens, do you want to pick it up and route via block tree or should
we route via "more traditional" tree (Andrew's tree)?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-10 6:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 6:18 [PATCH] zram: Avoid duplicate slots in batched writeback raoxu
2026-11-10 6:40 ` Sergey Senozhatsky
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®