All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/cgroup/slabinfo.py: updated to work on current kernel
@ 2021-04-22  5:29 Vasily Averin
  2021-04-23  0:52 ` Roman Gushchin
  0 siblings, 1 reply; 2+ messages in thread
From: Vasily Averin @ 2021-04-22  5:29 UTC (permalink / raw)
  To: Andrew Morton, Roman Gushchin, linux-kernel; +Cc: Michal Hocko

slabinfo.py script does not work with actual kernel version.
First, it was unable to recognise SLUB susbsytem,
when I specified it manually, it was 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'

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 tools/cgroup/memcg_slabinfo.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/cgroup/memcg_slabinfo.py b/tools/cgroup/memcg_slabinfo.py
index c4225ed..1600b17 100644
--- a/tools/cgroup/memcg_slabinfo.py
+++ b/tools/cgroup/memcg_slabinfo.py
@@ -128,9 +128,9 @@ OO_MASK = ((1 << OO_SHIFT) - 1)
 
     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')
@@ -193,7 +193,7 @@ OO_MASK = ((1 << OO_SHIFT) - 1)
         # 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
@@ -202,7 +202,7 @@ OO_MASK = ((1 << OO_SHIFT) - 1)
             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:
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/cgroup/slabinfo.py: updated to work on current kernel
  2021-04-22  5:29 [PATCH] tools/cgroup/slabinfo.py: updated to work on current kernel Vasily Averin
@ 2021-04-23  0:52 ` Roman Gushchin
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Gushchin @ 2021-04-23  0:52 UTC (permalink / raw)
  To: Vasily Averin; +Cc: Andrew Morton, linux-kernel, Michal Hocko

On Thu, Apr 22, 2021 at 08:29:31AM +0300, Vasily Averin wrote:
> slabinfo.py script does not work with actual kernel version.
> First, it was unable to recognise SLUB susbsytem,
> when I specified it manually, it was 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'
> 
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>

Indeed, we forgot to update it after recent changes in page->memcg_data.
Thank you, Vasily, for updating it!

I tested it, and it works great for me. Please, feel free to add
Tested-by: Roman Gushchin <guro@fb.com>
Acked-by: Roman Gushchin <guro@fb.com>

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-23  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22  5:29 [PATCH] tools/cgroup/slabinfo.py: updated to work on current kernel Vasily Averin
2021-04-23  0:52 ` Roman Gushchin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.