From: Nhat Pham <nphamcs@gmail.com>
To: akpm@linux-foundation.org
Cc: riel@surriel.com, hannes@cmpxchg.org, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeelb@google.com,
muchun.song@linux.dev, tj@kernel.org, lizefan.x@bytedance.com,
shuah@kernel.org, mike.kravetz@oracle.com, yosryahmed@google.com,
linux-mm@kvack.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests: add a selftest to verify hugetlb usage in memcg
Date: Tue, 26 Sep 2023 13:41:08 -0700 [thread overview]
Message-ID: <20230926204108.2931076-1-nphamcs@gmail.com> (raw)
In-Reply-To: <20230926194949.2637078-3-nphamcs@gmail.com>
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;
parent reply other threads:[~2023-09-26 20:41 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20230926194949.2637078-3-nphamcs@gmail.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230926204108.2931076-1-nphamcs@gmail.com \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
--cc=yosryahmed@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox