From: Ning Zhang <ningzhang@linux.alibaba.com>
To: linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
Yu Zhao <yuzhao@google.com>
Subject: [RFC 6/6] mm, thp: add document for zero subpages reclaim
Date: Thu, 28 Oct 2021 19:56:55 +0800 [thread overview]
Message-ID: <1635422215-99394-7-git-send-email-ningzhang@linux.alibaba.com> (raw)
In-Reply-To: <1635422215-99394-1-git-send-email-ningzhang@linux.alibaba.com>
Add user guide for thp zero subpages reclaim.
Signed-off-by: Ning Zhang <ningzhang@linux.alibaba.com>
---
Documentation/admin-guide/mm/transhuge.rst | 75 ++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst
index c9c37f1..85cd3b7 100644
--- a/Documentation/admin-guide/mm/transhuge.rst
+++ b/Documentation/admin-guide/mm/transhuge.rst
@@ -421,3 +421,78 @@ support enabled just fine as always. No difference can be noted in
hugetlbfs other than there will be less overall fragmentation. All
usual features belonging to hugetlbfs are preserved and
unaffected. libhugetlbfs will also work fine as usual.
+
+THP zero subpages reclaim
+=========================
+THP may lead to memory bloat which may cause OOM. The reason is a huge
+page may contain some zero subpages which users didn't really access them.
+To avoid this, a mechanism to reclaim these zero subpages is introduced::
+
+ echo 1 > /sys/fs/cgroup/memory/{memcg}/memory.thp_reclaim
+ echo 0 > /sys/fs/cgroup/memory/{memcg}/memory.thp_reclaim
+
+Echo 1 to enable and echo 0 to disable.
+The default value is inherited from its parent. The default mode of root
+memcg is disable.
+
+We also add a global interface, if you don't want to configure it by
+configuring every memory cgroup, you can use this one::
+
+ /sys/kernel/mm/transparent_hugepage/reclaim
+
+memcg
+ The default mode. It means every mem cgroup will use their own
+ configure.
+
+enable
+ means every mem cgroup will enable reclaim.
+
+disable
+ means every mem cgroup will disable reclaim.
+
+If zero subpages reclaim is enabled, the new huge page will be add to a
+reclaim queue in mem_cgroup, and the queue would be scanned when memory
+reclaiming. The queue stat can be checked like this::
+
+ cat /sys/fs/cgroup/memory/{memcg}/memory.thp_reclaim_stat
+
+queue_length
+ means the queue length of each node.
+
+split_hpage
+ means the numbers of huge pages split by thp reclaim of each node.
+
+split_failed
+ means the numbers of huge pages split failed by thp reclaim of
+ each node.
+
+reclaim_subpage
+ means the numbers of zero subpages reclaimed by thp reclaim of
+ each node.
+
+We also add a controller interface to set configs for thp reclaim::
+
+ /sys/fs/cgroup/memory/{memcg}/memory.thp_reclaim_ctrl
+
+threshold
+ means the huge page which contains at least threshold zero pages would
+ be split (estimate it by checking some discrete unsigned long values).
+ The default value of threshold is 16, and will inherit from it's parent.
+ The range of this value is (0, HPAGE_PMD_NR], which means the value must
+ be less than or equal to HPAGE_PMD_NR (512 in x86), and be greater than 0.
+ We can set reclaim threshold to be 8 by this::
+
+ echo "threshold 8" > memory.thp_reclaim_ctrl
+
+reclaim
+ triggers action immediately for the huge pages in the reclaim queue.
+ The action deponds on the thp reclaim config (reclaim, swap or disable,
+ disable means just remove the huge page from the queue).
+ This contronller has two value, 1 and 2. 1 means just reclaim the current
+ memcg, and 2 means reclaim the current memcg and all the children memcgs.
+ Like this::
+
+ echo "reclaim 1" > memory.thp_reclaim_ctrl
+ echo "reclaim 2" > memory.thp_reclaim_ctrl
+
+Only one of the configs mentioned above can be set at a time.
--
1.8.3.1
next prev parent reply other threads:[~2021-10-28 11:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 11:56 [RFC 0/6] Reclaim zero subpages of thp to avoid memory bloat Ning Zhang
2021-10-28 11:56 ` [RFC 1/6] mm, thp: introduce thp zero subpages reclaim Ning Zhang
2021-10-28 12:53 ` Matthew Wilcox
2021-10-29 12:16 ` ning zhang
2021-10-28 11:56 ` [RFC 2/6] mm, thp: add a global interface for zero subapges reclaim Ning Zhang
2021-10-28 11:56 ` [RFC 3/6] mm, thp: introduce zero subpages reclaim threshold Ning Zhang
2021-10-28 11:56 ` [RFC 4/6] mm, thp: introduce a controller to trigger zero subpages reclaim Ning Zhang
2021-10-28 11:56 ` [RFC 5/6] mm, thp: add some statistics for " Ning Zhang
2021-10-28 11:56 ` Ning Zhang [this message]
2021-10-28 14:13 ` [RFC 0/6] Reclaim zero subpages of thp to avoid memory bloat Kirill A. Shutemov
2021-10-29 12:07 ` ning zhang
2021-10-29 16:56 ` Yang Shi
2021-11-01 2:50 ` ning zhang
2021-10-29 13:38 ` Michal Hocko
2021-10-29 16:12 ` ning zhang
2021-11-01 9:20 ` Michal Hocko
2021-11-08 3:24 ` ning zhang
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=1635422215-99394-7-git-send-email-ningzhang@linux.alibaba.com \
--to=ningzhang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vdavydov.dev@gmail.com \
--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