From: Yosry Ahmed <yosryahmed@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Shakeel Butt <shakeelb@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.com>, Yu Zhao <yuzhao@google.com>,
Muchun Song <songmuchun@bytedance.com>,
Tejun Heo <tj@kernel.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Vasily Averin <vasily.averin@linux.dev>,
Vlastimil Babka <vbabka@suse.cz>,
Chris Down <chris@chrisdown.name>,
David Rientjes <rientjes@google.com>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Yosry Ahmed <yosryahmed@google.com>
Subject: [PATCH v3 3/3] selftests: cgroup: make sure reclaim target memcg is unprotected
Date: Fri, 2 Dec 2022 03:15:12 +0000 [thread overview]
Message-ID: <20221202031512.1365483-4-yosryahmed@google.com> (raw)
In-Reply-To: <20221202031512.1365483-1-yosryahmed@google.com>
Make sure that we ignore protection of a memcg that is the target of
memcg reclaim.
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
---
tools/testing/selftests/cgroup/test_memcontrol.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
index a8f4700353a4..1e616a8c6a9c 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -238,6 +238,8 @@ static int cg_test_proc_killed(const char *cgroup)
return -1;
}
+static bool reclaim_until(const char *memcg, long goal);
+
/*
* First, this test creates the following hierarchy:
* A memory.min = 0, memory.max = 200M
@@ -266,6 +268,12 @@ static int cg_test_proc_killed(const char *cgroup)
* unprotected memory in A available, and checks that:
* a) memory.min protects pagecache even in this case,
* b) memory.low allows reclaiming page cache with low events.
+ *
+ * Then we try to reclaim from A/B/C using memory.reclaim until its
+ * usage reaches 10M.
+ * This makes sure that:
+ * (a) We ignore the protection of the reclaim target memcg.
+ * (b) The previously calculated emin value (~29M) should be dismissed.
*/
static int test_memcg_protection(const char *root, bool min)
{
@@ -385,6 +393,9 @@ static int test_memcg_protection(const char *root, bool min)
if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3))
goto cleanup;
+ if (!reclaim_until(children[0], MB(10)))
+ goto cleanup;
+
if (min) {
ret = KSFT_PASS;
goto cleanup;
--
2.39.0.rc0.267.gcb52ba06e7-goog
prev parent reply other threads:[~2022-12-02 3:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 3:15 [PATCH v3 0/3] mm: memcg: fix protection of reclaim target memcg Yosry Ahmed
2022-12-02 3:15 ` [PATCH v3 1/3] mm: memcg: fix stale " Yosry Ahmed
2022-12-03 0:26 ` Yosry Ahmed
2022-12-03 0:35 ` Andrew Morton
2022-12-03 0:38 ` Yosry Ahmed
2022-12-03 0:50 ` Andrew Morton
2022-12-03 0:56 ` Yosry Ahmed
2022-12-02 3:15 ` [PATCH v3 2/3] selftests: cgroup: refactor proactive reclaim code to reclaim_until() Yosry Ahmed
2022-12-02 22:20 ` Roman Gushchin
2022-12-02 3:15 ` Yosry Ahmed [this message]
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=20221202031512.1365483-4-yosryahmed@google.com \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chris@chrisdown.name \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.com \
--cc=tj@kernel.org \
--cc=vasily.averin@linux.dev \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=yuzhao@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