From patchwork Fri Nov 18 07:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: limin X-Patchwork-Id: 13047806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38A6BC433FE for ; Fri, 18 Nov 2022 07:57:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98DAF6B0071; Fri, 18 Nov 2022 02:57:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 93C3B6B0072; Fri, 18 Nov 2022 02:57:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82B436B0073; Fri, 18 Nov 2022 02:57:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6F6426B0071 for ; Fri, 18 Nov 2022 02:57:40 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 408A281074 for ; Fri, 18 Nov 2022 07:57:40 +0000 (UTC) X-FDA: 80145808680.19.35FD78F Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf27.hostedemail.com (Postfix) with ESMTP id 302494000D for ; Fri, 18 Nov 2022 07:57:37 +0000 (UTC) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4ND8FC5DQjzJnq7; Fri, 18 Nov 2022 15:54:23 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 18 Nov 2022 15:57:34 +0800 Received: from localhost.localdomain (10.90.53.65) by kwepemm600001.china.huawei.com (7.193.23.3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 18 Nov 2022 15:57:33 +0800 From: limin To: , , , CC: , , , , , , , Subject: [PATCH -next] kselftest/cgroup: fix unexcepted testing failure on test_memcontrol Date: Fri, 18 Nov 2022 15:57:27 +0800 Message-ID: <20221118075727.542942-1-limin100@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-Originating-IP: [10.90.53.65] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600001.china.huawei.com (7.193.23.3) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668758259; a=rsa-sha256; cv=none; b=JS5kUwK8TiOhhM+U2Ljp3YnxA7eD7pZ/jg9IEoVO5PZliQ2xxnSbepQWzbJMORptUjPeZk j4YagdfM2fkSgWjY3mlxBtoLmr7a33/Z5NRnGdLxX1/ts9Fnz9w9qFWSjuIt4+dMDTutc2 VAYHiZvu+YeT9/vu8vG+TtiOXtF25wQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of limin100@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=limin100@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668758259; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=jHVthjlmV6UZ53EuUcW2R46FfVPS0ubPojtgWeF7sSY=; b=uFqzv1aHhq1PSaWJnyJE0c/4ogp179UYWAwKGri/ZYjmWcZJUITv+qgZv7PT4glEZv9Xjw hb6h3TwoBLlB3TjvF4GzPXgau3nuiRXEsQGJdfMeeKQt2aSqIVgQAWwXi1nKrVduPqpoWj yVLUv8ZYSnwrwnO5S1cb4DkYvqPcgQk= X-Stat-Signature: zh5o75q44roxtn3k56418dc54sxmw19w X-Rspamd-Queue-Id: 302494000D Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of limin100@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=limin100@huawei.com X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1668758257-161956 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000058, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When the `test_memcontrol` is run, the following two test cases fail: 1. test_memcg_low The original test case does not address the following issues: First, the memory reclamation behavior is different when memory.min or memory.low is set. Second, when memory.low of a cgroup is set to 0 and the cgroup's father's is set to 50, the value of the low field in the memory.events of the cgroup is greater than 0. 2. test_memcg_swap_max When swap.max is set, the sum of memory.current and memory.swap.current is slightly greater than the allocated memory size. The judgment in the original test case is too strict. some test cases will be failed as following: (the fourth and tenth): $ sudo ./test_memcontrol ok 1 test_memcg_subtree_control ok 2 test_memcg_current ok 3 test_memcg_min not ok 4 test_memcg_low ok 5 test_memcg_high ok 6 test_memcg_high_sync ok 7 test_memcg_max ok 8 test_memcg_reclaim ok 9 test_memcg_oom_events not ok 10 test_memcg_swap_max ok 11 test_memcg_sock ok 12 test_memcg_oom_group_leaf_events ok 13 test_memcg_oom_group_parent_events ok 14 test_memcg_oom_group_score_events this patch will correct this unexcepted failure Signed-off-by: limin Signed-off-by: liaoqixin --- tools/testing/selftests/cgroup/test_memcontrol.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 883335955..18a1d40b1 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -381,8 +381,7 @@ static int test_memcg_protection(const char *root, bool min) "memory.low prevents from allocating anon memory\n"); goto cleanup; } - - if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) + if (!values_close(cg_read_long(parent[1], "memory.current"), min ? MB(50) : MB(30), 3)) goto cleanup; if (min) { @@ -401,9 +400,6 @@ static int test_memcg_protection(const char *root, bool min) goto cleanup; if (i <= no_low_events_index && low <= 0) goto cleanup; - if (i > no_low_events_index && low) - goto cleanup; - } ret = KSFT_PASS; @@ -768,7 +764,7 @@ static int alloc_anon_50M_check_swap(const char *cgroup, void *arg) swap_current = cg_read_long(cgroup, "memory.swap.current"); if (!swap_current || - !values_close(mem_current + swap_current, size, 3)) + !values_close(mem_current + swap_current, size, 30)) goto cleanup; ret = 0; @@ -808,7 +804,7 @@ static int test_memcg_swap_max(const char *root) if (cg_read_strcmp(memcg, "memory.swap.max", "max\n")) goto cleanup; - if (cg_write(memcg, "memory.swap.max", "30M")) + if (cg_write(memcg, "memory.swap.max", "70M")) goto cleanup; if (cg_write(memcg, "memory.max", "30M"))