<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Petr,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 8, 2022 at 3:12 AM Petr Vorel <<a href="mailto:pvorel@suse.cz">pvorel@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Repeatedly read /sys/block/zram*/mm_stat for 1 sec. This should fix bug<br>
on ppc64le on stable kernels, where mem_used_total is often 0.<br>
<br>
Signed-off-by: Petr Vorel <<a href="mailto:pvorel@suse.cz" target="_blank">pvorel@suse.cz</a>><br>
---<br>
.../kernel/device-drivers/zram/zram01.sh | 27 +++++++++++++++++--<br>
1 file changed, 25 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh<br>
index 58d233f91..76a8ccab4 100755<br>
--- a/testcases/kernel/device-drivers/zram/zram01.sh<br>
+++ b/testcases/kernel/device-drivers/zram/zram01.sh<br>
@@ -105,6 +105,26 @@ zram_mount()<br>
tst_res TPASS "mount of zram device(s) succeeded"<br>
}<br>
<br>
+read_mem_used_total()<br>
+{<br>
+ echo $(awk '{print $3}' $1)<br>
+}<br>
+<br>
+# Reads /sys/block/zram*/mm_stat until mem_used_total is not 0.<br>
+loop_read_mem_used_total()<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">This is not a looping function to check if mem_used_total is equal to zero,</div><div class="gmail_default" style="font-size:small">the loop part is by means of the TST_RETRY_FUNC macro.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So, I'd suggest renaming it to check_read_mem_used_total().</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>><br></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+{<br>
+ local file="$1"<br>
+ local mem_used_total<br>
+<br>
+ tst_res TINFO "$file"<br>
+ cat $file >&2<br>
+<br>
+ mem_used_total=$(read_mem_used_total $file)<br>
+ [ "$mem_used_total" -eq 0 ] && return 1<br>
+<br>
+ return 0<br>
+}<br>
+<br>
zram_fill_fs()<br>
{<br>
local mem_used_total<br>
@@ -133,9 +153,12 @@ zram_fill_fs()<br>
continue<br>
fi<br>
<br>
- mem_used_total=`awk '{print $3}' "/sys/block/zram$i/mm_stat"`<br>
+ TST_RETRY_FUNC "loop_read_mem_used_total /sys/block/zram$i/mm_stat" 0<br>
+ mem_used_total=$(read_mem_used_total /sys/block/zram$i/mm_stat)<br>
+ tst_res TINFO "mem_used_total: $mem_used_total"<br>
+<br>
v=$((100 * 1024 * $b / $mem_used_total))<br>
- r=`echo "scale=2; $v / 100 " | bc`<br>
+ r=$(echo "scale=2; $v / 100 " | bc)<br>
<br>
if [ "$v" -lt 100 ]; then<br>
tst_res TFAIL "compression ratio: $r:1"<br>
-- <br>
2.38.0<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>