All of
 help / color / mirror / Atom feed
From: Julia Cartwright <>
To: Alexander Stein <>
Subject: Re: [PATCH 1/1] squashfs: Disable "percpu multiple decompressor" on RT
Date: Wed, 2 May 2018 09:37:29 -0500	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Wed, May 02, 2018 at 03:12:33PM +0200, Alexander Stein wrote:
> This decompressor can introduce a huge latency when a to be executed
> process have to read and decompress directly from mass storage.
> Using a QSPI flash and squashfs, starting htop causes a latency of ~8000µs
> to a running cyclictest. The "multiple decompressor" is fine though.
> The cause is that squashfs_decompress() calls get_cpu_ptr(). If this is
> done on all CPUs no task will be executed until the decompression has
> finished.

Hello Alexander-

Thanks for the patch.

> +++ b/fs/squashfs/Kconfig
> @@ -86,6 +86,7 @@ config SQUASHFS_DECOMP_MULTI
>  	bool "Use percpu multiple decompressors for parallel I/O"
> +	depends on !PREEMPT_RT_BASE

Hmm, I think we'd like to get out of the business of disabling Kconfig
options unless we are absolutely not given any other choice.

Looking at the codepaths involved in this squashfs decompressor, it
seems like this is a perfect candidate for the usage of local locks.
Can you give the following patch a try instead?


-- 8< --
Subject: [PATCH] squashfs: make use of local lock in multi_cpu decompressor

Currently, the squashfs multi_cpu decompressor makes use of
get_cpu_ptr()/put_cpu_ptr(), which unconditionally disable preemption
during decompression.

Because the workload is distributed across CPUs, all CPUs can observe a
very high wakeup latency, which has been seen to be as much as 8000us.

Convert this decompressor to make use of a local lock, which will allow
execution of the decompressor with preemption-enabled, but also ensure
concurrent accesses to the percpu compressor data on the local CPU will
be serialized.

Reported-by: Alexander Stein <>
Signed-off-by: Julia Cartwright <>
 fs/squashfs/decompressor_multi_percpu.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/squashfs/decompressor_multi_percpu.c b/fs/squashfs/decompressor_multi_percpu.c
index 23a9c28ad8ea..661ced620fd1 100644
--- a/fs/squashfs/decompressor_multi_percpu.c
+++ b/fs/squashfs/decompressor_multi_percpu.c
@@ -6,6 +6,7 @@
  * the COPYING file in the top-level directory.
+#include <linux/locallock.h>
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/percpu.h>
@@ -25,6 +26,8 @@ struct squashfs_stream {
 	void		*stream;
+static DEFINE_LOCAL_IRQ_LOCK(stream_lock);
 void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
 						void *comp_opts)
@@ -79,10 +82,15 @@ int squashfs_decompress(struct squashfs_sb_info *msblk, struct buffer_head **bh,
 	struct squashfs_stream __percpu *percpu =
 			(struct squashfs_stream __percpu *) msblk->stream;
-	struct squashfs_stream *stream = get_cpu_ptr(percpu);
-	int res = msblk->decompressor->decompress(msblk, stream->stream, bh, b,
-		offset, length, output);
-	put_cpu_ptr(stream);
+	struct squashfs_stream *stream;
+	int res;
+	stream = get_locked_var(stream_lock, percpu);
+	res = msblk->decompressor->decompress(msblk, stream->stream, bh, b,
+			offset, length, output);
+	put_locked_var(stream_lock, stream);
 	if (res < 0)
 		ERROR("%s decompression failed, data probably corrupt\n",

  reply	other threads:[~2018-05-02 14:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 13:12 [PATCH 1/1] squashfs: Disable "percpu multiple decompressor" on RT Alexander Stein
2018-05-02 14:37 ` Julia Cartwright [this message]
2018-05-03  6:36   ` Alexander Stein
2018-05-03 15:48     ` Julia Cartwright
2018-05-07  6:09       ` Alexander Stein
2018-05-07 13:58         ` [PATCH RT 1/2] locallock: provide {get,put}_locked_ptr() variants Julia Cartwright
2018-05-07 13:58           ` [PATCH RT 2/2] squashfs: make use of local lock in multi_cpu decompressor Julia Cartwright

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.