* [LTP] [PATCH] zram01: Fix division by 0
@ 2019-07-31 6:33 Petr Vorel
2019-07-31 7:16 ` Li Wang
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2019-07-31 6:33 UTC (permalink / raw)
To: ltp
Sometimes free reports no memory use by zram, which leads to division by 0:
zram01 8 TINFO: zram used 0M, zram disk sizes 104857600M
/opt/ltp/testcases/bin/zram01.sh: line 87: 100 * 104857600 / 0: division by 0 (error token is "0")
TBROK the test in that case.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/device-drivers/zram/zram01.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index 7d3951aa5..79e18cbb7 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -82,6 +82,11 @@ zram_fill_fs()
total_size=$(($total_size + $s))
done
+ if [ $used_mem -eq 0 ]; then
+ tst_resm TBROK "no memory used by zram"
+ return
+ fi
+
tst_resm TINFO "zram used ${used_mem}M, zram disk sizes ${total_size}M"
local v=$((100 * $total_size / $used_mem))
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] zram01: Fix division by 0
2019-07-31 6:33 [LTP] [PATCH] zram01: Fix division by 0 Petr Vorel
@ 2019-07-31 7:16 ` Li Wang
2019-07-31 7:27 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2019-07-31 7:16 UTC (permalink / raw)
To: ltp
> + if [ $used_mem -eq 0 ]; then
> + tst_resm TBROK "no memory used by zram"
> + return
> + fi
Why not use tst_brkm directly? Otherwise looks good to me.
--
Regards,
Li Wang
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] zram01: Fix division by 0
2019-07-31 7:16 ` Li Wang
@ 2019-07-31 7:27 ` Petr Vorel
2019-08-07 14:16 ` Alexey Kodanev
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2019-07-31 7:27 UTC (permalink / raw)
To: ltp
Hi Li,
> > + if [ $used_mem -eq 0 ]; then
> > + tst_resm TBROK "no memory used by zram"
> > + return
> > + fi
> Why not use tst_brkm directly? Otherwise looks good to me.
Make sense.
Thanks for your ack, lets wait for Alexey.
I wonder how this can happen (found occasionally on ppc64le).
If this happen than zram02 and zram03 fails on timeout:
/opt/ltp/testcases/bin/zram_lib.sh: line 38: echo: write error: Device or resource busy
zram03 1 TBROK : safe_file_ops.c:301: Failed to close FILE '/sys/block/zram0/disksize' at zram03.c:87: errno=EBUSY(16): Device or resource busy
Maybe some timeout would help, need to look into it.
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] zram01: Fix division by 0
2019-07-31 7:27 ` Petr Vorel
@ 2019-08-07 14:16 ` Alexey Kodanev
0 siblings, 0 replies; 4+ messages in thread
From: Alexey Kodanev @ 2019-08-07 14:16 UTC (permalink / raw)
To: ltp
On 31.07.2019 10:27, Petr Vorel wrote:
> Hi Li,
>
>>> + if [ $used_mem -eq 0 ]; then
>>> + tst_resm TBROK "no memory used by zram"
>>> + return
>>> + fi
>
>> Why not use tst_brkm directly? Otherwise looks good to me.
> Make sense.
> Thanks for your ack, lets wait for Alexey.
>
> I wonder how this can happen (found occasionally on ppc64le).
>
Is it actually working, i.e. writing to zram?
while true; do
dd conv=notrunc if=/dev/zero of=zram${i}/file \
oflag=append count=1 bs=1024 status=none \
> /dev/null 2>&1 || break
b=$(($b + 1))
done
tst_resm TINFO "zram$i can be filled with '$b' KB"
Perhaps, we could add a check for the minimum value of $b and print
the last error from dd too...
> If this happen than zram02 and zram03 fails on timeout:
> /opt/ltp/testcases/bin/zram_lib.sh: line 38: echo: write error: Device or resource busy
> zram03 1 TBROK : safe_file_ops.c:301: Failed to close FILE '/sys/block/zram0/disksize' at zram03.c:87: errno=EBUSY(16): Device or resource busy
>
> Maybe some timeout would help, need to look into it.
>
> Petr
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-07 14:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 6:33 [LTP] [PATCH] zram01: Fix division by 0 Petr Vorel
2019-07-31 7:16 ` Li Wang
2019-07-31 7:27 ` Petr Vorel
2019-08-07 14:16 ` Alexey Kodanev
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.