[RFC] zram: sleepable async read bio completion
From: Sergey Senozhatsky
Date: Wed Mar 04 2026 - 00:15:22 EST
Hello Jens, Christoph,
zram supports writeback, when "idle" pages are written back to the
actual physical device, so that they can be free from the zsmalloc
pool. Previously, zram would write back such pages un-compressed
(raw), which made async read back rather trivial: just sibmit bio
and return. However, decompression of every writtenback page is
expensive (battery wise), not every written back page is read back.
Therefore zram now also supports compressed writeback, which means
that async read back is not trivial anymore - zram needs to decompress
the page upon bio completion. The problem is that bio completion is
called from atomic context, while zram decompression is sleepable.
So at this point we have to deffer the decompression to a workqueue,
which adds (painful) latency to the read path. We clearly would like
to avoid that workquque offloading. What can we do about it?
A wild idea, (I know it's not perfect), it would be nice if we could
decompress in the same context/task that submitted bio in the first
place. Perhaps via addition callback:
->submit_bio()
reads data async
->post_submit_bio() // random name
decompresses bio page
Is that too ugly to live? Is there a better way to do it?