Back to home page

OSCL-LXR

 
 

    


0001 .. _shrinker_debugfs:
0002 
0003 ==========================
0004 Shrinker Debugfs Interface
0005 ==========================
0006 
0007 Shrinker debugfs interface provides a visibility into the kernel memory
0008 shrinkers subsystem and allows to get information about individual shrinkers
0009 and interact with them.
0010 
0011 For each shrinker registered in the system a directory in **<debugfs>/shrinker/**
0012 is created. The directory's name is composed from the shrinker's name and an
0013 unique id: e.g. *kfree_rcu-0* or *sb-xfs:vda1-36*.
0014 
0015 Each shrinker directory contains **count** and **scan** files, which allow to
0016 trigger *count_objects()* and *scan_objects()* callbacks for each memcg and
0017 numa node (if applicable).
0018 
0019 Usage:
0020 ------
0021 
0022 1. *List registered shrinkers*
0023 
0024   ::
0025 
0026     $ cd /sys/kernel/debug/shrinker/
0027     $ ls
0028     dquota-cache-16     sb-devpts-28     sb-proc-47       sb-tmpfs-42
0029     mm-shadow-18        sb-devtmpfs-5    sb-proc-48       sb-tmpfs-43
0030     mm-zspool:zram0-34  sb-hugetlbfs-17  sb-pstore-31     sb-tmpfs-44
0031     rcu-kfree-0         sb-hugetlbfs-33  sb-rootfs-2      sb-tmpfs-49
0032     sb-aio-20           sb-iomem-12      sb-securityfs-6  sb-tracefs-13
0033     sb-anon_inodefs-15  sb-mqueue-21     sb-selinuxfs-22  sb-xfs:vda1-36
0034     sb-bdev-3           sb-nsfs-4        sb-sockfs-8      sb-zsmalloc-19
0035     sb-bpf-32           sb-pipefs-14     sb-sysfs-26      thp-deferred_split-10
0036     sb-btrfs:vda2-24    sb-proc-25       sb-tmpfs-1       thp-zero-9
0037     sb-cgroup2-30       sb-proc-39       sb-tmpfs-27      xfs-buf:vda1-37
0038     sb-configfs-23      sb-proc-41       sb-tmpfs-29      xfs-inodegc:vda1-38
0039     sb-dax-11           sb-proc-45       sb-tmpfs-35
0040     sb-debugfs-7        sb-proc-46       sb-tmpfs-40
0041 
0042 2. *Get information about a specific shrinker*
0043 
0044   ::
0045 
0046     $ cd sb-btrfs\:vda2-24/
0047     $ ls
0048     count            scan
0049 
0050 3. *Count objects*
0051 
0052   Each line in the output has the following format::
0053 
0054     <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1> ...
0055     <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1> ...
0056     ...
0057 
0058   If there are no objects on all numa nodes, a line is omitted. If there
0059   are no objects at all, the output might be empty.
0060 
0061   If the shrinker is not memcg-aware or CONFIG_MEMCG is off, 0 is printed
0062   as cgroup inode id. If the shrinker is not numa-aware, 0's are printed
0063   for all nodes except the first one.
0064   ::
0065 
0066     $ cat count
0067     1 224 2
0068     21 98 0
0069     55 818 10
0070     2367 2 0
0071     2401 30 0
0072     225 13 0
0073     599 35 0
0074     939 124 0
0075     1041 3 0
0076     1075 1 0
0077     1109 1 0
0078     1279 60 0
0079     1313 7 0
0080     1347 39 0
0081     1381 3 0
0082     1449 14 0
0083     1483 63 0
0084     1517 53 0
0085     1551 6 0
0086     1585 1 0
0087     1619 6 0
0088     1653 40 0
0089     1687 11 0
0090     1721 8 0
0091     1755 4 0
0092     1789 52 0
0093     1823 888 0
0094     1857 1 0
0095     1925 2 0
0096     1959 32 0
0097     2027 22 0
0098     2061 9 0
0099     2469 799 0
0100     2537 861 0
0101     2639 1 0
0102     2707 70 0
0103     2775 4 0
0104     2877 84 0
0105     293 1 0
0106     735 8 0
0107 
0108 4. *Scan objects*
0109 
0110   The expected input format::
0111 
0112     <cgroup inode id> <numa id> <number of objects to scan>
0113 
0114   For a non-memcg-aware shrinker or on a system with no memory
0115   cgrups **0** should be passed as cgroup id.
0116   ::
0117 
0118     $ cd /sys/kernel/debug/shrinker/
0119     $ cd sb-btrfs\:vda2-24/
0120 
0121     $ cat count | head -n 5
0122     1 212 0
0123     21 97 0
0124     55 802 5
0125     2367 2 0
0126     225 13 0
0127 
0128     $ echo "55 0 200" > scan
0129 
0130     $ cat count | head -n 5
0131     1 212 0
0132     21 96 0
0133     55 752 5
0134     2367 2 0
0135     225 13 0