* [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test
@ 2026-05-20 9:31 Guopeng Zhang
2026-05-22 14:17 ` Michal Koutný
2026-05-22 16:24 ` Tejun Heo
0 siblings, 2 replies; 3+ messages in thread
From: Guopeng Zhang @ 2026-05-20 9:31 UTC (permalink / raw)
To: Shuah Khan, Tejun Heo, Michal Koutný
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Muchun Song, Oscar Salvador, David Hildenbrand, cgroups, linux-mm,
linux-kselftest, linux-kernel, Guopeng Zhang
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 <zhangguopeng@kylinos.cn>
---
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 memory
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/testing/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");
+ 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");
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test
2026-05-20 9:31 [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test Guopeng Zhang
@ 2026-05-22 14:17 ` Michal Koutný
2026-05-22 16:24 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Michal Koutný @ 2026-05-22 14:17 UTC (permalink / raw)
To: Guopeng Zhang
Cc: Shuah Khan, Tejun Heo, Johannes Weiner, Michal Hocko,
Roman Gushchin, Shakeel Butt, Muchun Song, Oscar Salvador,
David Hildenbrand, cgroups, linux-mm, linux-kselftest,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]
On Wed, May 20, 2026 at 05:31:30PM +0800, Guopeng Zhang <zhangguopeng@kylinos.cn> wrote:
> 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.
Makes sense.
> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
> ---
> 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 memory
>
> tools/testing/selftests/cgroup/test_hugetlb_memcg.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Acked-by: Michal Koutný <mkoutny@suse.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test
2026-05-20 9:31 [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test Guopeng Zhang
2026-05-22 14:17 ` Michal Koutný
@ 2026-05-22 16:24 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2026-05-22 16:24 UTC (permalink / raw)
To: Guopeng Zhang
Cc: Shuah Khan, Johannes Weiner, Michal Hocko, Roman Gushchin,
Shakeel Butt, Muchun Song, Oscar Salvador, David Hildenbrand,
Michal Koutný, cgroups, linux-mm, linux-kselftest,
linux-kernel
Hello,
Applied to cgroup/for-7.2.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-22 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 9:31 [PATCH] selftests/cgroup: enable memory controller in hugetlb memcg test Guopeng Zhang
2026-05-22 14:17 ` Michal Koutný
2026-05-22 16:24 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox