From: Hillf Danton <hdanton@sina.com>
To: Barry Song <21cnbao@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Brian Geffon <bgeffon@google.com>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v6 09/13] zram: split zcomp into separate R/W streams
Date: Thu, 22 Oct 2026 19:11:48 +0800 [thread overview]
Message-ID: <20261022111151.960-1-hdanton@sina.com> (raw)
In-Reply-To: <CAGsJ_4wMQteCGxQ7wxUKP2g96myo91ipF_zedFVVbxKdDrb=bA@mail.gmail.com>
On Thu, 22 Oct 2026 08:19:41 +0800 Barry Song wrote:
>On Thu, Oct 22, 2026 at 8:12 AM Hillf Danton <hdanton@sina.com> 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.
>
Given the log message above, I dont think the issue in question is the regular
lock contention, but priority inversion caused by preempt. Due to preempt, the
preempter becomes lock waiter without spinning for lock owner, which I think
creates the issue. Particularly given the spin for owner in mutex, if the lock
is hot then the critical section is supposed to be not well implemented.
What Sergey did not show is -- what if the preemptee gets back on cpu at the
preempter's priority after preempt, with the critical section assumed good.
This can be checked by making the Writer high priority instead.
What I am confused is -- why decompression needs to run faster without boosting
compression up. Where is the compressed material?
> 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
No agree. Just because of the high priority lock waiter, low priority lock
owner can run at the high priority, so the priority inversion is effectively
erased, particularly given a well implemented critical section.
> priority inheritance, they still compete for the same resources.
>
Even when lock contension rises, the lock owner runs at the priority as
high as the lock chain can offer.
>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
next prev parent reply other threads:[~2026-10-22 11:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 2:42 [PATCH v6 00/13] zram: redesign zcomp and rework backends Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 01/13] zram: prefix backends printk-s Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 02/13] zram: remove debugfs entry on init failure Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 03/13] zram: reset writeback state in zram_reset_device() Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 04/13] zram: zstd: do not allocate empty C/D-dictionaries Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 05/13] zram: lz4hc: pre-initialize dictionary stream in setup_params Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 06/13] zram: lz4: use LZ4_decompress_safe_usingDict() Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 07/13] zram: lz4hc: " Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 08/13] zram: zstd: do not use kvzalloc() for zstd allocations Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 09/13] zram: split zcomp into separate R/W streams Sergey Senozhatsky
2026-10-21 4:23 ` Hillf Danton
2026-10-21 4:56 ` Sergey Senozhatsky
2026-10-21 7:53 ` Hillf Danton
2026-10-22 0:08 ` Hillf Danton
2026-10-22 0:19 ` Barry Song
2026-10-22 11:11 ` Hillf Danton [this message]
2026-10-22 2:06 ` Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 10/13] zram: introduce shared decompression streams Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 11/13] zram: allocate bounce buffer for spanning objects Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 12/13] zram: borrow idle decompression streams in exclusive mode Sergey Senozhatsky
2026-10-21 2:42 ` [PATCH v6 13/13] zram: use a singleton compression context for recompression Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022111151.960-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bgeffon@google.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®