Re: [PATCH v6 09/13] zram: split zcomp into separate R/W streams
From: Barry Song
Date: Wed Oct 21 2026 - 20:20:05 EST
On Thu, Oct 22, 2026 at 8:12 AM Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> On Wed, 21 Oct 2026 15:53:21 +0800 Hillf Danton wrote:
> >On Wed, 21 Oct 2026 13:56:17 +0900 Sergey Senozhatsky wrote:
> >>On (26/10/21 12:23), Hillf Danton wrote:
> >>> On Wed, 21 Oct 2026 11:42:19 +0900 Sergey Senozhatsky wrote:
> >>> > Split struct zcomp_strm into separate compression (Write zcomp_cstrm)
> >>> > and decompression (Read zcomp_dstrm) streams, and split zcomp_ops
> >>> > context creation/destruction into create_cctx/destroy_cctx and
> >>> > optional create_dctx/destroy_dctx callbacks.
> >>> >
> >>> > This decouples Read (decompression) and Write (compression) paths so
> >>> > they no longer contend on the same per-CPU stream mutex (Writer vs
> >>> > Reader priority inversion). Currently, a (low priority) Writer that
> >>> > holds the stream mutex can be preempted by a (higher priority) Reader
> >>> > on the same CPU, which then blocks on that mutex until the Writer gets
> >>> > to run again and releases it, which can take a long time when there
> >>> > are other runnable tasks on that CPU.
> >>> >
> >>> Given lock like mutex, priority inversion happens from Monday to Friday,
> >>> but I wonder if you are inventing some wheels in 2026 if proxy excution
> >>> works for you.
> >>
> >> Reader-Writer split is a foundation for further improvements (like
> >> singleton recompression stream and so on).
> >>
> > But that split is not needed at all if PE works, yes?
> >
> Because PE is good at handling complex priority hiarchy. In a simple case,
> task1(priority=1) is the owner of lock1 with two waiters, task2(priority=2)
> and task3(priority=3), while task3 is the owner of lock2 also with two waiters,
> task4(priority=5) and task5(priority=7).
>
> When the number of locks and tasks grows, I have increasing difficulty even
> describing the lock chain that you in combination with Brian are unable to
> handle. That is why in general PE is prefered over whatever wheels you can create.
>
I still believe that reducing lock contention is the most correct way
to address lock
contention.
Proxy execution and other priority-inheritance mechanisms can help in
some cases,
but they also have downsides. For example, allowing a low-priority
task to run at a
high priority can affect other tasks. When many tasks require proxy execution or
priority inheritance, they still compete for the same resources.
So I'd vote for reducing lock contention as the first option. If that
turns out to be
impractical, we can consider priority inheritance.
Best Regards
Barry