From patchwork Tue May 21 08:25:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 1102620 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=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 457TNh34l6z9s5c for ; Tue, 21 May 2019 18:25:37 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3DF8129879C for ; Tue, 21 May 2019 10:25:26 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id C33B929879C for ; Tue, 21 May 2019 10:25:24 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 8EB666002E7 for ; Tue, 21 May 2019 10:25:23 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E42F3082E69 for ; Tue, 21 May 2019 08:25:22 +0000 (UTC) Received: from dustball.brq.redhat.com (unknown [10.43.17.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0B4E5D9D5; Tue, 21 May 2019 08:25:21 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Tue, 21 May 2019 10:25:18 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 21 May 2019 08:25:22 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Cc: liwan@redhat.com Subject: [LTP] [PATCH] overcommit_memory: update for "mm: fix false-positive OVERCOMMIT_GUESS failures" 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" commit 8c7829b04c52 ("mm: fix false-positive OVERCOMMIT_GUESS failures") changes logic of __vm_enough_memory(), simplifying it to: When in GUESS mode, catch wild allocations by comparing their request size to total amount of ram and swap in the system. Testcase currently allocates mem_total + swap_total, which doesn't trigger new condition. Make it more extreme, but assuming free_total / 2 will PASS, and sum_total * 2 will FAIL. Signed-off-by: Jan Stancek --- testcases/kernel/mem/tunable/overcommit_memory.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c index 555298fbfd85..345764dfe427 100644 --- a/testcases/kernel/mem/tunable/overcommit_memory.c +++ b/testcases/kernel/mem/tunable/overcommit_memory.c @@ -36,11 +36,10 @@ * * The program is designed to test the two tunables: * - * When overcommit_memory = 0, allocatable memory can't overextends - * the amount of free memory. I choose the three cases: + * When overcommit_memory = 0, allocatable memory can't overextend + * the amount of total memory: * a. less than free_total: free_total / 2, alloc should pass. - * b. greater than free_total: free_total * 2, alloc should fail. - * c. equal to sum_total: sum_tatal, alloc should fail + * b. greater than sum_total: sum_total * 2, alloc should fail. * * When overcommit_memory = 1, it can alloc enough much memory, I * choose the three cases: @@ -164,9 +163,7 @@ static void overcommit_memory_test(void) update_mem(); alloc_and_check(free_total / 2, EXPECT_PASS); - update_mem(); - alloc_and_check(free_total * 2, EXPECT_FAIL); - alloc_and_check(sum_total, EXPECT_FAIL); + alloc_and_check(sum_total * 2, EXPECT_FAIL); /* start to test overcommit_memory=1 */ set_sys_tune("overcommit_memory", 1, 1);