Skip to content

Commit 7a2369b

Browse files
yosrym93akpm00
authored andcommitted
mm: z3fold: deprecate CONFIG_Z3FOLD
The z3fold compressed pages allocator is rarely used, most users use zsmalloc. The only disadvantage of zsmalloc in comparison is the dependency on MMU, and zbud is a more common option for !MMU as it was the default zswap allocator for a long time. Historically, zsmalloc had worse latency than zbud and z3fold but offered better memory savings. This is no longer the case as shown by a simple recent analysis [1]. That analysis showed that z3fold does not have any advantage over zsmalloc or zbud considering both performance and memory usage. In a kernel build test on tmpfs in a limited cgroup, z3fold took 3% more time and used 1.8% more memory. The latency of zswap_load() was 7% higher, and that of zswap_store() was 10% higher. Zsmalloc is better in all metrics. Moreover, z3fold apparently has latent bugs, which was made noticeable by a recent soft lockup bug report with z3fold [2]. Switching to zsmalloc not only fixed the problem, but also reduced the swap usage from 6~8G to 1~2G. Other users have also reported being bitten by mistakenly enabling z3fold. Other than hurting users, z3fold is repeatedly causing wasted engineering effort. Apart from investigating the above bug, it came up in multiple development discussions (e.g. [3]) as something we need to handle, when there aren't any legit users (at least not intentionally). The natural course of action is to deprecate z3fold, and remove in a few cycles if no objections are raised from active users. Next on the list should be zbud, as it offers marginal latency gains at the cost of huge memory waste when compared to zsmalloc. That one will need to wait until zsmalloc does not depend on MMU. Rename the user-visible config option from CONFIG_Z3FOLD to CONFIG_Z3FOLD_DEPRECATED so that users with CONFIG_Z3FOLD=y get a new prompt with explanation during make oldconfig. Also, remove CONFIG_Z3FOLD=y from defconfigs. [1]https://lore.kernel.org/lkml/CAJD7tkbRF6od-2x_L8-A1QL3=2Ww13sCj4S3i4bNndqF+3+_Vg@mail.gmail.com/ [2]https://lore.kernel.org/lkml/[email protected]/ [3]https://lore.kernel.org/lkml/CAJD7tkbnmeVugfunffSovJf9FAgy9rhBVt_tx=nxUveLUfqVsA@mail.gmail.com/ [[email protected]: deprecate ZSWAP_ZPOOL_DEFAULT_Z3FOLD as well] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yosry Ahmed <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Chris Down <[email protected]> Acked-by: Nhat Pham <[email protected]> Acked-by: Johannes Weiner <[email protected]> Acked-by: Vitaly Wool <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Miaohe Lin <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Naveen N. Rao <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: WANG Xuerui <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f9e54c3 commit 7a2369b

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

arch/loongarch/configs/loongson3_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ CONFIG_ZPOOL=y
9696
CONFIG_ZSWAP=y
9797
CONFIG_ZSWAP_COMPRESSOR_DEFAULT_ZSTD=y
9898
CONFIG_ZBUD=y
99-
CONFIG_Z3FOLD=y
10099
CONFIG_ZSMALLOC=m
101100
# CONFIG_COMPAT_BRK is not set
102101
CONFIG_MEMORY_HOTPLUG=y

arch/powerpc/configs/ppc64_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ CONFIG_MODULE_SIG_SHA512=y
8181
CONFIG_PARTITION_ADVANCED=y
8282
CONFIG_BINFMT_MISC=m
8383
CONFIG_ZSWAP=y
84-
CONFIG_Z3FOLD=y
8584
CONFIG_ZSMALLOC=y
8685
# CONFIG_SLAB_MERGE_DEFAULT is not set
8786
CONFIG_SLAB_FREELIST_RANDOM=y

mm/Kconfig

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,15 @@ config ZSWAP_ZPOOL_DEFAULT_ZBUD
146146
help
147147
Use the zbud allocator as the default allocator.
148148

149-
config ZSWAP_ZPOOL_DEFAULT_Z3FOLD
150-
bool "z3fold"
151-
select Z3FOLD
149+
config ZSWAP_ZPOOL_DEFAULT_Z3FOLD_DEPRECATED
150+
bool "z3foldi (DEPRECATED)"
151+
select Z3FOLD_DEPRECATED
152152
help
153153
Use the z3fold allocator as the default allocator.
154154

155+
Deprecated and scheduled for removal in a few cycles,
156+
see CONFIG_Z3FOLD_DEPRECATED.
157+
155158
config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC
156159
bool "zsmalloc"
157160
select ZSMALLOC
@@ -163,7 +166,7 @@ config ZSWAP_ZPOOL_DEFAULT
163166
string
164167
depends on ZSWAP
165168
default "zbud" if ZSWAP_ZPOOL_DEFAULT_ZBUD
166-
default "z3fold" if ZSWAP_ZPOOL_DEFAULT_Z3FOLD
169+
default "z3fold" if ZSWAP_ZPOOL_DEFAULT_Z3FOLD_DEPRECATED
167170
default "zsmalloc" if ZSWAP_ZPOOL_DEFAULT_ZSMALLOC
168171
default ""
169172

@@ -177,15 +180,25 @@ config ZBUD
177180
deterministic reclaim properties that make it preferable to a higher
178181
density approach when reclaim will be used.
179182

180-
config Z3FOLD
181-
tristate "3:1 compression allocator (z3fold)"
183+
config Z3FOLD_DEPRECATED
184+
tristate "3:1 compression allocator (z3fold) (DEPRECATED)"
182185
depends on ZSWAP
183186
help
187+
Deprecated and scheduled for removal in a few cycles. If you have
188+
a good reason for using Z3FOLD over ZSMALLOC, please contact
189+
[email protected] and the zswap maintainers.
190+
184191
A special purpose allocator for storing compressed pages.
185192
It is designed to store up to three compressed pages per physical
186193
page. It is a ZBUD derivative so the simplicity and determinism are
187194
still there.
188195

196+
config Z3FOLD
197+
tristate
198+
default y if Z3FOLD_DEPRECATED=y
199+
default m if Z3FOLD_DEPRECATED=m
200+
depends on Z3FOLD_DEPRECATED
201+
189202
config ZSMALLOC
190203
tristate
191204
prompt "N:1 compression allocator (zsmalloc)" if (ZSWAP || ZRAM)

0 commit comments

Comments
 (0)