On Wed, Feb 16, 2022 at 12:52:36PM -0800, Roman Gushchin wrote: > 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.: This feels like a quick fix, and not really correct. > @@ -77,7 +77,8 @@ def count_partial(n, fn): > > > def count_free(page): > - return page.objects - page.inuse > + slab = cast('struct slab *', page) > + return slab.objects - slab.inuse count_free() should take a slab, not a page. > def slub_get_slabinfo(s, cfg): > @@ -193,10 +194,11 @@ 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): for_each_slab_page() should be renamed for_each_slab(). It should return a slab, not a page. And it should definitely skip over tail pages (it works today by coincidence because tail pages do not have PG_slab set). count_partial() should use struct slab, and slab_list, not lru. ... I think that's it. But I'm no pythonist, much less dragoneer.