On Wed, May 20, 2026 at 05:31:30PM +0800, Guopeng Zhang 
<[email protected]> 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 <[email protected]>
> ---
> 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ý <[email protected]>

Attachment: signature.asc
Description: PGP signature

Reply via email to