Re: [PATCH v2 27/28] tools/cgroup: make slabinfo.py compatible with new slab controller

From: Roman Gushchin
Date: Wed Jan 29 2020 - 21:44:44 EST


On Thu, Jan 30, 2020 at 07:47:29AM +0530, Bharata B Rao wrote:
> On Mon, Jan 27, 2020 at 09:34:52AM -0800, Roman Gushchin wrote:
> > Make slabinfo.py compatible with the new slab controller.
>
> Tried using slabinfo.py, but run into some errors. (I am using your
> new_slab.2 branch)
>
> ./tools/cgroup/slabinfo.py /sys/fs/cgroup/memory/1
> Traceback (most recent call last):
> File "/usr/local/bin/drgn", line 11, in <module>
> sys.exit(main())
> File "/usr/local/lib/python3.6/dist-packages/drgn/internal/cli.py", line 127, in main
> runpy.run_path(args.script[0], init_globals=init_globals, run_name="__main__")
> File "/usr/lib/python3.6/runpy.py", line 263, in run_path
> pkg_name=pkg_name, script_name=fname)
> File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
> mod_name, mod_spec, pkg_name, script_name)
> File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
> exec(code, run_globals)
> File "./tools/cgroup/slabinfo.py", line 220, in <module>
> main()
> File "./tools/cgroup/slabinfo.py", line 165, in main
> find_memcg_ids()
> File "./tools/cgroup/slabinfo.py", line 43, in find_memcg_ids
> MEMCGS[css.cgroup.kn.id.ino.value_()] = memcg
> AttributeError: '_drgn.Object' object has no attribute 'ino'
>
> I did make this change...
>
> # git diff
> diff --git a/tools/cgroup/slabinfo.py b/tools/cgroup/slabinfo.py
> index b779a4863beb..571fd95224d6 100755
> --- a/tools/cgroup/slabinfo.py
> +++ b/tools/cgroup/slabinfo.py
> @@ -40,7 +40,7 @@ def find_memcg_ids(css=prog['root_mem_cgroup'].css, prefix=''):
> 'sibling'):
> name = prefix + '/' + css.cgroup.kn.name.string_().decode('utf-8')
> memcg = container_of(css, 'struct mem_cgroup', 'css')
> - MEMCGS[css.cgroup.kn.id.ino.value_()] = memcg
> + MEMCGS[css.cgroup.kn.id.value_()] = memcg
> find_memcg_ids(css, name)
>
>
> but now get empty output.
>
> # ./tools/cgroup/slabinfo.py /sys/fs/cgroup/memory/1
> # name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
>
> Guess this script is not yet ready for the upstream kernel?

Yes, looks like I've used a slightly outdated kernel version to test it.
I'll fix it in the next version.

Thank you for reporting it!