From: Yuanchu Xie <yuanchu@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Khalid Aziz <khalid.aziz@oracle.com>,
Henry Huang <henry.hj@antgroup.com>, Yu Zhao <yuzhao@google.com>,
Dan Williams <dan.j.williams@intel.com>,
Gregory Price <gregory.price@memverge.com>,
Huang Ying <ying.huang@intel.com>,
Lance Yang <ioworker0@gmail.com>,
Randy Dunlap <rdunlap@infradead.org>,
Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Michal Hocko" <mhocko@kernel.org>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Muchun Song" <muchun.song@linux.dev>,
"Mike Rapoport" <rppt@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
"Christian Brauner" <brauner@kernel.org>,
"Daniel Watson" <ozzloy@each.do>,
"Yuanchu Xie" <yuanchu@google.com>,
cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org
Subject: [PATCH v4 7/9] Docs/admin-guide/mm/workingset_report: document sysfs and memcg interfaces
Date: Tue, 26 Nov 2024 18:57:26 -0800 [thread overview]
Message-ID: <20241127025728.3689245-8-yuanchu@google.com> (raw)
In-Reply-To: <20241127025728.3689245-1-yuanchu@google.com>
Add workingset reporting documentation for better discoverability of
its sysfs and memcg interfaces. Also document the required kernel
config to enable workingset reporting.
Signed-off-by: Yuanchu Xie <yuanchu@google.com>
---
Documentation/admin-guide/mm/index.rst | 1 +
.../admin-guide/mm/workingset_report.rst | 105 ++++++++++++++++++
2 files changed, 106 insertions(+)
create mode 100644 Documentation/admin-guide/mm/workingset_report.rst
diff --git a/Documentation/admin-guide/mm/index.rst b/Documentation/admin-guide/mm/index.rst
index 8b35795b664b..61a2a347fc91 100644
--- a/Documentation/admin-guide/mm/index.rst
+++ b/Documentation/admin-guide/mm/index.rst
@@ -41,4 +41,5 @@ the Linux memory management.
swap_numa
transhuge
userfaultfd
+ workingset_report
zswap
diff --git a/Documentation/admin-guide/mm/workingset_report.rst b/Documentation/admin-guide/mm/workingset_report.rst
new file mode 100644
index 000000000000..0969513705c4
--- /dev/null
+++ b/Documentation/admin-guide/mm/workingset_report.rst
@@ -0,0 +1,105 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=================
+Workingset Report
+=================
+Workingset report provides a view of memory coldness in user-defined
+time intervals, e.g. X bytes are Y milliseconds cold. It breaks down
+the user pages in the system per-NUMA node, per-memcg, for both
+anonymous and file pages into histograms that look like:
+::
+
+ 1000 anon=137368 file=24530
+ 20000 anon=34342 file=0
+ 30000 anon=353232 file=333608
+ 40000 anon=407198 file=206052
+ 9223372036854775807 anon=4925624 file=892892
+
+The workingset reports can be used to drive proactive reclaim, by
+identifying the number of cold bytes in a memcg, then writing to
+``memory.reclaim``.
+
+Quick start
+===========
+Build the kernel with the following configurations. The report relies
+on Multi-gen LRU for page coldness.
+
+* ``CONFIG_LRU_GEN=y``
+* ``CONFIG_LRU_GEN_ENABLED=y``
+* ``CONFIG_WORKINGSET_REPORT=y``
+
+Optionally, the aging kernel daemon can be enabled with the following
+configuration.
+* ``CONFIG_WORKINGSET_REPORT_AGING=y``
+
+Sysfs interfaces
+================
+``/sys/devices/system/node/nodeX/workingset_report/page_age`` provides
+a per-node page age histogram, showing an aggregate of the node's lruvecs.
+Reading this file causes a hierarchical aging of all lruvecs, scanning
+pages and creates a new Multi-gen LRU generation in each lruvec.
+For example:
+::
+
+ 1000 anon=0 file=0
+ 2000 anon=0 file=0
+ 100000 anon=5533696 file=5566464
+ 18446744073709551615 anon=0 file=0
+
+``/sys/devices/system/node/nodeX/workingset_report/page_age_intervals``
+is a comma-separated list of time in milliseconds that configures what
+the page age histogram uses for aggregation. For the above histogram,
+the intervals are::
+
+ 1000,2000,100000
+
+``/sys/devices/system/node/nodeX/workingset_report/refresh_interval``
+defines the amount of time the report is valid for in milliseconds.
+When a report is still valid, reading the ``page_age`` file shows
+the existing valid report, instead of generating a new one.
+
+``/sys/devices/system/node/nodeX/workingset_report/report_threshold``
+specifies how often the userspace agent can be notified for node
+memory pressure, in milliseconds. When a node reaches its low
+watermarks and wakes up kswapd, programs waiting on ``page_age`` are
+woken up so they can read the histogram and make policy decisions.
+
+Memcg interface
+===============
+While ``page_age_interval`` is defined per-node in sysfs, ``page_age``,
+``refresh_interval`` and ``report_threshold`` are available per-memcg.
+
+``/sys/fs/cgroup/.../memory.workingset.page_age``
+The memcg equivalent of the sysfs workingset page age histogram
+breaks down the workingset of this memcg and its children into
+page age intervals. Each node is prefixed with a node header and
+a newline. Non-proactive direct reclaim on this memcg can also
+wake up userspace agents that are waiting on this file.
+E.g.
+::
+
+ N0
+ 1000 anon=0 file=0
+ 2000 anon=0 file=0
+ 3000 anon=0 file=0
+ 4000 anon=0 file=0
+ 5000 anon=0 file=0
+ 18446744073709551615 anon=0 file=0
+
+``/sys/fs/cgroup/.../memory.workingset.refresh_interval``
+The memcg equivalent of the sysfs refresh interval. A per-node
+number of how much time a page age histogram is valid for, in
+milliseconds.
+E.g.
+::
+
+ echo N0=2000 > memory.workingset.refresh_interval
+
+``/sys/fs/cgroup/.../memory.workingset.report_threshold``
+The memcg equivalent of the sysfs report threshold. A per-node
+number of how often userspace agent waiting on the page age
+histogram can be woken up, in milliseconds.
+E.g.
+::
+
+ echo N0=1000 > memory.workingset.report_threshold
--
2.47.0.338.g60cca15819-goog
next prev parent reply other threads:[~2024-11-27 2:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 2:57 [PATCH v4 0/9] mm: workingset reporting Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 1/9] mm: aggregate workingset information into histograms Yuanchu Xie
2024-11-27 4:21 ` Matthew Wilcox
2024-11-27 17:47 ` Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 2/9] mm: use refresh interval to rate-limit workingset report aggregation Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 3/9] mm: report workingset during memory pressure driven scanning Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 4/9] mm: extend workingset reporting to memcgs Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 5/9] mm: add kernel aging thread for workingset reporting Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 6/9] selftest: test system-wide " Yuanchu Xie
2024-11-27 2:57 ` Yuanchu Xie [this message]
2024-11-27 2:57 ` [PATCH v4 8/9] Docs/admin-guide/cgroup-v2: document " Yuanchu Xie
2024-11-27 2:57 ` [PATCH v4 9/9] virtio-balloon: add " Yuanchu Xie
2024-11-27 23:14 ` Daniel Verkamp
2024-11-27 23:38 ` Yuanchu Xie
2024-11-27 7:26 ` [PATCH v4 0/9] mm: " Johannes Weiner
2024-11-27 19:40 ` SeongJae Park
2024-11-27 23:33 ` Yu Zhao
2024-12-06 19:57 ` Yuanchu Xie
2024-12-11 19:53 ` SeongJae Park
2025-01-30 2:02 ` Yuanchu Xie
2025-01-30 4:11 ` SeongJae Park
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=20241127025728.3689245-8-yuanchu@google.com \
--to=yuanchu@google.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=brauner@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=dan.j.williams@intel.com \
--cc=david@redhat.com \
--cc=eperezma@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.price@memverge.com \
--cc=hannes@cmpxchg.org \
--cc=henry.hj@antgroup.com \
--cc=ioworker0@gmail.com \
--cc=jasowang@redhat.com \
--cc=khalid.aziz@oracle.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=mst@redhat.com \
--cc=muchun.song@linux.dev \
--cc=ozzloy@each.do \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
--cc=usama.anjum@collabora.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
--cc=ying.huang@intel.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