1 ==========================
2 Shrinker Debugfs Interface
3 ==========================
5 Shrinker debugfs interface provides a visibility into the kernel memory
6 shrinkers subsystem and allows to get information about individual shrinkers
7 and interact with them.
9 For each shrinker registered in the system a directory in **<debugfs>/shrinker/**
10 is created. The directory's name is composed from the shrinker's name and an
11 unique id: e.g. *kfree_rcu-0* or *sb-xfs:vda1-36*.
13 Each shrinker directory contains **count** and **scan** files, which allow to
14 trigger *count_objects()* and *scan_objects()* callbacks for each memcg and
15 numa node (if applicable).
20 1. *List registered shrinkers*
24 $ cd /sys/kernel/debug/shrinker/
26 dquota-cache-16 sb-devpts-28 sb-proc-47 sb-tmpfs-42
27 mm-shadow-18 sb-devtmpfs-5 sb-proc-48 sb-tmpfs-43
28 mm-zspool:zram0-34 sb-hugetlbfs-17 sb-pstore-31 sb-tmpfs-44
29 rcu-kfree-0 sb-hugetlbfs-33 sb-rootfs-2 sb-tmpfs-49
30 sb-aio-20 sb-iomem-12 sb-securityfs-6 sb-tracefs-13
31 sb-anon_inodefs-15 sb-mqueue-21 sb-selinuxfs-22 sb-xfs:vda1-36
32 sb-bdev-3 sb-nsfs-4 sb-sockfs-8 sb-zsmalloc-19
33 sb-bpf-32 sb-pipefs-14 sb-sysfs-26 thp-deferred_split-10
34 sb-btrfs:vda2-24 sb-proc-25 sb-tmpfs-1 thp-zero-9
35 sb-cgroup2-30 sb-proc-39 sb-tmpfs-27 xfs-buf:vda1-37
36 sb-configfs-23 sb-proc-41 sb-tmpfs-29 xfs-inodegc:vda1-38
37 sb-dax-11 sb-proc-45 sb-tmpfs-35
38 sb-debugfs-7 sb-proc-46 sb-tmpfs-40
40 2. *Get information about a specific shrinker*
44 $ cd sb-btrfs\:vda2-24/
50 Each line in the output has the following format::
52 <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1> ...
53 <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1> ...
56 If there are no objects on all numa nodes, a line is omitted. If there
57 are no objects at all, the output might be empty.
59 If the shrinker is not memcg-aware or CONFIG_MEMCG is off, 0 is printed
60 as cgroup inode id. If the shrinker is not numa-aware, 0's are printed
61 for all nodes except the first one.
108 The expected input format::
110 <cgroup inode id> <numa id> <number of objects to scan>
112 For a non-memcg-aware shrinker or on a system with no memory
113 cgrups **0** should be passed as cgroup id.
116 $ cd /sys/kernel/debug/shrinker/
117 $ cd sb-btrfs\:vda2-24/
119 $ cat count | head -n 5
126 $ echo "55 0 200" > scan
128 $ cat count | head -n 5