linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Roman Gushchin <guro@fb.com>
Cc: Vasily Averin <vvs@virtuozzo.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux MM <linux-mm@kvack.org>, Vlastimil Babka <vbabka@suse.cz>
Subject: Re: tools/cgroup/memcg_slabinfo.py is broken
Date: Wed, 16 Feb 2022 21:12:01 +0000	[thread overview]
Message-ID: <Yg1ooYmX54j8l+Fz@casper.infradead.org> (raw)
In-Reply-To: <Yg1kFH3umdrvOhu1@carbon.dhcp.thefacebook.com>

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.


  parent reply	other threads:[~2022-02-16 21:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 13:22 tools/cgroup/memcg_slabinfo.py is broken Vasily Averin
2022-02-15 23:29 ` Roman Gushchin
     [not found]   ` <35486a00-791c-3b1b-14e0-476e6242709b@virtuozzo.com>
     [not found]     ` <Yg1kFH3umdrvOhu1@carbon.dhcp.thefacebook.com>
2022-02-16 21:12       ` Matthew Wilcox [this message]
2022-02-16 21:44         ` Roman Gushchin
     [not found]           ` <Yg1y0ax5bnjGLAqz@casper.infradead.org>
     [not found]             ` <Yg16ClVQj8SLSlqV@carbon.DHCP.thefacebook.com>
2022-02-16 23:12               ` Matthew Wilcox
2022-02-16 23:57                 ` Shakeel Butt
2022-02-17  0:13                   ` Matthew Wilcox
2022-02-17  0:25                     ` Roman Gushchin
     [not found]                     ` <Yg2cKKnIboNu7j+p@carbon.DHCP.thefacebook.com>
     [not found]                       ` <11060a75-98c2-f547-68eb-fcab404a2539@virtuozzo.com>
2022-02-21  9:19                         ` Vlastimil Babka
2022-02-21 13:27                       ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yg1ooYmX54j8l+Fz@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=guro@fb.com \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    --cc=vvs@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).