]> www.infradead.org Git - users/jedix/linux-maple.git/commit
zram: permit only one post-processing operation at a time
authorSergey Senozhatsky <senozhatsky@chromium.org>
Tue, 17 Sep 2024 02:09:07 +0000 (11:09 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:28:42 +0000 (21:28 -0700)
commitb0334d344dc5183e51a6fc6b4fd079500e2491de
tree3ae49108a95a1bb488119f59ae757445982045b4
parent555114f0dabbe449c50ce2bd057f389f95023cb9
zram: permit only one post-processing operation at a time

Both recompress and writeback soon will unlock slots during processing,
which makes things too complex wrt possible race-conditions.  We still
want to clear PP_SLOT in slot_free, because this is how we figure out that
slot that was selected for post-processing has been released under us and
when we start post-processing we check if slot still has PP_SLOT set.  At
the same time, theoretically, we can have something like this:

CPU0     CPU1

recompress
scan slots
set PP_SLOT
unlock slot
slot_free
clear PP_SLOT

allocate PP_SLOT
writeback
scan slots
set PP_SLOT
unlock slot
select PP-slot
test PP_SLOT

So recompress will not detect that slot has been re-used and re-selected
for concurrent writeback post-processing.

Make sure that we only permit on post-processing operation at a time.  So
now recompress and writeback post-processing don't race against each
other, we only need to handle slot re-use (slot_free and write), which is
handled individually by each pp operation.

Having recompress and writeback competing for the same slots is not
exactly good anyway (can't imagine anyone doing that).

Link: https://lkml.kernel.org/r/20240917021020.883356-3-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/admin-guide/blockdev/zram.rst
drivers/block/zram/zram_drv.c
drivers/block/zram/zram_drv.h