Roman Gushchin
221944736f
tools/cgroup/slabinfo: update to work with struct slab
...
After the introduction of the dedicated struct slab to describe slab
pages by commit d122019bf0
("mm: Split slab into its own type") and
the following removal of the corresponding struct page's fields by
commit 07f910f9b7
("mm: Remove slab from struct page") the
memcg_slabinfo tool broke. An attempt to run it produces a trace like
this:
Traceback (most recent call last):
File "/usr/bin/drgn", line 33, in <module>
sys.exit(load_entry_point('drgn==0.0.16', 'console_scripts', 'drgn')())
File "/usr/lib64/python3.9/site-packages/drgn/internal/cli.py", line 133, in main
runpy.run_path(args.script[0], init_globals=init_globals, run_name="__main__")
File "/usr/lib64/python3.9/runpy.py", line 268, in run_path
return _run_module_code(code, init_globals, run_name,
File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "memcg_slabinfo.py", line 226, in <module>
main()
File "memcg_slabinfo.py", line 199, in main
cache = page.slab_cache
AttributeError: 'struct page' has no member 'slab_cache'
The problem can be fixed by explicitly casting struct page * to struct
slab * for slab pages. The tools works as expected with this fix, e.g.:
cred_jar 776 776 192 21 1 : tunables 0 0 0 : slabdata 547 547 0
kmalloc-cg-32 6 6 32 128 1 : tunables 0 0 0 : slabdata 9 9 0
files_cache 3 3 832 39 8 : tunables 0 0 0 : slabdata 8 8 0
kmalloc-cg-512 1 1 512 32 4 : tunables 0 0 0 : slabdata 10 10 0
task_struct 10 10 6720 4 8 : tunables 0 0 0 : slabdata 63 63 0
mm_struct 3 3 1664 19 8 : tunables 0 0 0 : slabdata 9 9 0
kmalloc-cg-16 1 1 16 256 1 : tunables 0 0 0 : slabdata 8 8 0
pde_opener 1 1 40 102 1 : tunables 0 0 0 : slabdata 8 8 0
anon_vma_chain 375 375 64 64 1 : tunables 0 0 0 : slabdata 81 81 0
radix_tree_node 3 3 584 28 4 : tunables 0 0 0 : slabdata 419 419 0
dentry 98 98 312 26 2 : tunables 0 0 0 : slabdata 1420 1420 0
btrfs_inode 3 3 2368 13 8 : tunables 0 0 0 : slabdata 730 730 0
signal_cache 3 3 1600 20 8 : tunables 0 0 0 : slabdata 17 17 0
sighand_cache 3 3 2240 14 8 : tunables 0 0 0 : slabdata 20 20 0
filp 90 90 512 32 4 : tunables 0 0 0 : slabdata 95 95 0
anon_vma 214 214 200 20 1 : tunables 0 0 0 : slabdata 162 162 0
kmalloc-cg-1k 1 1 1024 32 8 : tunables 0 0 0 : slabdata 22 22 0
pid 10 10 256 32 2 : tunables 0 0 0 : slabdata 14 14 0
kmalloc-cg-64 2 2 64 64 1 : tunables 0 0 0 : slabdata 8 8 0
kmalloc-cg-96 3 3 96 42 1 : tunables 0 0 0 : slabdata 8 8 0
sock_inode_cache 5 5 1408 23 8 : tunables 0 0 0 : slabdata 29 29 0
UNIX 7 7 1920 17 8 : tunables 0 0 0 : slabdata 21 21 0
inode_cache 36 36 1152 28 8 : tunables 0 0 0 : slabdata 680 680 0
proc_inode_cache 26 26 1224 26 8 : tunables 0 0 0 : slabdata 64 64 0
kmalloc-cg-2k 2 2 2048 16 8 : tunables 0 0 0 : slabdata 9 9 0
v2: change naming and count_partial()/count_free()/for_each_slab()
signatures to work with slabs, suggested by Matthew Wilcox
Fixes: 07f910f9b7
("mm: Remove slab from struct page")
Reported-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Roman Gushchin <guro@fb.com>
Tested-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Link: https://lore.kernel.org/linux-patches/Yg2cKKnIboNu7j+p@carbon.DHCP.thefacebook.com/
2022-02-21 11:34:49 +01:00
Vasily Averin
1974c45dd7
tools/cgroup/slabinfo.py: updated to work on current kernel
...
slabinfo.py script does not work with actual kernel version.
First, it was unable to recognise SLUB susbsytem, and when I specified
it manually it failed again with
AttributeError: 'struct page' has no member 'obj_cgroups'
.. and then again with
File "tools/cgroup/memcg_slabinfo.py", line 221, in main
memcg.kmem_caches.address_of_(),
AttributeError: 'struct mem_cgroup' has no member 'kmem_caches'
Link: https://lkml.kernel.org/r/cec1a75e-43b4-3d64-2084-d9f98fda037f@virtuozzo.com
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Tested-by: Roman Gushchin <guro@fb.com>
Acked-by: Roman Gushchin <guro@fb.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-04-23 14:42:40 -07:00
Roman Gushchin
fbc1ac9d09
tools/cgroup: add memcg_slabinfo.py tool
...
Add a drgn-based tool to display slab information for a given memcg. Can
replace cgroup v1 memory.kmem.slabinfo interface on cgroup v2, but in a
more flexiable way.
Currently supports only SLUB configuration, but SLAB can be trivially
added later.
Output example:
$ sudo ./tools/cgroup/memcg_slabinfo.py /sys/fs/cgroup/user.slice/user-111017.slice/user\@111017.service
shmem_inode_cache 92 92 704 46 8 : tunables 0 0 0 : slabdata 2 2 0
eventpoll_pwq 56 56 72 56 1 : tunables 0 0 0 : slabdata 1 1 0
eventpoll_epi 32 32 128 32 1 : tunables 0 0 0 : slabdata 1 1 0
kmalloc-8 0 0 8 512 1 : tunables 0 0 0 : slabdata 0 0 0
kmalloc-96 0 0 96 42 1 : tunables 0 0 0 : slabdata 0 0 0
kmalloc-2048 0 0 2048 16 8 : tunables 0 0 0 : slabdata 0 0 0
kmalloc-64 128 128 64 64 1 : tunables 0 0 0 : slabdata 2 2 0
mm_struct 160 160 1024 32 8 : tunables 0 0 0 : slabdata 5 5 0
signal_cache 96 96 1024 32 8 : tunables 0 0 0 : slabdata 3 3 0
sighand_cache 45 45 2112 15 8 : tunables 0 0 0 : slabdata 3 3 0
files_cache 138 138 704 46 8 : tunables 0 0 0 : slabdata 3 3 0
task_delay_info 153 153 80 51 1 : tunables 0 0 0 : slabdata 3 3 0
task_struct 27 27 3520 9 8 : tunables 0 0 0 : slabdata 3 3 0
radix_tree_node 56 56 584 28 4 : tunables 0 0 0 : slabdata 2 2 0
btrfs_inode 140 140 1136 28 8 : tunables 0 0 0 : slabdata 5 5 0
kmalloc-1024 64 64 1024 32 8 : tunables 0 0 0 : slabdata 2 2 0
kmalloc-192 84 84 192 42 2 : tunables 0 0 0 : slabdata 2 2 0
inode_cache 54 54 600 27 4 : tunables 0 0 0 : slabdata 2 2 0
kmalloc-128 0 0 128 32 1 : tunables 0 0 0 : slabdata 0 0 0
kmalloc-512 32 32 512 32 4 : tunables 0 0 0 : slabdata 1 1 0
skbuff_head_cache 32 32 256 32 2 : tunables 0 0 0 : slabdata 1 1 0
sock_inode_cache 46 46 704 46 8 : tunables 0 0 0 : slabdata 1 1 0
cred_jar 378 378 192 42 2 : tunables 0 0 0 : slabdata 9 9 0
proc_inode_cache 96 96 672 24 4 : tunables 0 0 0 : slabdata 4 4 0
dentry 336 336 192 42 2 : tunables 0 0 0 : slabdata 8 8 0
filp 697 864 256 32 2 : tunables 0 0 0 : slabdata 27 27 0
anon_vma 644 644 88 46 1 : tunables 0 0 0 : slabdata 14 14 0
pid 1408 1408 64 64 1 : tunables 0 0 0 : slabdata 22 22 0
vm_area_struct 1200 1200 200 40 2 : tunables 0 0 0 : slabdata 30 30 0
Signed-off-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Link: http://lkml.kernel.org/r/20200623174037.3951353-20-guro@fb.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-07 11:33:25 -07:00