mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Brian Geffon <bgeffon@google.com>,
	Minchan Kim <minchan@kernel.org>,
	 Richard Chang <richardycc@google.com>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	 linux-mm@kvack.org
Subject: Re: [PATCH v2 11/11] zram: use rw_semaphore for decompression streams
Date: Sun, 11 Oct 2026 13:28:01 +0900	[thread overview]
Message-ID: <assQJStvoDK0nepk@google.com> (raw)
In-Reply-To: <20261009071157.3730698-12-senozhatsky@chromium.org>

On (26/10/09 16:11), Sergey Senozhatsky wrote:
> Currently, per-CPU decompression streams use a mutex, so there is
> a chance for priority inversion - a low priority Reader can get
> preempted by a higher priority Reader, which simply will get
> blocked on the stream mutex.
> 
> Switch zcomp_dstrm lock from mutex to rw_semaphore to permit parallel
> usage.  However, things are not completely straightforward.  Many
> backends have stateless decompression and don't modify decompression
> context, so those can be used concurrently.  But then there are backends
> that do modify decompression context.  We also can have compressed
> object span across physical pages, which zcomp linearises using stream's
> ->local_copy buffer before decompression.  That buffer, clearly, cannot
> be used concurrently.
> 
> When the backend has no per-stream decompression context (stateless)
> and zsmalloc object fits in a single page (ZCOMP_DECOMP_INPLACE), take
> the stream lock in shared mode (read).  Otherwise, when ->local_copy
> is needed (ZCOMP_DECOMP_BOUNCE) or the backend has a decompression
> context (zstd, deflate), take the lock in exclusive mode (write).
> 
> A quick synthetic fio test on 24 CPUs (preempt=full, lz4, 48 low
> priority (nice 19) readers, 24 normal priority (nice 0) CPU hogs
> and 24 high priority (nice -19) readers):
> 
>   Metric           Base               Patched
>   ----------------------------------------------------------
>   Read IOPS        473k               680k          (+43.8%)
>   Read clat avg    35.98 us           21.28 us      (-40.9%)
>   Read clat p99.95 55.55 us           20.86 us      (-2.7x)
>   Read clat p99.99 6,717 us           2,834 us      (-2.4x)
>   Read clat max    2,005,100 us       1,614,300 us  (-19.5%)
> 
> Suggested-by: Brian Geffon <bgeffon@google.com>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>

JFI
I have completely reworked this patch.  Will run tests and then
send out v3.

      reply	other threads:[~2026-10-11  4:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09  7:11 [PATCH v2 00/11] zram: redesign zcomp and rework backends Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 01/11] zram: prefix backends printk-s Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 02/11] zram: remove debugfs entry on init failure Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 03/11] zram: zstd: do not allocate empty C/D-dictionaries Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 04/11] zram: lz4hc: pre-initialize dictionary stream in setup_params Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 05/11] zram: lz4: use LZ4_decompress_safe_usingDict() Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 06/11] zram: lz4hc: " Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 07/11] zram: zstd: do not use kvzalloc() for zstd allocations Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 08/11] zram: reset writeback state in zram_reset_device() Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 09/11] zram: split zcomp into separate R/W streams Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 10/11] zram: use a singleton compression context for recompression Sergey Senozhatsky
2026-10-09  7:11 ` [PATCH v2 11/11] zram: use rw_semaphore for decompression streams Sergey Senozhatsky
2026-10-11  4:28   ` Sergey Senozhatsky [this message]

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=assQJStvoDK0nepk@google.com \
    --to=senozhatsky@chromium.org \
    --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=minchan@kernel.org \
    --cc=richardycc@google.com \
    /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®