]> Gentwo Git Trees - linux/.git/commit
zram: cond_resched() in writeback loop
authorSergey Senozhatsky <senozhatsky@chromium.org>
Wed, 18 Dec 2024 06:34:24 +0000 (15:34 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 14 Jan 2025 06:41:05 +0000 (22:41 -0800)
commit66ab1fb71c6f542b50542425554cdeece6b936a4
tree086cdc1436cf182ef3880d80a0453e9b510211f6
parentaf28bf8ee6ff1ae8a5c9ac5556ce0746a11850db
zram: cond_resched() in writeback loop

zram writeback is a costly operation, because every target slot (unless
ZRAM_HUGE) is decompressed before it gets written to a backing device.
The writeback to a backing device uses submit_bio_wait() which may look
like a rescheduling point.  However, if the backing device has
BD_HAS_SUBMIT_BIO bit set __submit_bio() calls directly
disk->fops->submit_bio(bio) on the backing device and so when
submit_bio_wait() calls blk_wait_io() the I/O is already done.  On such
systems we effective end up in a loop

    for_each (target slot) {
decompress(slot)
__submit_bio()
    disk->fops->submit_bio(bio)
    }

Which on PREEMPT_NONE systems triggers watchdogs (since there are no
explicit rescheduling points).  Add cond_resched() to the zram writeback
loop.

Link: https://lkml.kernel.org/r/20241218063513.297475-8-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>
drivers/block/zram/zram_drv.c