zram01.sh: Workaround division by 0 on vfat on ppc64le
Repeatedly read /sys/block/zram*/mm_stat for 1 sec. This should fix bug on ppc64le on stable kernels, where mem_used_total is often 0.
Signed-off-by Petr Vorel <[email protected]>
Reviewed-by Li Wang <[email protected]>
Reviewed-by Richard Palethorpe <[email protected]>
[rpalethorpe: s/loop/check/ suggested by Li]
---
rpalethorpe:
This may not fix the problem, but it can rule out a simple race condition.
.../kernel/device-drivers/zram/zram01.sh | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
testcases/kernel/device-drivers/zram/zram01.sh +25 -2
@@ -105,6 +105,26 @@ zram_mount() tst_res TPASS "mount of zram device(s) succeeded" } +read_mem_used_total() +{ + echo $(awk '{print $3}' $1) +} + +# Reads /sys/block/zram*/mm_stat until mem_used_total is not 0. +check_read_mem_used_total() +{ + local file="$1" + local mem_used_total + + tst_res TINFO "$file" + cat $file >&2 + + mem_used_total=$(read_mem_used_total $file) + [ "$mem_used_total" -eq 0 ] && return 1 + + return 0 +} + zram_fill_fs() { local mem_used_total
@@ -133,9 +153,12 @@ zram_fill_fs() continue fi - mem_used_total=`awk '{print $3}' "/sys/block/zram$i/mm_stat"` + TST_RETRY_FUNC "check_read_mem_used_total /sys/block/zram$i/mm_stat" 0 + mem_used_total=$(read_mem_used_total /sys/block/zram$i/mm_stat) + tst_res TINFO "mem_used_total: $mem_used_total" + v=$((100 * 1024 * $b / $mem_used_total)) - r=`echo "scale=2; $v / 100 " | bc` + r=$(echo "scale=2; $v / 100 " | bc) if [ "$v" -lt 100 ]; then tst_res TFAIL "compression ratio: $r:1"
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Richie,
Quoted 7 lines
Repeatedly read
/sys/block/zram*/mm_statfor 1 sec. This should fix bug on ppc64le on stable kernels, wheremem_used_totalis often 0.Signed-off-by Petr Vorel <[email protected]>Reviewed-by Li Wang <[email protected]>Reviewed-by Richard Palethorpe <[email protected]>
Quoted 6 lines
[rpalethorpe: s/loop/check/ suggested by Li]
---rpalethorpe:
This may not fix the problem, but it can rule out a simple race condition.
thanks a lot for finishing the effort!
I was waiting for Cyril to have his ack.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp