linux/tools/testing/selftests/zram
Yang Xu 01dabed205 selftests/zram: Adapt the situation that /dev/zram0 is being used
If zram-generator package is installed and works, then we can not remove
zram module because zram swap is being used. This case needs a clean zram
environment, change this test by using hot_add/hot_remove interface. So
even zram device is being used, we still can add zram device and remove
them in cleanup.

The two interface was introduced since kernel commit 6566d1a32bf7("zram:
add dynamic device add/remove functionality") in v4.2-rc1. If kernel
supports these two interface, we use hot_add/hot_remove to slove this
problem, if not, just check whether zram is being used or built in, then
skip it on old kernel.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2022-01-27 10:59:02 -07:00
..
config selftests: create test-specific kconfig fragments 2016-02-25 09:47:52 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
README docs: blockdev: add it to the admin-guide 2019-07-15 11:03:01 -03:00
zram01.sh selftests/zram: Adapt the situation that /dev/zram0 is being used 2022-01-27 10:59:02 -07:00
zram02.sh selftests/zram: Adapt the situation that /dev/zram0 is being used 2022-01-27 10:59:02 -07:00
zram_lib.sh selftests/zram: Adapt the situation that /dev/zram0 is being used 2022-01-27 10:59:02 -07:00
zram.sh selftests/zram: Adapt the situation that /dev/zram0 is being used 2022-01-27 10:59:02 -07:00

zram: Compressed RAM based block devices
----------------------------------------
* Introduction

The zram module creates RAM based block devices named /dev/zram<id>
(<id> = 0, 1, ...). Pages written to these disks are compressed and stored
in memory itself. These disks allow very fast I/O and compression provides
good amounts of memory savings. Some of the usecases include /tmp storage,
use as swap disks, various caches under /var and maybe many more :)

Statistics for individual zram devices are exported through sysfs nodes at
/sys/block/zram<id>/

Kconfig required:
CONFIG_ZRAM=y
CONFIG_CRYPTO_LZ4=y
CONFIG_ZPOOL=y
CONFIG_ZSMALLOC=y

ZRAM Testcases
--------------
zram_lib.sh: create library with initialization/cleanup functions
zram.sh: For sanity check of CONFIG_ZRAM and to run zram01 and zram02

Two functional tests: zram01 and zram02:
zram01.sh: creates general purpose ram disks with ext4 filesystems
zram02.sh: creates block device for swap

Commands required for testing:
 - bc
 - dd
 - free
 - awk
 - mkswap
 - swapon
 - swapoff
 - mkfs/ mkfs.ext4

For more information please refer:
kernel-source-tree/Documentation/admin-guide/blockdev/zram.rst