All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/1] Fix zram01.sh
@ 2019-11-04 12:52 Martin Doucha
  2019-11-04 12:52 ` [LTP] [PATCH 1/1] Fix compression ratio calculation in zram01 Martin Doucha
  0 siblings, 1 reply; 11+ messages in thread
From: Martin Doucha @ 2019-11-04 12:52 UTC (permalink / raw)
  To: ltp

The compression ratio check in zram01.sh is completely broken:
- It uses `free -m` to *guess* zram memory usage which is distorted by all
  other processes running on the system.
- It calculates memory usage backwards ($before - $after; which should
  produce a negative value if the two values weren't nonsense).
- It mixes bytes with megabytes when calculating the final ratio.

Here's a patch to calculate the compression ratio correctly using sysfs memory
usage statistics for each zram device. I currently calculate it as
$bytes_written / $mm_stat_compr_data_size.

One question for debate is whether I should use a different formula:
- $bytes_written / $mm_stat_mem_used_total
  (mem_used_total includes internal zram memory management overhead)
- $mm_stat_orig_data_size / $mm_stat_compr_data_size
  (zram01.sh fills the zram device with binary zeroes so the data will be
  compacted even before compression; orig_data_size << bytes_written)
- $mm_stat_orig_data_size / $mm_stat_mem_used_total)
  (this could easily produce ratio <100% due to page compacting)
See https://www.kernel.org/doc/Documentation/blockdev/zram.txt

The mm_stat sysfs file is available since kernel 4.1. Unfortunately,
I couldn't test the TCONF branch when mm_stat doesn't exist because there's
no SLE release with kernel version between 3.14 and 4.1.

Verifcation run: https://openqa.suse.de/tests/3552880#step/zram01/6

Martin Doucha (1):
  Fix compression ratio calculation in zram01

 .../kernel/device-drivers/zram/zram01.sh      | 36 +++++++++----------
 1 file changed, 16 insertions(+), 20 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-11-08 15:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-04 12:52 [LTP] [PATCH 0/1] Fix zram01.sh Martin Doucha
2019-11-04 12:52 ` [LTP] [PATCH 1/1] Fix compression ratio calculation in zram01 Martin Doucha
2019-11-04 15:16   ` Petr Vorel
2019-11-04 15:51     ` Martin Doucha
2019-11-05  8:23       ` Petr Vorel
2019-11-05  8:46         ` Martin Doucha
2019-11-05  9:03         ` [LTP] [PATCH v2 0/1] " Martin Doucha
2019-11-05  9:03           ` [LTP] [PATCH v2 1/1] " Martin Doucha
2019-11-08 15:29             ` Cyril Hrubis
2019-11-08 15:31               ` Martin Doucha
2019-11-08 15:49                 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.