[LTP] [PATCH 1/1] zram01.sh: Workaround division by 0 on vfat on ppc64le
Li Wang
liwang@redhat.com
Mon Nov 21 08:14:05 CET 2022
Hi Petr,
On Tue, Nov 8, 2022 at 3:12 AM Petr Vorel <pvorel@suse.cz> wrote:
> 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 <pvorel@suse.cz>
> ---
> .../kernel/device-drivers/zram/zram01.sh | 27 +++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/zram/zram01.sh
> b/testcases/kernel/device-drivers/zram/zram01.sh
> index 58d233f91..76a8ccab4 100755
> --- a/testcases/kernel/device-drivers/zram/zram01.sh
> +++ b/testcases/kernel/device-drivers/zram/zram01.sh
> @@ -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.
> +loop_read_mem_used_total()
>
This is not a looping function to check if mem_used_total is equal to zero,
the loop part is by means of the TST_RETRY_FUNC macro.
So, I'd suggest renaming it to check_read_mem_used_total().
Reviewed-by: Li Wang <liwang@redhat.com>
> +{
> + 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 "loop_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"
> --
> 2.38.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20221121/0e43e37e/attachment.htm>
More information about the ltp
mailing list