[LTP] [PATCH v4] memcg_stress_test.sh: Fix reserved mem calculate
Hao Ge
gehao@kylinos.cn
Wed Mar 15 09:00:41 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 .
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
.../controllers/memcg/stress/memcg_stress_test.sh | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 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..ed35eaace 100755
--- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
+++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
@@ -34,13 +34,16 @@ setup()
echo 3 > /proc/sys/vm/drop_caches
sleep 2
local mem_free=`cat /proc/meminfo | grep MemFree | awk '{ print $2 }'`
+ local mem_available=`cat /proc/meminfo | grep MemAvailable | awk '{ print $2 }'`
local swap_free=`cat /proc/meminfo | grep SwapFree | awk '{ print $2 }'`
- local pgsize=`tst_getconf PAGESIZE`
+ mem_min=`cat /proc/sys/vm/min_free_kbytes`
- MEM=$(( $mem_free + $swap_free / 2 ))
+ mem_min=$(( $mem_min + $mem_min / 10 ))
+ [ $swap_free -gt $mem_min ] && RESERVED_MEM=0 || RESERVED_MEM=$mem_min
+ [ $mem_free -lt $mem_available ] && MEM=$mem_free || MEM=$mem_available
+ MEM=$(( $MEM - $RESERVED_MEM ))
MEM=$(( $MEM / 1024 ))
RUN_TIME=$(( 15 * 60 ))
- [ "$pgsize" = "4096" ] && THREAD_SPARE_MB=1 || THREAD_SPARE_MB=8
tst_res TINFO "Calculated available memory $MEM MB"
}
@@ -93,12 +96,12 @@ run_stress()
test1()
{
- run_stress 150 $(( ($MEM - 150 * $THREAD_SPARE_MB) / 150 )) 5 $RUN_TIME
+ run_stress 150 $(( $MEM / 150 )) 5 $RUN_TIME
}
test2()
{
- run_stress 1 $(( $MEM - $THREAD_SPARE_MB)) 5 $RUN_TIME
+ run_stress 1 $MEM 5 $RUN_TIME
}
. cgroup_lib.sh
--
2.25.1
More information about the ltp
mailing list