selftests/vm: make charge_reserved_hugetlb.sh work with existing cgroup setting
authorWaiman Long <longman@redhat.com>
Fri, 14 Jan 2022 22:07:58 +0000 (14:07 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Mar 2022 18:12:38 +0000 (19:12 +0100)
commite9737301f0df5d3b47f7e3eaab57984355291da3
tree91a2a14b7bc20aef9c65b2246ee9735bcad55e55
parent1123c2fb9dc361eb8a0d87608b6f93c7ea6ed5b3
selftests/vm: make charge_reserved_hugetlb.sh work with existing cgroup setting

[ Upstream commit 209376ed2a8431ccb4c40fdcef11194fc1e749b0 ]

The hugetlb cgroup reservation test charge_reserved_hugetlb.sh assume
that no cgroup filesystems are mounted before running the test.  That is
not true in many cases.  As a result, the test fails to run.  Fix that
by querying the current cgroup mount setting and using the existing
cgroup setup instead before attempting to freshly mount a cgroup
filesystem.

Similar change is also made for hugetlb_reparenting_test.sh as well,
though it still has problem if cgroup v2 isn't used.

The patched test scripts were run on a centos 8 based system to verify
that they ran properly.

Link: https://lkml.kernel.org/r/20220106201359.1646575-1-longman@redhat.com
Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests")
Signed-off-by: Waiman Long <longman@redhat.com>
Acked-by: Mina Almasry <almasrymina@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/vm/charge_reserved_hugetlb.sh
tools/testing/selftests/vm/hugetlb_reparenting_test.sh
tools/testing/selftests/vm/write_hugetlb_memory.sh