]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/zram01.sh: Fix compression ratio calculation
authorYang Xu <xuyang2018.jy@fujitsu.com>
Thu, 27 Jan 2022 09:11:36 +0000 (17:11 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 27 Jan 2022 17:58:56 +0000 (10:58 -0700)
commitb1b6c17a5ab63fcc2dc44c57ff75fafdc5629caa
tree4c20ab0d70950189a8a96a59bc3c9ab00f6c71a3
parentf775a5bcaa387c8f96283e9f144965f447e04760
selftests/zram01.sh: Fix compression ratio calculation

zram01 uses `free -m` to measure zram memory usage. The results are no
sense because they are polluted by all running processes on the system.

We Should only calculate the free memory delta for the current process.
So use the third field of /sys/block/zram<id>/mm_stat to measure memory
usage instead. The file is available since kernel 4.1.

orig_data_size(first): uncompressed size of data stored in this disk.
compr_data_size(second): compressed size of data stored in this disk
mem_used_total(third): the amount of memory allocated for this disk

Also remove useless zram cleanup call in zram_fill_fs and so we don't
need to cleanup zram twice if fails.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/zram/zram01.sh