mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Walker <danielwa@cisco.com>
To: Phillip Lougher <phillip@squashfs.org.uk>
Cc: "yusun2@cisco.com" <yusun2@cisco.com>,
	xe-linux-external@cisco.com, Daniel Walker <dwalker@fifo99.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] fs/squashfs: Make SquashFS xz initialization mode configurable
Date: Fri,  8 Nov 2019 12:00:39 -0800	[thread overview]
Message-ID: <20191108200040.20259-1-danielwa@cisco.com> (raw)

From: "yusun2@cisco.com" <yusun2@cisco.com>

Make SquashFS xz initialization mode configurable to be either
XZ_PREALLOC or XZ_DYNALLOC. The default mode is XZ_PREALLOC.

SquashFS multi-threaded per-CPU decompressor is proven to
effectively resolve the I/O bottleneck and boost the outcome
of other boot time optimization technologies on some I/O bound
platforms. However it allocates extra memory on per-processor
per-mounted-package basis. Making XZ_DYNALLOC mode an option
for the xz decompressor initialization in SquashFS minimizes
the memory impact.

Signed-off-by: Yu Sun <yusun2@cisco.com>
Cc: xe-linux-external@cisco.com
Signed-off-by: Daniel Walker <dwalker@fifo99.com>
---
 fs/squashfs/Kconfig      | 32 ++++++++++++++++++++++++++++++++
 fs/squashfs/xz_wrapper.c |  6 +++++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index 916e78fabcaa..9cf2ebf89374 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -223,3 +223,35 @@ config SQUASHFS_FRAGMENT_CACHE_SIZE
 
 	  Note there must be at least one cached fragment.  Anything
 	  much more than three will probably not make much difference.
+
+choice
+    prompt "XZ decompressor operation mode"
+    depends on SQUASHFS_XZ
+    default SQUASHFS_XZ_DICT_PREALLOC
+    help
+      Squashfs now utilizes the two different multi-call modes of xz
+      decompression. They each exhibits various trade-offs between
+      decompression performance and memory consumption.
+
+      If in doubt, select "XZ preallocated multi-call mode"
+
+config SQUASHFS_XZ_DICT_PREALLOC
+    bool "XZ preallocated multi-call mode"
+    help
+      Traditionally Squashfs has used XZ_PREALLOC operation mode for
+      xz decompression, under which the xz dictionary buffer is allocated
+      at initialization.
+
+config SQUASHFS_XZ_DICT_DYNALLOC
+    bool "XZ dynamic-allocated multi-call mode"
+    help
+      By default Squashfs uses XZ_PREALLOC operation mode for xz decompressor.
+      This, however, potentially lead to significant increase of memory
+      consumption, especially when SquashFS per-cpu multi-threaded
+      decompressor is applied.
+
+      If the system has memory constraints, setting this option will force
+      SquashFS to use XZ_DYNALLOC mode, and thus reduce memory footprint.
+      In this case, the LZMA2 dictionary is allocated upon needed with the
+      required size.
+endchoice
diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c
index 4b2f2051a6dc..6d6946bb5e4c 100644
--- a/fs/squashfs/xz_wrapper.c
+++ b/fs/squashfs/xz_wrapper.c
@@ -90,7 +90,11 @@ static void *squashfs_xz_init(struct squashfs_sb_info *msblk, void *buff)
 		goto failed;
 	}
 
-	stream->state = xz_dec_init(XZ_PREALLOC, comp_opts->dict_size);
+	if (IS_ENABLED(CONFIG_SQUASHFS_XZ_DICT_DYNALLOC)) {
+	    stream->state = xz_dec_init(XZ_DYNALLOC, comp_opts->dict_size);
+	} else {
+	    stream->state = xz_dec_init(XZ_PREALLOC, comp_opts->dict_size);
+	}
 	if (stream->state == NULL) {
 		kfree(stream);
 		err = -ENOMEM;
-- 
2.17.1


                 reply	other threads:[~2019-11-08 20:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191108200040.20259-1-danielwa@cisco.com \
    --to=danielwa@cisco.com \
    --cc=dwalker@fifo99.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@squashfs.org.uk \
    --cc=xe-linux-external@cisco.com \
    --cc=yusun2@cisco.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®