Re: [PATCH 2/3] selftests/zram01.sh: Fix compression ratio calculation

From: xuyang2018.jy@xxxxxxxxxxx
Date: Wed Jan 26 2022 - 01:16:04 EST


on 2022/1/26 4:37, Shuah Khan wrote:
> On 12/15/21 2:56 AM, Yang Xu wrote:
>> zram01 uses `free -m` to measure zram memory usage. The results are
>> nonsense
>> because they are polluted by all running processes on the system.
>>
>
> Are the results inaccurate or does /sys/block/zram<id>/mm_stat is a quick
> way to get the information?
The "free -m" result is inaccurate because it caculted global systemd
free memory instead of process that used zram device.

We should use mm_stat as Documentation/admin-guide/blockdev/zram.rst wrote:

File /sys/block/zram<id>/mm_stat

The mm_stat file represents the device's mm statistics. It consists of a
single
line of text and contains the following stats separated by whitespace:

================
=============================================================
orig_data_size uncompressed size of data stored in this disk.
Unit: bytes
compr_data_size compressed size of data stored in this disk
mem_used_total the amount of memory allocated for this disk. This
includes allocator fragmentation and metadata
>
> In any case, this patch and all 3 patches in this series have:
>
> WARNING: Possible unwrapped commit description (prefer a maximum 75
> chars per line)
>
> Please run checkpatch.pl and clean these up.
Ok, Will do it in v2.

Best Regards
Yang Xu
>
> thanks,
> -- Shuah