Skip to content

Commit

Permalink
tools/cgroup/slabinfo.py: updated to work on current kernel
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Vasily Averin <[email protected]>
Tested-by: Roman Gushchin <[email protected]>
Acked-by: Roman Gushchin <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
vaverin authored and torvalds committed Apr 23, 2021
1 parent ed98b01 commit 1974c45
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/cgroup/memcg_slabinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def detect_kernel_config():

cfg['nr_nodes'] = prog['nr_online_nodes'].value_()

if prog.type('struct kmem_cache').members[1][1] == 'flags':
if prog.type('struct kmem_cache').members[1].name == 'flags':
cfg['allocator'] = 'SLUB'
elif prog.type('struct kmem_cache').members[1][1] == 'batchcount':
elif prog.type('struct kmem_cache').members[1].name == 'batchcount':
cfg['allocator'] = 'SLAB'
else:
err('Can\'t determine the slab allocator')
Expand Down Expand Up @@ -193,7 +193,7 @@ def main():
# look over all slab pages, belonging to non-root memcgs
# and look for objects belonging to the given memory cgroup
for page in for_each_slab_page(prog):
objcg_vec_raw = page.obj_cgroups.value_()
objcg_vec_raw = page.memcg_data.value_()
if objcg_vec_raw == 0:
continue
cache = page.slab_cache
Expand All @@ -202,7 +202,7 @@ def main():
addr = cache.value_()
caches[addr] = cache
# clear the lowest bit to get the true obj_cgroups
objcg_vec = Object(prog, page.obj_cgroups.type_,
objcg_vec = Object(prog, 'struct obj_cgroup **',
value=objcg_vec_raw & ~1)

if addr not in stats:
Expand Down

0 comments on commit 1974c45

Please sign in to comment.