mm: unify default compressor algorithm for zram/zswap
Subsystems (8)
cover mm: unify default compressor algorithm for zram/zswap
Both zram and zswap are used to reduce memory usage by compressing cold page, a default compressor algorithm is selected from kinds of compressor algorithm as the default one from very similar Kconfig, also both of them could change the algorithm by sysfs interfaces, so unify the default compressor algorithm to cleanup the default algorithm chosen.
Kefeng Wang (5):
zram: zcomp: remove zcomp_set_max_streams() declaration
zram: make zram depends on SWAP
zram: support deflate compressor
mm: zswap: default to lzo-rle instead of lzo
mm: unify default compressor algorithm for zswap and zram
Documentation/admin-guide/mm/zswap.rst | 2 +- arch/loongarch/configs/loongson3_defconfig | 2 +- drivers/block/zram/Kconfig | 44 +------ drivers/block/zram/zcomp.c | 3 + drivers/block/zram/zcomp.h | 1 - drivers/block/zram/zram_drv.c | 2 +- mm/Kconfig | 134 +++++++++++---------- mm/zswap.c | 8 +- 8 files changed, 83 insertions(+), 113 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/5 zram: zcomp: remove zcomp_set_max_streams() declaration
The zcomp_set_max_streams() is removed from commit 43209ea2d17a ("zram: remove max_comp_streams internals"), remove the declaration.
--- drivers/block/zram/zcomp.h | 1 - 1 file changed, 1 deletion(-)
drivers/block/zram/zcomp.h +0 -1
@@ -39,5 +39,4 @@ int zcomp_compress(struct zcomp_strm *zstrm,int zcomp_decompress (struct zcomp_strm *zstrm,const void *src,unsigned int src_len,void *dst); -bool zcomp_set_max_streams (struct zcomp *comp,int num_strm);#endif /* _ZCOMP_H_ */
Signature · 1 line
2.27.0
PATCH 2/5 zram: make zram depends on SWAP
In reply to Kefeng WangThe zram is useless when SWAP is disabled, make zram depends on SWAP.
--- drivers/block/zram/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zram/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 config ZRAM tristate "Compressed RAM block device support" - depends on BLOCK && SYSFS && MMU + depends on SWAP && SYSFS depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 select ZSMALLOC help
Signature · 1 line
2.27.0
Sergey Senozhatsky
maintainerRe: [PATCH 2/5] zram: make zram depends on SWAP
Quoted 3 lines · Kefeng Wang
The zram is useless when SWAP is disabled, make zram depends on SWAP.
I'm sorry, this doesn't make a lot of sense to me. zram is a generic block device.
PATCH 3/5 zram: support deflate compressor
In reply to Kefeng WangAdd deflate compressor support, also it is prepare for unifying the default compressor compressor for zram and zswap.
--- drivers/block/zram/Kconfig | 7 ++++++- drivers/block/zram/zcomp.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/block/zram/Kconfig +6 -1
@@ -2,7 +2,7 @@ config ZRAM tristate "Compressed RAM block device support" depends on SWAP && SYSFS - depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 + depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 || CRYPTO_DEFLATE select ZSMALLOC help Creates virtual block devices called /dev/zramX (X = 0, 1, ...).
@@ -20,6 +20,10 @@ choice default ZRAM_DEF_COMP_LZORLE depends on ZRAM +config ZRAM_DEF_COMP_DEFLATE + bool "Deflate" + depends on CRYPTO_DEFLATE + config ZRAM_DEF_COMP_LZORLE bool "lzo-rle" depends on CRYPTO_LZO
@@ -48,6 +52,7 @@ endchoice config ZRAM_DEF_COMP string + default "deflate" if ZRAM_DEF_COMP_DEFLATE default "lzo-rle" if ZRAM_DEF_COMP_LZORLE default "zstd" if ZRAM_DEF_COMP_ZSTD default "lz4" if ZRAM_DEF_COMP_LZ4
drivers/block/zram/zcomp.c +3 -0
@@ -16,6 +16,9 @@#include "zcomp.h" static const char *const backends[] = { +#if IS_ENABLED(CONFIG_CRYPTO_DEFLATE) +"deflate" , +#endif #if IS_ENABLED(CONFIG_CRYPTO_LZO)"lzo" , "lzo-rle",
Signature · 1 line
2.27.0
PATCH 4/5 mm: zswap: default to lzo-rle instead of lzo
In reply to Kefeng WangSince lzo-rle performance is better than lzo, see commit ce82f19fd580 ("zram: default to lzo-rle instead of lzo"), converting zswap to use lze-rle too.
--- mm/Kconfig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
mm/Kconfig +9 -2
@@ -62,7 +62,7 @@ config ZSWAP_SHRINKER_DEFAULT_ON choice prompt "Default compressor" depends on ZSWAP - default ZSWAP_COMPRESSOR_DEFAULT_LZO + default ZSWAP_COMPRESSOR_DEFAULT_LZORLE help Selects the default compression algorithm for the compressed cache for swap pages.
@@ -72,7 +72,7 @@ choice available at the following LWN page: https://lwn.net/Articles/751795/ - If in doubt, select 'LZO'. + If in doubt, select 'LZO-RLE'. The selection made here can be overridden by using the kernel command line 'zswap.compressor=' option.
@@ -83,6 +83,12 @@ config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE help Use the Deflate algorithm as the default compression algorithm. +config ZSWAP_COMPRESSOR_DEFAULT_LZORLE + bool "LZO-RLE" + select CRYPTO_LZO + help + Use the LZO algorithm as the default compression algorithm. + config ZSWAP_COMPRESSOR_DEFAULT_LZO bool "LZO" select CRYPTO_LZO
@@ -118,6 +124,7 @@ config ZSWAP_COMPRESSOR_DEFAULT string depends on ZSWAP default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE + default "lzo-rle" if ZSWAP_COMPRESSOR_DEFAULT_LZORLE default "lzo" if ZSWAP_COMPRESSOR_DEFAULT_LZO default "842" if ZSWAP_COMPRESSOR_DEFAULT_842 default "lz4" if ZSWAP_COMPRESSOR_DEFAULT_LZ4
Signature · 1 line
2.27.0
PATCH 5/5 mm: unify default compressor algorithm for zswap and zram
In reply to Kefeng WangBoth zswap and zram could change compressor algorithm dynamically, it can be overridden at boot time by 'zswap.compressor=' for zswap, also there is a sysfs interface to change it, see
/sys/block/zramX/comp_algorithm /sys/module/zswap/parameters/compressor
So there is no need to maintain independence default compressor algorithm, unify the Kconfig to use lzo-rle as the default page compressor algorithm.
--- Documentation/admin-guide/mm/zswap.rst | 2 +- arch/loongarch/configs/loongson3_defconfig | 2 +- drivers/block/zram/Kconfig | 47 +------- drivers/block/zram/zram_drv.c | 2 +- mm/Kconfig | 131 +++++++++++---------- mm/zswap.c | 8 +- 6 files changed, 74 insertions(+), 118 deletions(-)
Documentation/admin-guide/mm/zswap.rst +1 -1
@@ -90,7 +90,7 @@ controlled policy: * max_pool_percent - The maximum percentage of memory that the compressed pool can occupy. -The default compressor is selected in ``CONFIG_ZSWAP_COMPRESSOR_DEFAULT`` +The default compressor is selected in ``CONFIG_COMPRESSOR_DEFAULT`` Kconfig option, but it can be overridden at boot time by setting the ``compressor`` attribute, e.g. ``zswap.compressor=lzo``. It can also be changed at runtime using the sysfs "compressor"
arch/loongarch/configs/loongson3_defconfig +1 -1
@@ -91,7 +91,7 @@ CONFIG_BFQ_GROUP_IOSCHED=y CONFIG_BINFMT_MISC=m CONFIG_ZPOOL=y CONFIG_ZSWAP=y -CONFIG_ZSWAP_COMPRESSOR_DEFAULT_ZSTD=y +CONFIG_COMPRESSOR_DEFAULT_ZSTD=y CONFIG_ZBUD=y CONFIG_Z3FOLD=y CONFIG_ZSMALLOC=m
drivers/block/zram/Kconfig +1 -46
59 lines not on this page · raw message
drivers/block/zram/zram_drv.c +1 -1
@@ -41,7 +41,7 @@ static DEFINE_IDR(zram_index_idr);static DEFINE_MUTEX (zram_index_mutex);static int zram_major; -static const char *default_compressor =CONFIG_ZRAM_DEF_COMP ; +static const char *default_compressor =CONFIG_COMPRESSOR_DEFAULT ;/* Module params (documentation at end) */ static unsigned int num_devices =1 ;
mm/Kconfig +66 -65
197 lines not on this page · raw message
mm/zswap.c +4 -4
@@ -96,7 +96,7 @@ static const struct kernel_param_ops zswap_enabled_param_ops = {module_param_cb (enabled, &zswap_enabled_param_ops, &zswap_enabled,0644 );/* Crypto compressor to use */ -static char *zswap_compressor =CONFIG_ZSWAP_COMPRESSOR_DEFAULT ; +static char *zswap_compressor =CONFIG_COMPRESSOR_DEFAULT ;static int zswap_compressor_param_set (const char *,const struct kernel_param *);static const struct kernel_param_ops zswap_compressor_param_ops = {
@@ -386,11 +386,11 @@ static struct zswap_pool *__zswap_pool_create_fallback(void) has_comp =crypto_has_acomp (zswap_compressor,0 ,0 );if (!has_comp &&strcmp (zswap_compressor, -CONFIG_ZSWAP_COMPRESSOR_DEFAULT )) { +CONFIG_COMPRESSOR_DEFAULT )) {pr_err ("compressor %s not available, using default %s\n" , - zswap_compressor,CONFIG_ZSWAP_COMPRESSOR_DEFAULT ); + zswap_compressor,CONFIG_COMPRESSOR_DEFAULT );param_free_charp (&zswap_compressor); - zswap_compressor =CONFIG_ZSWAP_COMPRESSOR_DEFAULT ; + zswap_compressor =CONFIG_COMPRESSOR_DEFAULT ; has_comp =crypto_has_acomp (zswap_compressor,0 ,0 ); }if (!has_comp) {
Signature · 1 line
2.27.0
Quoted 6 lines · Kefeng Wang
Both zram and zswap are used to reduce memory usage by compressing cold page, a default compressor algorithm is selected from kinds of compressor algorithm as the default one from very similar
Kconfig, also both of them could change the algorithm by sysfs interfaces, so unify the default compressor algorithm to cleanup the default algorithm chosen.
Both zswap and zram *can* be used for compressed swap, but zram is a generic block device that has other use cases, see
https://docs.kernel.org/admin-guide/blockdev/zram.html.
For starters, making zram depend on SWAP may break some of those use cases.
Otherwise, I don't immediately see the benefit of unifying the config options for two independent subsystems just because they both use "compression". The reduction of the config options is nice, but in this case I am not sure it's doing more good than harm. Also, most people use either zswap or zram in my experience, so they don't really have to configure both anyway.
Quoted 21 lines
Kefeng Wang (5):
zram: zcomp: removezcomp_set_max_streams()declaration
zram: make zram depends on SWAP
zram: support deflate compressor
mm: zswap: default to lzo-rle instead of lzo
mm: unify default compressor algorithm for zswap and zramDocumentation/admin-guide/mm/zswap.rst | 2 +- arch/loongarch/configs/loongson3_defconfig | 2 +- drivers/block/zram/Kconfig | 44 +------ drivers/block/zram/zcomp.c | 3 + drivers/block/zram/zcomp.h | 1 - drivers/block/zram/zram_drv.c | 2 +- mm/Kconfig | 134 +++++++++++---------- mm/zswap.c | 8 +- 8 files changed, 83 insertions(+), 113 deletions(-)--
2.27.0
Quoted 12 lines · Yosry Ahmed
Quoted 6 lines · Kefeng Wang
Both zram and zswap are used to reduce memory usage by compressing cold page, a default compressor algorithm is selected from kinds of compressor algorithm as the default one from very similar
Kconfig, also both of them could change the algorithm by sysfs interfaces, so unify the default compressor algorithm to cleanup the default algorithm chosen.Both zswap and zram *can* be used for compressed swap, but zram is a generic block device that has other use cases, see
https://docs.kernel.org/admin-guide/blockdev/zram.html.
Quoted 8 lines
For starters, making zram depend on SWAP may break some of those use cases.
Otherwise, I don't immediately see the benefit of unifying the config options for two independent subsystems just because they both use "compression". The reduction of the config options is nice, but in this case I am not sure it's doing more good than harm. Also, most people use either zswap or zram in my experience, so they don't really have to configure both anyway.
Fair enough, then, please ignore the patches, thanks.
Quoted 22 lines
Quoted 22 lines
Kefeng Wang (5):
zram: zcomp: removezcomp_set_max_streams()declaration
zram: make zram depends on SWAP
zram: support deflate compressor
mm: zswap: default to lzo-rle instead of lzo
mm: unify default compressor algorithm for zswap and zramDocumentation/admin-guide/mm/zswap.rst | 2 +- arch/loongarch/configs/loongson3_defconfig | 2 +- drivers/block/zram/Kconfig | 44 +------ drivers/block/zram/zcomp.c | 3 + drivers/block/zram/zcomp.h | 1 - drivers/block/zram/zram_drv.c | 2 +- mm/Kconfig | 134 +++++++++++---------- mm/zswap.c | 8 +- 8 files changed, 83 insertions(+), 113 deletions(-)--
2.27.0
Sergey Senozhatsky
maintainerQuoted 9 lines · Kefeng Wang
Both zram and zswap are used to reduce memory usage by compressing cold page, a default compressor algorithm is selected from kinds of compressor algorithm as the default one from very similar
Kconfig, also both of them could change the algorithm by sysfs interfaces, so unify the default compressor algorithm to cleanup the default algorithm chosen.Kefeng Wang (5):
zram: zcomp: removezcomp_set_max_streams()declaration
I'm afraid this (1/5) is the only patch in the series that we can land.
The rest of the series doesn't look beneficial nor correct. Sorry.
Quoted 4 lines
zram: make zram depends on SWAP
zram: support deflate compressor
mm: zswap: default to lzo-rle instead of lzo
mm: unify default compressor algorithm for zswap and zram
Quoted 8 lines · Sergey Senozhatsky
Quoted 7 lines · Kefeng Wang
Both zram and zswap are used to reduce memory usage by compressing cold page, a default compressor algorithm is selected from kinds of compressor algorithm as the default one from very similar
Kconfig, also both of them could change the algorithm by sysfs interfaces, so unify the default compressor algorithm to cleanup the default algorithm chosen.
Quoted 6 lines
Quoted 2 lines
Kefeng Wang (5):
zram: zcomp: removezcomp_set_max_streams()declarationI'm afraid this (1/5) is the only patch in the series that we can land.
The rest of the series doesn't look beneficial nor correct. Sorry.
OK, please ignore the reset of patches, Andrew, could you only pick the first one, thanks.
Quoted 5 lines
Quoted 5 lines
zram: make zram depends on SWAP
zram: support deflate compressor
mm: zswap: default to lzo-rle instead of lzo
mm: unify default compressor algorithm for zswap and zram