From nobody Mon May 25 00:10:57 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AA8B3C65E0; Wed, 20 May 2026 09:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779269537; cv=none; b=sGoEubO5mRsPpA3PMflNfAp1NegfwlNH+ytOQrTyu85efo4EZzxifE/uDrmJXEp8c1GxvbMuqOXyCVx81QLPM5n7Iv6GFzUFGI79vfewAlqHxsWvJmoj1Mwj3wqddvhn+FmuZ1nBq7Nvt9tmbI5ICubCpcFb/F8N58AyOMR/ZR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779269537; c=relaxed/simple; bh=8YfbGTb5qD2kWjjJr6kJPWp9Ff0N5ji9lmV/cl0fe7Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PmRIi9YZzV661yNAW7o3QY0VgyHbhR0VCCjD+56sSn9dnXjxzI3YkmBv0Q7nBBQvDu2JEUnGKiepxqAWssx0CZc0Ee9OOSbGynOxDS9JNnE+h0oDoGUJIPzsisgVcH0r8uZyd3GWX3IqGrWGnXB4MCijwxOgw4UeKUABVtO6TIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: bcdc7526542e11f1aa26b74ffac11d73-20260520 X-CTIC-Tags: HR_CC_COUNT, HR_CC_DOMAIN_COUNT, HR_CC_NAME, HR_CC_NO_NAME, HR_CHARSET HR_CHARSET_NUM, HR_CTE_8B, HR_CTT_MISS, HR_DATE_H, HR_DATE_WKD HR_DATE_ZONE, HR_FROM_NAME, HR_SJ_LANG, HR_SJ_LEN, HR_SJ_LETTER HR_SJ_NOR_SYM, HR_SJ_PHRASE, HR_SJ_PHRASE_LEN, HR_SJ_WS, HR_TO_CHARSET HR_TO_CHARSET_NUM, HR_TO_COUNT, HR_TO_DOMAIN_COUNT, HR_TO_NAME, IP_TRUSTED SRC_TRUSTED, DN_TRUSTED, SA_TRUSTED, SA_EXISTED, SN_TRUSTED SN_EXISTED, SPF_NOPASS, DKIM_NOPASS, DMARC_NOPASS, CIE_GOOD CIE_GOOD_SPF, GTI_FG_BS, GTI_RG_INFO, GTI_C_BU, AMN_GOOD ABX_MISS_RDNS X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:8ea1c0e1-8084-4f84-8587-b02fe67b2cdc,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:10 X-CID-INFO: VERSION:1.3.12,REQID:8ea1c0e1-8084-4f84-8587-b02fe67b2cdc,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:10 X-CID-META: VersionHash:e7bac3a,CLOUDID:a38dba02c14bbe1690276f6c3af2da88,BulkI D:260520173155BISL4B5P,BulkQuantity:0,Recheck:0,SF:17|19|38|66|78|102|127| 865|898,TC:nil,Content:0|15|50,EDM:-3,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil ,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE: 0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: bcdc7526542e11f1aa26b74ffac11d73-20260520 X-User: zhangguopeng@kylinos.cn Received: from yan.. [(183.242.174.22)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1577218; Wed, 20 May 2026 17:31:53 +0800 From: Guopeng Zhang To: Shuah Khan , Tejun Heo , =?UTF-8?q?Michal=20Koutn=C3=BD?= Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Oscar Salvador , David Hildenbrand , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test Date: Wed, 20 May 2026 17:31:30 +0800 Message-ID: <20260520093130.490020-1-zhangguopeng@kylinos.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" test_hugetlb_memcg creates a child cgroup and then writes memory.max and memory.swap.max. When the test is run standalone, the memory controller may not be enabled in the test root cgroup's subtree_control. In that case, the child cgroup is created without the memory control files, and the test fails during setup before reaching the hugetlb memcg accounting checks. Skip the test when the memory controller is unavailable. Otherwise, enable it in subtree_control before creating the test cgroup. Signed-off-by: Guopeng Zhang Acked-by: Michal Koutn=C3=BD --- Tested with a cgroup namespace where memory is available in cgroup.controllers but not enabled in cgroup.subtree_control: before: test_hugetlb_memcg failed with "fail to set cgroup memory limit" after: test_hugetlb_memcg passed and cgroup.subtree_control contained me= mory tools/testing/selftests/cgroup/test_hugetlb_memcg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c b/tools/te= sting/selftests/cgroup/test_hugetlb_memcg.c index f451aa449be6..b627d84358b1 100644 --- a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c +++ b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c @@ -217,6 +217,14 @@ int main(int argc, char **argv) if (cg_find_unified_root(root, sizeof(root), NULL)) ksft_exit_skip("cgroup v2 isn't mounted\n"); =20 + if (cg_read_strstr(root, "cgroup.controllers", "memory")) + ksft_exit_skip("memory controller isn't available\n"); + + if (cg_read_strstr(root, "cgroup.subtree_control", "memory")) { + if (cg_write(root, "cgroup.subtree_control", "+memory")) + ksft_exit_skip("Failed to set memory controller\n"); + } + switch (test_hugetlb_memcg(root)) { case KSFT_PASS: ksft_test_result_pass("test_hugetlb_memcg\n"); --=20 2.43.0