1# SPDX-License-Identifier: GPL-2.0
2config ZRAM
3	tristate "Compressed RAM block device support"
4	depends on BLOCK && SYSFS && MMU
5	depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842
6	select ZSMALLOC
7	help
8	  Creates virtual block devices called /dev/zramX (X = 0, 1, ...).
9	  Pages written to these disks are compressed and stored in memory
10	  itself. These disks allow very fast I/O and compression provides
11	  good amounts of memory savings.
12
13	  It has several use cases, for example: /tmp storage, use as swap
14	  disks and maybe many more.
15
16	  See Documentation/admin-guide/blockdev/zram.rst for more information.
17
18choice
19	prompt "Default zram compressor"
20	default ZRAM_DEF_COMP_LZORLE
21	depends on ZRAM
22
23config ZRAM_DEF_COMP_LZORLE
24	bool "lzo-rle"
25	depends on CRYPTO_LZO
26
27config ZRAM_DEF_COMP_ZSTD
28	bool "zstd"
29	depends on CRYPTO_ZSTD
30
31config ZRAM_DEF_COMP_LZ4
32	bool "lz4"
33	depends on CRYPTO_LZ4
34
35config ZRAM_DEF_COMP_LZO
36	bool "lzo"
37	depends on CRYPTO_LZO
38
39config ZRAM_DEF_COMP_LZ4HC
40	bool "lz4hc"
41	depends on CRYPTO_LZ4HC
42
43config ZRAM_DEF_COMP_842
44	bool "842"
45	depends on CRYPTO_842
46
47endchoice
48
49config ZRAM_DEF_COMP
50	string
51	default "lzo-rle" if ZRAM_DEF_COMP_LZORLE
52	default "zstd" if ZRAM_DEF_COMP_ZSTD
53	default "lz4" if ZRAM_DEF_COMP_LZ4
54	default "lzo" if ZRAM_DEF_COMP_LZO
55	default "lz4hc" if ZRAM_DEF_COMP_LZ4HC
56	default "842" if ZRAM_DEF_COMP_842
57
58config ZRAM_WRITEBACK
59       bool "Write back incompressible or idle page to backing device"
60       depends on ZRAM
61       help
62	 With incompressible page, there is no memory saving to keep it
63	 in memory. Instead, write it out to backing device.
64	 For this feature, admin should set up backing device via
65	 /sys/block/zramX/backing_dev.
66
67	 With /sys/block/zramX/{idle,writeback}, application could ask
68	 idle page's writeback to the backing device to save in memory.
69
70	 See Documentation/admin-guide/blockdev/zram.rst for more information.
71
72config ZRAM_MEMORY_TRACKING
73	bool "Track zRam block status"
74	depends on ZRAM && DEBUG_FS
75	help
76	  With this feature, admin can track the state of allocated blocks
77	  of zRAM. Admin could see the information via
78	  /sys/kernel/debug/zram/zramX/block_state.
79
80	  See Documentation/admin-guide/blockdev/zram.rst for more information.
81