[LTP] [PATCH V2] memcg_stress_test.sh: Fix reserved mem calculate

gehao618 gehao618@163.com
Mon Mar 13 02:14:18 CET 2023


Hi Pals


    Can you help to review this patch ? Or have any suggestions ?


Thanks
Best Regards
Hao
---- Replied Message ----
| From | Hao Ge<gehao@kylinos.cn> |
| Date | 03/09/2023 17:16 |
| To | ltp<ltp@lists.linux.it> |
| Cc | Hao Ge<gehao@kylinos.cn> |
| Subject | [LTP] [PATCH V2] memcg_stress_test.sh: Fix reserved mem calculate |
When running this test case on a machine with large memory,
and without swap or swap is too small,existing reserved
memory is too small for a machine with large memory,and
will cause forking a subprocess to run a command will fail
due to memory is exhausted,so optimize reserved memory
calculate to ten percent of free memory.

Here is an example:

free -m
             total        used        free      shared  buff/cache   available
Mem:         260184        2959      255854          62        1370      236346
Swap:          4095           0        4095

when you run this testcase,console will report
fork:Cannot allocate memory

Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
.../kernel/controllers/memcg/stress/memcg_stress_test.sh    | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
index cb52840d7..f26a9f72a 100755
--- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
+++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
@@ -40,7 +40,7 @@ setup()
   MEM=$(( $mem_free + $swap_free / 2 ))
   MEM=$(( $MEM / 1024 ))
   RUN_TIME=$(( 15 * 60 ))
-    [ "$pgsize" = "4096" ] && THREAD_SPARE_MB=1 || THREAD_SPARE_MB=8
+    RESERVED_MEMORY=$(( $MEM * 10/100 ))

   tst_res TINFO "Calculated available memory $MEM MB"
}
@@ -93,12 +93,12 @@ run_stress()

test1()
{
-    run_stress 150 $(( ($MEM - 150 * $THREAD_SPARE_MB) / 150 )) 5 $RUN_TIME
+    run_stress 150 $(( ($MEM - $RESERVED_MEMORY) / 150 )) 5 $RUN_TIME
}

test2()
{
-    run_stress 1 $(( $MEM - $THREAD_SPARE_MB)) 5 $RUN_TIME
+    run_stress 1 $(( $MEM - $RESERVED_MEMORY)) 5 $RUN_TIME
}

. cgroup_lib.sh
--
2.25.1


--
Mailing list info: https://lists.linux.it/listinfo/ltp


More information about the ltp mailing list