Re: [PATCH 2/2] selftests: add a selftest to verify hugetlb usage in memcg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux