>> 1 .. _shrinker_debugfs: >> 2 1 ========================== 3 ========================== 2 Shrinker Debugfs Interface 4 Shrinker Debugfs Interface 3 ========================== 5 ========================== 4 6 5 Shrinker debugfs interface provides a visibili 7 Shrinker debugfs interface provides a visibility into the kernel memory 6 shrinkers subsystem and allows to get informat 8 shrinkers subsystem and allows to get information about individual shrinkers 7 and interact with them. 9 and interact with them. 8 10 9 For each shrinker registered in the system a d 11 For each shrinker registered in the system a directory in **<debugfs>/shrinker/** 10 is created. The directory's name is composed f 12 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- 13 unique id: e.g. *kfree_rcu-0* or *sb-xfs:vda1-36*. 12 14 13 Each shrinker directory contains **count** and 15 Each shrinker directory contains **count** and **scan** files, which allow to 14 trigger *count_objects()* and *scan_objects()* 16 trigger *count_objects()* and *scan_objects()* callbacks for each memcg and 15 numa node (if applicable). 17 numa node (if applicable). 16 18 17 Usage: 19 Usage: 18 ------ 20 ------ 19 21 20 1. *List registered shrinkers* 22 1. *List registered shrinkers* 21 23 22 :: 24 :: 23 25 24 $ cd /sys/kernel/debug/shrinker/ 26 $ cd /sys/kernel/debug/shrinker/ 25 $ ls 27 $ ls 26 dquota-cache-16 sb-devpts-28 sb-pr 28 dquota-cache-16 sb-devpts-28 sb-proc-47 sb-tmpfs-42 27 mm-shadow-18 sb-devtmpfs-5 sb-pr 29 mm-shadow-18 sb-devtmpfs-5 sb-proc-48 sb-tmpfs-43 28 mm-zspool:zram0-34 sb-hugetlbfs-17 sb-ps 30 mm-zspool:zram0-34 sb-hugetlbfs-17 sb-pstore-31 sb-tmpfs-44 29 rcu-kfree-0 sb-hugetlbfs-33 sb-ro 31 rcu-kfree-0 sb-hugetlbfs-33 sb-rootfs-2 sb-tmpfs-49 30 sb-aio-20 sb-iomem-12 sb-se 32 sb-aio-20 sb-iomem-12 sb-securityfs-6 sb-tracefs-13 31 sb-anon_inodefs-15 sb-mqueue-21 sb-se 33 sb-anon_inodefs-15 sb-mqueue-21 sb-selinuxfs-22 sb-xfs:vda1-36 32 sb-bdev-3 sb-nsfs-4 sb-so 34 sb-bdev-3 sb-nsfs-4 sb-sockfs-8 sb-zsmalloc-19 33 sb-bpf-32 sb-pipefs-14 sb-sy 35 sb-bpf-32 sb-pipefs-14 sb-sysfs-26 thp-deferred_split-10 34 sb-btrfs:vda2-24 sb-proc-25 sb-tm 36 sb-btrfs:vda2-24 sb-proc-25 sb-tmpfs-1 thp-zero-9 35 sb-cgroup2-30 sb-proc-39 sb-tm 37 sb-cgroup2-30 sb-proc-39 sb-tmpfs-27 xfs-buf:vda1-37 36 sb-configfs-23 sb-proc-41 sb-tm 38 sb-configfs-23 sb-proc-41 sb-tmpfs-29 xfs-inodegc:vda1-38 37 sb-dax-11 sb-proc-45 sb-tm 39 sb-dax-11 sb-proc-45 sb-tmpfs-35 38 sb-debugfs-7 sb-proc-46 sb-tm 40 sb-debugfs-7 sb-proc-46 sb-tmpfs-40 39 41 40 2. *Get information about a specific shrinker* 42 2. *Get information about a specific shrinker* 41 43 42 :: 44 :: 43 45 44 $ cd sb-btrfs\:vda2-24/ 46 $ cd sb-btrfs\:vda2-24/ 45 $ ls 47 $ ls 46 count scan 48 count scan 47 49 48 3. *Count objects* 50 3. *Count objects* 49 51 50 Each line in the output has the following fo 52 Each line in the output has the following format:: 51 53 52 <cgroup inode id> <nr of objects on node 0 54 <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 55 <cgroup inode id> <nr of objects on node 0> <nr of objects on node 1> ... 54 ... 56 ... 55 57 56 If there are no objects on all numa nodes, a 58 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 e 59 are no objects at all, the output might be empty. 58 60 59 If the shrinker is not memcg-aware or CONFIG 61 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 n 62 as cgroup inode id. If the shrinker is not numa-aware, 0's are printed 61 for all nodes except the first one. 63 for all nodes except the first one. 62 :: 64 :: 63 65 64 $ cat count 66 $ cat count 65 1 224 2 67 1 224 2 66 21 98 0 68 21 98 0 67 55 818 10 69 55 818 10 68 2367 2 0 70 2367 2 0 69 2401 30 0 71 2401 30 0 70 225 13 0 72 225 13 0 71 599 35 0 73 599 35 0 72 939 124 0 74 939 124 0 73 1041 3 0 75 1041 3 0 74 1075 1 0 76 1075 1 0 75 1109 1 0 77 1109 1 0 76 1279 60 0 78 1279 60 0 77 1313 7 0 79 1313 7 0 78 1347 39 0 80 1347 39 0 79 1381 3 0 81 1381 3 0 80 1449 14 0 82 1449 14 0 81 1483 63 0 83 1483 63 0 82 1517 53 0 84 1517 53 0 83 1551 6 0 85 1551 6 0 84 1585 1 0 86 1585 1 0 85 1619 6 0 87 1619 6 0 86 1653 40 0 88 1653 40 0 87 1687 11 0 89 1687 11 0 88 1721 8 0 90 1721 8 0 89 1755 4 0 91 1755 4 0 90 1789 52 0 92 1789 52 0 91 1823 888 0 93 1823 888 0 92 1857 1 0 94 1857 1 0 93 1925 2 0 95 1925 2 0 94 1959 32 0 96 1959 32 0 95 2027 22 0 97 2027 22 0 96 2061 9 0 98 2061 9 0 97 2469 799 0 99 2469 799 0 98 2537 861 0 100 2537 861 0 99 2639 1 0 101 2639 1 0 100 2707 70 0 102 2707 70 0 101 2775 4 0 103 2775 4 0 102 2877 84 0 104 2877 84 0 103 293 1 0 105 293 1 0 104 735 8 0 106 735 8 0 105 107 106 4. *Scan objects* 108 4. *Scan objects* 107 109 108 The expected input format:: 110 The expected input format:: 109 111 110 <cgroup inode id> <numa id> <number of obj 112 <cgroup inode id> <numa id> <number of objects to scan> 111 113 112 For a non-memcg-aware shrinker or on a syste 114 For a non-memcg-aware shrinker or on a system with no memory 113 cgrups **0** should be passed as cgroup id. 115 cgrups **0** should be passed as cgroup id. 114 :: 116 :: 115 117 116 $ cd /sys/kernel/debug/shrinker/ 118 $ cd /sys/kernel/debug/shrinker/ 117 $ cd sb-btrfs\:vda2-24/ 119 $ cd sb-btrfs\:vda2-24/ 118 120 119 $ cat count | head -n 5 121 $ cat count | head -n 5 120 1 212 0 122 1 212 0 121 21 97 0 123 21 97 0 122 55 802 5 124 55 802 5 123 2367 2 0 125 2367 2 0 124 225 13 0 126 225 13 0 125 127 126 $ echo "55 0 200" > scan 128 $ echo "55 0 200" > scan 127 129 128 $ cat count | head -n 5 130 $ cat count | head -n 5 129 1 212 0 131 1 212 0 130 21 96 0 132 21 96 0 131 55 752 5 133 55 752 5 132 2367 2 0 134 2367 2 0 133 225 13 0 135 225 13 0
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.