lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 26 Sep 2023 13:41:08 -0700
From:   Nhat Pham <nphamcs@...il.com>
To:     akpm@...ux-foundation.org
Cc:     riel@...riel.com, hannes@...xchg.org, mhocko@...nel.org,
        roman.gushchin@...ux.dev, shakeelb@...gle.com,
        muchun.song@...ux.dev, tj@...nel.org, lizefan.x@...edance.com,
        shuah@...nel.org, mike.kravetz@...cle.com, yosryahmed@...gle.com,
        linux-mm@...ck.org, kernel-team@...a.com,
        linux-kernel@...r.kernel.org, cgroups@...r.kernel.org
Subject: Re: [PATCH 2/2] selftests: add a selftest to verify hugetlb usage in memcg

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;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ