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 ");