Skip to contentSkip to conversation

Squashfs: add multi-threaded decompression using percpu variables (V2)

PATCH New Phillip Lougher 1 participant 1 message Nov 18, 2013 SquashFS file system

lore
Share & tools
lore

Phillip Lougher

author maintainer
#0 lore raw

PATCH 1/1 Squashfs: add multi-threaded decompression using percpu variables (V2)

Add a multi-threaded decompression implementation which uses percpu variables.

Using percpu variables has advantages and disadvantages over implementations which do not use percpu variables.

Advantages:
* the nature of percpu variables ensures decompression is load-balanced across the multiple cores.
* simplicity.

Disadvantages: it limits decompression to one thread per core.

V2:
* squashfs_decompressor_create: improve error handling path, re freeing of decompressors and comp_opts
* decompressor_multi_percpu.c: include percpu.h header
* Kconfig: indentation

---
 fs/squashfs/Kconfig                     | 57 ++++++++++++++-----
 fs/squashfs/Makefile                    | 10 +---
 fs/squashfs/decompressor_multi_percpu.c | 98 +++++++++++++++++++++++++++++++++
 3 files changed, 145 insertions(+), 20 deletions(-)
 create mode 100644 fs/squashfs/decompressor_multi_percpu.c
fs/squashfs/Kconfig +44 -13
index 1c6d340..159bd66 100644
@@ -25,6 +25,50 @@ config SQUASHFS
 
 	  If unsure, say N.
 
+choice
+	prompt "Decompressor parallelisation options"
+	depends on SQUASHFS
+	help
+	  Squashfs now supports three parallelisation options for
+	  decompression.  Each one exhibits various trade-offs between
+	  decompression performance and CPU and memory usage.
+
+	  If in doubt, select "Single threaded compression"
+
+config SQUASHFS_DECOMP_SINGLE
+	bool "Single threaded compression"
+	help
+	  Traditionally Squashfs has used single-threaded decompression.
+	  Only one block (data or metadata) can be decompressed at any
+	  one time.  This limits CPU and memory usage to a minimum.
+
+config SQUASHFS_DECOMP_MULTI
+	bool "Use multiple decompressors for parallel I/O"
+	help
+	  By default Squashfs uses a single decompressor but it gives
+	  poor performance on parallel I/O workloads when using multiple CPU
+	  machines due to waiting on decompressor availability.
+
+	  If you have a parallel I/O workload and your system has enough memory,
+	  using this option may improve overall I/O performance.
+
+	  This decompressor implementation uses up to two parallel
+	  decompressors per core.  It dynamically allocates decompressors
+	  on a demand basis.
+
+config SQUASHFS_DECOMP_MULTI_PERCPU
+	bool "Use percpu multiple decompressors for parallel I/O"
+	help
+	  By default Squashfs uses a single decompressor but it gives
+	  poor performance on parallel I/O workloads when using multiple CPU
+	  machines due to waiting on decompressor availability.
+
+	  This decompressor implementation uses a maximum of one
+	  decompressor per core.  It uses percpu variables to ensure
+	  decompression is load-balanced across the cores.
+
+endchoice
+
 config SQUASHFS_XATTR
 	bool "Squashfs XATTR support"
 	depends on SQUASHFS
@@ -63,19 +107,6 @@ config SQUASHFS_LZO
 
 	  If unsure, say N.
 
-config SQUASHFS_MULTI_DECOMPRESSOR
-	bool "Use multiple decompressors for handling parallel I/O"
-	depends on SQUASHFS
-	help
-	  By default Squashfs uses a single decompressor but it gives
-	  poor performance on parallel I/O workloads when using multiple CPU
-	  machines due to waiting on decompressor availability.
-
-	  If you have a parallel I/O workload and your system has enough memory,
-	  using this option may improve overall I/O performance.
-
-	  If unsure, say N.
-
 config SQUASHFS_XZ
 	bool "Include support for XZ compressed file systems"
 	depends on SQUASHFS
fs/squashfs/Makefile +3 -7
index dfebc3b..5833b96 100644
@@ -5,14 +5,10 @@
 obj-$(CONFIG_SQUASHFS) += squashfs.o
 squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
 squashfs-y += namei.o super.o symlink.o decompressor.o
-
+squashfs-$(CONFIG_SQUASHFS_DECOMP_SINGLE) += decompressor_single.o
+squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI) += decompressor_multi.o
+squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.o
 squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o
 squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
 squashfs-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
 squashfs-$(CONFIG_SQUASHFS_ZLIB) += zlib_wrapper.o
-
-ifdef CONFIG_SQUASHFS_MULTI_DECOMPRESSOR
-	squashfs-y		+= decompressor_multi.o
-else
-	squashfs-y		+= decompressor_single.o
-endif
fs/squashfs/decompressor_multi_percpu.c new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
1.8.3.2