From patchwork Fri Jan 4 19:02:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 1020887 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43WZ1N0wfRz9s55 for ; Sat, 5 Jan 2019 06:03:00 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 7A5483E6611 for ; Fri, 4 Jan 2019 20:02:56 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 7667D3E65CC for ; Fri, 4 Jan 2019 20:02:55 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by in-5.smtp.seeweb.it (Postfix) with ESMTP id 632F46008C2 for ; Fri, 4 Jan 2019 20:02:52 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3FFA15AD; Fri, 4 Jan 2019 11:02:50 -0800 (PST) Received: from e120937-lin.cambridge.arm.com (e120937-lin.cambridge.arm.com [10.1.197.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 45BE93F5D4; Fri, 4 Jan 2019 11:02:50 -0800 (PST) From: Cristian Marussi To: ltp@lists.linux.it Date: Fri, 4 Jan 2019 19:02:40 +0000 Message-Id: <20190104190240.18601-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH] memcg_stress_test.sh: fix memory usage X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Currently this test roughly calculates the maximum amount of memory to use by barely looking up mem_free and swap_free from /proc/meminfo. Unfortunately it does not consider any special the systems configured without a swap, so it ends, on those systems, trying to use all the found mem_free while keeping only one mb per-worker-thread as a safety net. This is fine when using a 4k pagesize but it is NOT enough on systems configured with a 64k pagesize, resulting in an oom-party. With this patch we now consider the configured page-size to decide how many memory to set aside as a safety area. Signed-off-by: Cristian Marussi Reviewed-by: Petr Vorel --- .../kernel/controllers/memcg/stress/memcg_stress_test.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh index 652d99e55..97a4d444e 100755 --- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh +++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh @@ -32,10 +32,12 @@ do_setup() sleep 2 local mem_free=`cat /proc/meminfo | grep MemFree | awk '{ print $2 }'` local swap_free=`cat /proc/meminfo | grep SwapFree | awk '{ print $2 }'` + local pgsize=`tst_getconf PAGESIZE` MEM=$(( $mem_free + $swap_free / 2 )) 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" } @@ -100,7 +102,7 @@ testcase_1() { tst_res TINFO "testcase 1 started...it will run for $RUN_TIME secs" - run_stress 150 $(( ($MEM - 150) / 150 )) 5 $RUN_TIME + run_stress 150 $(( ($MEM - 150 * $THREAD_SPARE_MB) / 150 )) 5 $RUN_TIME tst_res TPASS "stress test 1 passed" } @@ -109,7 +111,7 @@ testcase_2() { tst_res TINFO "testcase 2 started...it will run for $RUN_TIME secs" - run_stress 1 $MEM 5 $RUN_TIME + run_stress 1 $(( $MEM - $THREAD_SPARE_MB)) 5 $RUN_TIME tst_res TPASS "stress test 2 passed" }