]> www.infradead.org Git - users/jedix/linux-maple.git/commit
zram: permit preemption with active compression stream
authorSergey Senozhatsky <senozhatsky@chromium.org>
Fri, 21 Feb 2025 22:25:33 +0000 (07:25 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 28 Feb 2025 01:00:22 +0000 (17:00 -0800)
commit6052b5c7df9bf62d14dc3edeac878bf4d1e7fee4
tree0855a38a889cb0632826bd8e9f59a4b87a76a960
parented0505a959054e6dcf2cf56ae30607028cebef0d
zram: permit preemption with active compression stream

Currently, per-CPU stream access is done from a non-preemptible (atomic)
section, which imposes the same atomicity requirements on compression
backends as entry spin-lock, and makes it impossible to use algorithms
that can schedule/wait/sleep during compression and decompression.

Switch to preemptible per-CPU model, similar to the one used in zswap.
Instead of a per-CPU local lock, each stream carries a mutex which is
locked throughout entire time zram uses it for compression or
decompression, so that cpu-dead event waits for zram to stop using a
particular per-CPU stream and release it.

Link: https://lkml.kernel.org/r/20250221222958.2225035-3-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Suggested-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Reviewed-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zcomp.c
drivers/block/zram/zcomp.h
drivers/block/zram/zram_drv.c