[LTP] [PATCH V2] memcg_stress_test.sh: Fix reserved mem calculate
Hao Ge
gehao@kylinos.cn
Thu Mar 9 10:16:55 CET 2023
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
More information about the ltp
mailing list