From patchwork Tue Apr 15 21:04:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 14052813 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 DCB05C369AB for ; Tue, 15 Apr 2025 21:04:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B37F16B0197; Tue, 15 Apr 2025 17:04:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE6E16B0198; Tue, 15 Apr 2025 17:04:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AD896B0199; Tue, 15 Apr 2025 17:04:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7B89E6B0197 for ; Tue, 15 Apr 2025 17:04:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 840D5161911 for ; Tue, 15 Apr 2025 21:04:41 +0000 (UTC) X-FDA: 83337507162.11.C4448A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id C0E1940004 for ; Tue, 15 Apr 2025 21:04:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b/+smepi"; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of longman@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744751079; a=rsa-sha256; cv=none; b=7WwHsnkwVSZp8bL7cbAuJJWJh2L8eC/eaKsU6FI9pHTQyyyouddDDJCfp2qcntM+sM/iHa 8wGNU5r5V1TAE2bnlsc9cQ4/cWpFTZchn3v8kxm3eIXlK1bCHZsg3Z/BLKmkhKztXnH6QJ GjhRB+q5wAdkDCdKfrUTHL8Hxja7bhQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="b/+smepi"; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of longman@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744751079; 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:in-reply-to:references:references:dkim-signature; bh=xFsllInDSe+SHojwQO4gcvZGi+BBau3/2pd7c11VFAU=; b=cOElK+fMS3OQoyCv2wrbpzdXERsGjgImJbP6zYeD1rcAW3Ktn3IoF5rPs9+64yh6GfEQmJ VKhizVWVnuHHfg+PNKa6hHNg8RPjJYfRoHwCo12kgouU03KM9XxkN0BCOdvy2lNBD93xE9 +KgqXcEQh/U4Xc0aupk+oFoCP3cR/58= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744751079; h=from:from: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:in-reply-to:references:references; bh=xFsllInDSe+SHojwQO4gcvZGi+BBau3/2pd7c11VFAU=; b=b/+smepiUW8aTMn5FrWdJCzX9qiCy50c/6ikpyiXeyPJ9buu1jMiMpKqcLGijX8TIfmoqy 5aHu9NkP9KH8S6FpHo1aBs7D6pwEsY4/snfbBkmNnJqMS/SOCR5mUhQcso6KnV9lSoLmej pazOBi/Mtp0Aylx6fQaK9K29ZQU47L0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-UXskAcDnNXizMDmIG5y0cQ-1; Tue, 15 Apr 2025 17:04:34 -0400 X-MC-Unique: UXskAcDnNXizMDmIG5y0cQ-1 X-Mimecast-MFC-AGG-ID: UXskAcDnNXizMDmIG5y0cQ_1744751071 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 942FB18007E1; Tue, 15 Apr 2025 21:04:30 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.64.119]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3D4171955D81; Tue, 15 Apr 2025 21:04:26 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Tejun Heo , =?utf-8?q?Michal_Koutn=C3=BD?= , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Waiman Long Subject: [PATCH v7 1/2] selftests: memcg: Allow low event with no memory.low and memory_recursiveprot on Date: Tue, 15 Apr 2025 17:04:14 -0400 Message-ID: <20250415210415.13414-2-longman@redhat.com> In-Reply-To: <20250415210415.13414-1-longman@redhat.com> References: <20250415210415.13414-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C0E1940004 X-Stat-Signature: fo4fizk7gyh8xtgcr58diik7paxm7po8 X-HE-Tag: 1744751079-13155 X-HE-Meta: U2FsdGVkX1/v0RjqVDcW/g7YO/tF/ILclBJ4EfQKTHNwKR+KU6LIqKaEvPI1FlgRuI5bfsGi2p0zKWrPEbTMXeRHo+TrF8/bQIWTJAqPUnbVlmTnxCc1pRvcX2vLKtMWaUDqUfjw4LyorwWGj62ZfzEn4rTomUFyI7iVAcxscLsjNaLX4DWnq4G93KJIVR/ZKhooj3LYFL7irZEldnA7QDMX9RDDk2QbShq7Kuyj5LZ3zmgC9xy83X9odpIF8yeHZ2TO+s7FBAs2ebmWmIFvo/hfrVTFkpRj4NVj1cSGO5GAwSCoCSf1Mhtm2hFBFoWeUWlCt+9LuiiUA/eNgXzXpF1p9Synfk9OYO1Uy9/j5FiTHXJlb19G42sq/RTPy/LiTCppj8Zz+PIPaC6mCU5sUcu6PRMnmoLLOz7v6HHRK5pu/ymirzWMLF0Kd1tFBDphB8csNyM5iiYVgJZFvBp2bePV+LNvymqf1cfFHypl66FP65wgMnIlhPsSnXcr9xOyNBeegJbsXe93OBydrNrSTA/W2RbBX0BeP576iAXV6XzIOo18OSLAJl3KKLJjbG4EuWu1JxvQweX/IAtxBUCbnGt+p3GPNawvv2OwTuPI1HN7qYs7Jyi0JHsm5DLXONW+Bd3Ycq7aNdrWeuPfnhxhEhyZ8Q66f6VFuG26pzGhNrG7oEnOVHMFzadH4DYaLtdLnn5bXq212IRfeb8ZVbn+hOv92BSwjmX+1qQ+b/+73H73TxKm0P+hmvlLpid6pHPNyASf5yx9lVKnctNqLk1cmDZU+yksC4r4yrJrDeiiMdFZ3zTUMIPppL2IQGlb5rhF2CrCjHKwamXCfwgCDFYzc3KXN1aMR4GRJg+EgpzfWWEkGg80+D1AG8e1NI7kT0DMGDXxi8St6AnLqEyFwWulys5umSiX/0tlVCBzxy+NWS9CX/oXRlUpwI7xWhPiED8Bf1/VBpvnQEnZY8pjCe7 Bfc6c2F3 /povDFhQwtFoJZsGSmUnu7y8OMwuBQch+gDp42YBRUj3YIuPydxItDNfWRcc41hbhIj+GOsQR2oIJqCY7TaVyfEX97FRU5QBcjhOkt0vze7YwW5f4b5r93IPpec8f4lMEOjw+tcA6E4w/f2+6GdgsaMpJH6nQ5hzscUOo/udJIa4rbuYYBq5rRG10cQcmgK48yH8/25LUWK/1aDtjTa5m2/9PlOmYb+uyQBAUYWuPOiX4NFgh1rEBLs5PffKcqvtRxheddG3Jdj1PDz9cdUvjHohabCBGue3P/gYLcnods82SS1G1hbBkFvMXS4coGU0AcAyDxcRHfTX/K0uf/21xOXPOuRMDgzk/lZkcuMg9uZSs3ZjkjfeNg2vlqVl7O7PFpA1Gmn0E0+jU/uCapdYhSt6za29Thz+pHF6PbLa694EdQKB6oXyLlAyF5PqwUi7+e0z0QNQ1VxMiKG74APa4L3zD+V78b57FyoKj X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The test_memcontrol selftest consistently fails its test_memcg_low sub-test due to the fact that its 3rd test child cgroup which have a memmory.low of 0 have low event count. This happens when memory_recursiveprot mount option is enabled which is the default setting used by systemd to mount cgroup2 filesystem. Modify the test_memcontrol.c to allow non-zero low event count in this particular case with memory_recursiveprot on. With this patch applied, the test_memcg_low sub-test finishes successfully without failure in most cases. Though both test_memcg_low and test_memcg_min sub-tests may still fail occasionally if the memory.current values fall outside of the expected ranges. The 4th test child cgroup has no memory usage and so has an effective low of 0. It has no low event count because the mem_cgroup_below_low() check in shrink_node_memcgs() is skipped as mem_cgroup_below_min() returns true. If we ever change mem_cgroup_below_min() in such a way that it no longer skips the no usage case, we will have to add code to explicitly skip it. Suggested-by: Michal Koutný Signed-off-by: Waiman Long --- tools/testing/selftests/cgroup/test_memcontrol.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 16f5d74ae762..5a5dcbe57b56 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -380,10 +380,10 @@ static bool reclaim_until(const char *memcg, long goal); * * Then it checks actual memory usages and expects that: * A/B memory.current ~= 50M - * A/B/C memory.current ~= 29M - * A/B/D memory.current ~= 21M - * A/B/E memory.current ~= 0 - * A/B/F memory.current = 0 + * A/B/C memory.current ~= 29M [memory.events:low > 0] + * A/B/D memory.current ~= 21M [memory.events:low > 0] + * A/B/E memory.current ~= 0 [memory.events:low == 0 if !memory_recursiveprot, > 0 otherwise] + * A/B/F memory.current = 0 [memory.events:low == 0] * (for origin of the numbers, see model in memcg_protection.m.) * * After that it tries to allocate more than there is @@ -525,8 +525,14 @@ static int test_memcg_protection(const char *root, bool min) goto cleanup; } + /* + * Child 2 has memory.low=0, but some low protection is still being + * distributed down from its parent with memory.low=50M if cgroup2 + * memory_recursiveprot mount option is enabled. So the low event + * count will be non-zero in this case. + */ for (i = 0; i < ARRAY_SIZE(children); i++) { - int no_low_events_index = 1; + int no_low_events_index = has_recursiveprot ? 2 : 1; long low, oom; oom = cg_read_key_long(children[i], "memory.events", "oom "); From patchwork Tue Apr 15 21:04:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 14052814 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 35AC5C369BD for ; Tue, 15 Apr 2025 21:04:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14D5A6B0198; Tue, 15 Apr 2025 17:04:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D5B46B0199; Tue, 15 Apr 2025 17:04:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB8EF6B019A; Tue, 15 Apr 2025 17:04:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BFC526B0199 for ; Tue, 15 Apr 2025 17:04:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E68AE1CEA85 for ; Tue, 15 Apr 2025 21:04:41 +0000 (UTC) X-FDA: 83337507162.25.63EE8CC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 16338140018 for ; Tue, 15 Apr 2025 21:04:39 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YJHG5oHM; spf=pass (imf26.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744751080; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G181R4Ce8Y0oezWUB5dkYUGLwtFvIKy14kWYL4Idox0=; b=l5eidy0VBXC6n2r4dZ8cVXd5LyIkarmWhU19COPGdzcVKtxrYXI4IoCAUUFZrcpJudiUeA d4RBcUprRyGflxIZHWeOGDNK08uawBGa3BOrgrqzuheNGAFRD0q/AHJS923dBYBqjvQHjU e7iH1yp2r//N9KvdQg6aoULyGq661hs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YJHG5oHM; spf=pass (imf26.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744751080; a=rsa-sha256; cv=none; b=4XtATnsQlXdZoGkXRrDK/GAmModm9gQcyO23e28HhltbKjMFTZZnhm0RsUuif0fmnZJabf mz1wdbkA6QCtyiZdYr67W10wI5qvvsWoR739eSMwisxr6bNquUZ3FyuYWz9aHpe2ZAnOOR TcCzJVaW1CKWCqhuR+UWHoosPgq3zB4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744751079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G181R4Ce8Y0oezWUB5dkYUGLwtFvIKy14kWYL4Idox0=; b=YJHG5oHM9dNshL0Aac/D3aCXpaLItAWQb5hSwLVcVuBX4dipevXhrxf/KF8z0cfguEr71+ KMUNLgFXGRA/0NnannG3SNQg2+eqy+BfoUwZGkjLYDcOQvXUF2fexftg6EoPdOGoHXfr2G J/E73ecHkYBKAhvKVdZ/y/HvC34T6k0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527-ja4OLp0VOwmG-_HocO_yiA-1; Tue, 15 Apr 2025 17:04:35 -0400 X-MC-Unique: ja4OLp0VOwmG-_HocO_yiA-1 X-Mimecast-MFC-AGG-ID: ja4OLp0VOwmG-_HocO_yiA_1744751074 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F213C1808985; Tue, 15 Apr 2025 21:04:33 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.64.119]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 02B6C19792DC; Tue, 15 Apr 2025 21:04:30 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Tejun Heo , =?utf-8?q?Michal_Koutn=C3=BD?= , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Waiman Long Subject: [PATCH v7 2/2] selftests: memcg: Increase error tolerance of child memory.current check in test_memcg_protection() Date: Tue, 15 Apr 2025 17:04:15 -0400 Message-ID: <20250415210415.13414-3-longman@redhat.com> In-Reply-To: <20250415210415.13414-1-longman@redhat.com> References: <20250415210415.13414-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 16338140018 X-Stat-Signature: q6bxkwskkp6xbi6t1949o1fb5w36d83b X-HE-Tag: 1744751079-383392 X-HE-Meta: U2FsdGVkX1/XOISkxSfJc41YeMPITfKX48m+q1v40RvN1799wKOIB+hIU+kmWyJj4CqYSuRpJEXZ844vfOOpCePHBgMcHuGJ18o6Pnsy5aiJqhA/ELas5kmPLRLU2rsNRDDU5rfzOQioK22TaJZIf/Tw4S6ZJK5XfxM/pmB8vQJx7+9be3svzImvzcyvCfP+Fn6W5pnHy4H47XxhjQTGvq1SpQ5dFFQQrb8yUMvMyypjkzI6NneMfuQVm2pqJ14XmaaYL5AafPlSCe3z+YQ7/bRdZs7xAfvbt3KZLKLQd9P0OFuPRMS/ukaKDDFHQCd6s38uw4+fZBuF94aoBYthcI8Mp68Du+Eh4wSuFz00TwIh38FrYEpoFVjUhaS5+sgf7bSV8LBai49UVzRb6DHXL1FI3Wy+bBJal8fO+eA77j/9/HvRz5a+IHONLuaKz9smnAXD+XN+0Q34Qnjdc2VuS8RymfBPbTFQGmfM1qibyHXOgtVvyDMZTaIveAWAoQ8sUW/oDvj0gON9i5M+B1bSuWwCPXcu3T4RvVbYtXhY/QhxS3P5PuELwDQgJLKnphfAO7SPguiWbuuvayrqkcAhRcAgSwKYm8zBQLXjKKwRkak7AK7qLfW7hqSoXQo7hWEb/6k2rQSK3bAoDco/XMGmJwvvKuRFu5kGdwaHSJaVEaIeUzEFRyUx3061OUwvnrtPmOiZRQ+WUhuKh3qJDEdZT0ujogBwmUZFC1mNqU4WSov0n2fuWeH/RTOUtYT5jZS27YgqpKPYQzu4bnY6qCnE1GMaHkOr76DpMmh/yfhE5r562i9Nes8HUVAEJLNFwUQ+qSz6swKv+WeTiYF4+QGSkAT+hwy4lQRYThBySaW63LoQubDC5rE05yDaatVKGQnfUTggpwZEpeK3/RzbPzP2hlGpVCDJimbtgk0i23wOa5cd92ADumONeaWc1SXjRwFG9FslyeP1tdtp5km8NLk L00tyra3 WXwTyjNeyGmyIJ+iz5tz1w8IGcJn3mlw5M8/bDuGbjDVo/m6pwUDn/TWLfnr4asbWuvEgdcoxXKm64ysnPjSttStjdrDFGS9u3doe4/6vA2bipEa4n15b1vAE1LNsBPPDxmCWwIIQ8zsb+GwpZs4LV+hgjEtGlh8OltgC56K21qkueQsb09+r8pSKMSoW0LFG9N4o+Slx3ucVbNJDPO9vit+fdRgJvgjU17JStdby2O6p0IMmYABdqruxcrEE7YT4viJoT/NUKYg6uqO6t+YLdjEtkoI1P3E9GqRyrvckHzbGpiFLGJUDuHsqXxePnkrcStj4Z8bCXAUJFGAJe6JztMXigSKlfGBsm76SILAyzlzeVTfKpanJv9uuQ0A4dQrRfOrU X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The test_memcg_protection() function is used for the test_memcg_min and test_memcg_low sub-tests. This function generates a set of parent/child cgroups like: parent: memory.min/low = 50M child 0: memory.min/low = 75M, memory.current = 50M child 1: memory.min/low = 25M, memory.current = 50M child 2: memory.min/low = 0, memory.current = 50M After applying memory pressure, the function expects the following actual memory usages. parent: memory.current ~= 50M child 0: memory.current ~= 29M child 1: memory.current ~= 21M child 2: memory.current ~= 0 In reality, the actual memory usages can differ quite a bit from the expected values. It uses an error tolerance of 10% with the values_close() helper. Both the test_memcg_min and test_memcg_low sub-tests can fail sporadically because the actual memory usage exceeds the 10% error tolerance. Below are a sample of the usage data of the tests runs that fail. Child Actual usage Expected usage %err ----- ------------ -------------- ---- 1 16990208 22020096 -12.9% 1 17252352 22020096 -12.1% 0 37699584 30408704 +10.7% 1 14368768 22020096 -21.0% 1 16871424 22020096 -13.2% The current 10% error tolerenace might be right at the time test_memcontrol.c was first introduced in v4.18 kernel, but memory reclaim have certainly evolved quite a bit since then which may result in a bit more run-to-run variation than previously expected. Increase the error tolerance to 15% for child 0 and 20% for child 1 to minimize the chance of this type of failure. The tolerance is bigger for child 1 because an upswing in child 0 corresponds to a smaller %err than a similar downswing in child 1 due to the way %err is used in values_close(). Before this patch, a 100 test runs of test_memcontrol produced the following results: 17 not ok 1 test_memcg_min 22 not ok 2 test_memcg_low After applying this patch, there were no test failure for test_memcg_min and test_memcg_low in 100 test runs. However, these tests may still fail once in a while if the memory usage goes beyond the newly extended range. Signed-off-by: Waiman Long --- tools/testing/selftests/cgroup/test_memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index 5a5dcbe57b56..2ef07b8fa718 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -495,10 +495,10 @@ static int test_memcg_protection(const char *root, bool min) for (i = 0; i < ARRAY_SIZE(children); i++) c[i] = cg_read_long(children[i], "memory.current"); - if (!values_close(c[0], MB(29), 10)) + if (!values_close(c[0], MB(29), 15)) goto cleanup; - if (!values_close(c[1], MB(21), 10)) + if (!values_close(c[1], MB(21), 20)) goto cleanup; if (c[3] != 0)