* Re: [PATCH 2/2] selftests: add a selftest to verify hugetlb usage in memcg
[not found] <20230926194949.2637078-3-nphamcs@gmail.com>
@ 2023-09-26 20:41 ` Nhat Pham
0 siblings, 0 replies; only message in thread
From: Nhat Pham @ 2023-09-26 20:41 UTC (permalink / raw)
To: akpm
Cc: riel, hannes, mhocko, roman.gushchin, shakeelb, muchun.song, tj,
lizefan.x, shuah, mike.kravetz, yosryahmed, linux-mm,
kernel-team, linux-kernel, cgroups
Ooops I forgot to commit this change.
Basically just moving the nr_hugepages check inside the test program
run within the cgroup. This should apply cleanly:
diff --git a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c
index 9651f6af6914..436522257cd2 100644
--- a/tools/testing/selftests/cgroup/test_hugetlb_memcg.c
+++ b/tools/testing/selftests/cgroup/test_hugetlb_memcg.c
@@ -100,6 +100,14 @@ static int hugetlb_test_program(const char *cgroup, void *arg)
int ret = EXIT_FAILURE;
old_current = cg_read_long(test_group, "memory.current");
+ set_nr_hugepages(20);
+ current = cg_read_long(test_group, "memory.current");
+ expected_current = old_current;
+ if (!values_close(expected_current, current, 10)) {
+ ksft_print_msg(
+ "memory usage should not increase after setting nr_hugepages.\n");
+ return EXIT_FAILURE;
+ }
addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, 0, 0);
if (addr == MAP_FAILED) {
@@ -152,10 +160,8 @@ static int test_hugetlb_memcg(char *root)
{
int ret = KSFT_FAIL;
char *test_group;
- long old_current, expected_current, current;
test_group = cg_name(root, "hugetlb_memcg_test");
-
if (!test_group || cg_create(test_group)) {
ksft_print_msg("fail to create cgroup.\n");
goto out;
@@ -171,16 +177,6 @@ static int test_hugetlb_memcg(char *root)
ksft_print_msg("fail to disable swap.\n");
goto out;
}
- old_current = cg_read_long(test_group, "memory.current");
-
- set_nr_hugepages(20);
- current = cg_read_long(test_group, "memory.current");
- expected_current = old_current;
- if (!values_close(expected_current, current, 10)) {
- ksft_print_msg(
- "memory usage should not increase after setting nr_hugepages.\n");
- goto out;
- }
if (!cg_run(test_group, hugetlb_test_program, (void *)test_group))
ret = KSFT_PASS;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-26 20:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230926194949.2637078-3-nphamcs@gmail.com>
2023-09-26 20:41 ` [PATCH 2/2] selftests: add a selftest to verify hugetlb usage in memcg Nhat Pham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox