[LTP] [PATCH] kernel/device-drivers/zram/zram01.sh : add a sync
Ian Wienand
iwienand@redhat.com
Thu Aug 3 03:51:49 CEST 2023
I have a system (virtualized aarch64, 4.18.0 kernel) that is
consistently failing the zram01.sh test as it tries to divide the
memory stats by zero. It seems like I'm not the only one, this has
been reported before at [1] without resolution.
This test does a lot of 1k writes into zram devices of size 25, 25,
25, 300 and 25 mb. On this particular system, I consistently see the
final 25mb testing fail as it examines /sys/block/zramX/mm_stat and
finds the mem_used_total as zero.
For example, I instrumented the test to put a "sync" call in between
examining the mm_stat value if it was zero; before and after it looks
like:
zram01 7 TINFO: /sys/block/zram34/mm_stat is zero : 10092544 0 0 26214400 196608 154 0 0
<sync>
zram01 7 TINFO: /sys/block/zram34/mm_stat is zero (post sync) : 26214400 2841 65536 26214400 196608 399 0 0
This is an otherwise quiet system and nothing else seems out of order
(weird logs, load average, etc.). I think that given the 300mb worth
of writes from the prior step, the system just needs a little time to
catch up on the compression to make this test more reliable.
I considered checking if the value is zero and arbitrarily just
waiting a few seconds which did work. I then replaced this with a
sync which also worked. Rather than worrying about checking for zero
values, it seems more reliable and simpler to just sync after the
writes in all cases. I could not replicate this issue with the sync
as proposed in this patch.
Additionally this does a check for a zero value to hopefully provide a
more structured message if the test fails in the same way.
[1] https://lists.linux.it/pipermail/ltp/2019-July/013028.html
Signed-off-by: Ian Wienand <iwienand@redhat.com>
---
testcases/kernel/device-drivers/zram/zram01.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index 58d233f91..5f3964f6c 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -119,6 +119,9 @@ zram_fill_fs()
>/dev/null 2>err.txt || break
b=$(($b + 1))
done
+ # Give the system time to catch up, otherwise the mm_stat
+ # checking below can give a false negative
+ sync
if [ $b -eq 0 ]; then
[ -s err.txt ] && tst_res TWARN "dd error: $(cat err.txt)"
tst_brk TBROK "cannot fill zram $i"
@@ -134,6 +137,9 @@ zram_fill_fs()
fi
mem_used_total=`awk '{print $3}' "/sys/block/zram$i/mm_stat"`
+ if [ $mem_used_total -eq 0 ]; then
+ test_res FAIL "/sys/block/zram$i/mm_stat reports 0 size : $(cat /sys/block/zram$i/mm_stat)"
+ fi
v=$((100 * 1024 * $b / $mem_used_total))
r=`echo "scale=2; $v / 100 " | bc`
--
2.41.0
More information about the ltp
mailing list