linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <roman.gushchin@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Cc: Dave Chinner <dchinner@redhat.com>,
	linux-kernel@vger.kernel.org, Yang Shi <shy828301@gmail.com>,
	Kent Overstreet <kent.overstreet@gmail.com>,
	Hillf Danton <hdanton@sina.com>,
	Roman Gushchin <roman.gushchin@linux.dev>
Subject: [PATCH v2 6/7] docs: document shrinker debugfs
Date: Fri, 22 Apr 2022 13:26:43 -0700	[thread overview]
Message-ID: <20220422202644.799732-7-roman.gushchin@linux.dev> (raw)
In-Reply-To: <20220422202644.799732-1-roman.gushchin@linux.dev>

Add a document describing the shrinker debugfs interface.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
---
 Documentation/admin-guide/mm/index.rst        |  1 +
 .../admin-guide/mm/shrinker_debugfs.rst       | 90 +++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100644 Documentation/admin-guide/mm/shrinker_debugfs.rst

diff --git a/Documentation/admin-guide/mm/index.rst b/Documentation/admin-guide/mm/index.rst
index c21b5823f126..1bd11118dfb1 100644
--- a/Documentation/admin-guide/mm/index.rst
+++ b/Documentation/admin-guide/mm/index.rst
@@ -36,6 +36,7 @@ the Linux memory management.
    numa_memory_policy
    numaperf
    pagemap
+   shrinker_debugfs
    soft-dirty
    swap_numa
    transhuge
diff --git a/Documentation/admin-guide/mm/shrinker_debugfs.rst b/Documentation/admin-guide/mm/shrinker_debugfs.rst
new file mode 100644
index 000000000000..c2f3da534b70
--- /dev/null
+++ b/Documentation/admin-guide/mm/shrinker_debugfs.rst
@@ -0,0 +1,90 @@
+==========================
+Shrinker Debugfs Interface
+==========================
+
+Shrinker debugfs interface provides a visibility into the kernel memory
+shrinkers subsystem and allows to get statistics and interact with
+individual shrinkers.
+
+For each shrinker registered in the system a directory in <debugfs>/shrinker/
+is created. The directory is named like "kfree_rcu-0". Each name is composed
+from the shrinker's name and an unique id.
+
+Each shrinker directory contains "count" and "scan" files, which allow
+to trigger count_objects() and scan_objects() callbacks. For memcg-aware
+and numa-aware shrinkers count_memcg, scan_memcg, count_node, scan_node,
+count_memcg_node and scan_memcg_node are additionally provided. They allow
+to get per-memcg and/or per-node object count and shrink only a specific
+memcg/node.
+
+Usage examples:
+
+ 1. List registered shrinkers::
+      $ cd /sys/kernel/debug/shrinker/
+      $ ls
+      dqcache-16          sb-cgroup2-30    sb-hugetlbfs-33  sb-proc-41       sb-selinuxfs-22  sb-tmpfs-40    sb-zsmalloc-19
+      kfree_rcu-0         sb-configfs-23   sb-iomem-12      sb-proc-44       sb-sockfs-8      sb-tmpfs-42    shadow-18
+      sb-aio-20           sb-dax-11        sb-mqueue-21     sb-proc-45       sb-sysfs-26      sb-tmpfs-43    thp_deferred_split-10
+      sb-anon_inodefs-15  sb-debugfs-7     sb-nsfs-4        sb-proc-47       sb-tmpfs-1       sb-tmpfs-46    thp_zero-9
+      sb-bdev-3           sb-devpts-28     sb-pipefs-14     sb-pstore-31     sb-tmpfs-27      sb-tmpfs-49    xfs_buf-37
+      sb-bpf-32           sb-devtmpfs-5    sb-proc-25       sb-rootfs-2      sb-tmpfs-29      sb-tracefs-13  xfs_inodegc-38
+      sb-btrfs-24         sb-hugetlbfs-17  sb-proc-39       sb-securityfs-6  sb-tmpfs-35      sb-xfs-36      zspool-34
+
+ 2. Get information about a specific shrinker::
+      $ cd sb-btrfs-24/
+      $ ls
+      count  count_memcg  count_memcg_node  count_node  scan  scan_memcg  scan_memcg_node  scan_node
+
+ 3. Count objects on the system/root cgroup level::
+      $ cat count
+      212
+
+ 4. Count objects on the system/root cgroup level per numa node (on a 2-node machine)::
+      $ cat count_node
+      209 3
+
+ 5. Count objects for each memcg (output format: cgroup inode, count)::
+      $ cat count_memcg
+      1 212
+      20 96
+      53 817
+      2297 2
+      218 13
+      581 30
+      911 124
+      ...
+
+ 6. Same but with a per-node output::
+      $ cat count_memcg_node
+      1 209 3
+      20 96 0
+      53 810 7
+      2297 2 0
+      218 13 0
+      581 30 0
+      911 124 0
+      ...
+
+ 7. Scan system/root shrinker::
+      $ cat count
+      212
+      $ echo 100 > scan
+      $ cat scan
+      97
+      $ cat count
+      115
+
+ 8. Scan individual memcg::
+      $ echo "1868 500" > scan_memcg
+      $ cat scan_memcg
+      193
+
+ 9. Scan individual node::
+      $ echo "1 200" > scan_node
+      $ cat scan_node
+      2
+
+ 10. Scan individual memcg and node::
+     $ echo "1868 0 500" > scan_memcg_node
+     $ cat scan_memcg_node
+     435
-- 
2.35.1



  parent reply	other threads:[~2022-04-22 20:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 20:26 [PATCH v2 0/7] mm: introduce shrinker debugfs interface Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 1/7] mm: introduce debugfs interface for kernel memory shrinkers Roman Gushchin
2022-04-23  7:51   ` Christophe JAILLET
2022-04-22 20:26 ` [PATCH v2 2/7] mm: memcontrol: introduce mem_cgroup_ino() and mem_cgroup_get_from_ino() Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 3/7] mm: introduce memcg interfaces for shrinker debugfs Roman Gushchin
2022-04-23  0:35   ` Hillf Danton
2022-04-23  1:29     ` Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 4/7] mm: introduce numa " Roman Gushchin
2022-04-22 20:26 ` [PATCH v2 5/7] mm: provide shrinkers with names Roman Gushchin
2022-04-23  7:46   ` Christophe JAILLET
2022-04-28  0:25     ` Roman Gushchin
2022-04-22 20:26 ` Roman Gushchin [this message]
2022-04-22 20:26 ` [PATCH v2 7/7] tools: add memcg_shrinker.py Roman Gushchin
2022-04-26  6:02 ` [PATCH v2 0/7] mm: introduce shrinker debugfs interface Dave Chinner
2022-04-26  6:45   ` Kent Overstreet
2022-04-26  8:45   ` Hillf Danton
2022-04-26 16:41   ` Roman Gushchin
2022-04-26 18:37     ` Kent Overstreet
2022-04-27  1:22     ` Dave Chinner
2022-04-27  2:18       ` Roman Gushchin
2022-04-26 19:05   ` Roman Gushchin
2022-04-27  1:02     ` Dave Chinner

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=20220422202644.799732-7-roman.gushchin@linux.dev \
    --to=roman.gushchin@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=dchinner@redhat.com \
    --cc=hdanton@sina.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shy828301@gmail.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;
as well as URLs for NNTP newsgroup(s).