linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, Johannes Weiner <hannes@cmpxchg.org>,
	 Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	 Muchun Song <muchun.song@linux.dev>, Zi Yan <ziy@nvidia.com>,
	David Hildenbrand <david@redhat.com>
Subject: Re: memcg_data and the page/folio/slab split
Date: Thu, 13 Mar 2025 10:06:38 -0700	[thread overview]
Message-ID: <5e6rtjxoo56cgqhbhs7hvfjfz5cpv7qebsjr7gulxdfvhknhub@z6wvj2gxggbt> (raw)
In-Reply-To: <Z9LwTOudOlCGny3f@casper.infradead.org>

On Thu, Mar 13, 2025 at 02:48:44PM +0000, Matthew Wilcox wrote:
> I started working on 'struct acctmem' as hinted at in
> https://kernelnewbies.org/MatthewWilcox/Memdescs
> 
> However, as I did so, I became aware of two things.  First, we don't
> need acctmem until (unless?) we remove page->flags, which is not
> on the cards for 2025.  Second, we actually have distinct things stored
> in memcg_data and those things line up perfectly with page/slab/folio.
> 
> That is, alloc_page(GFP_ACCOUNT) always stores an obj_cgroup pointer there
> (with the KMEM flag set).  Slab always stores an slabobj_ext pointer (with
> the OBJEXTS flag set) and folios always store a mem_cgroup pointer there.
> Maybe that's obvious to those who work on memcg, but I didn't know that;
> I just saw code that could handle all three kinds of accounting.

To be fair I often get confused on page vs folio distinction which your
new following plan and the series will make much more clear.

> 
> So, new plan.  For 2025, we have struct slab directly pointing
> to slabobj_ext (with no flag, because we know anything that is a
> slab has this pointer).  struct folio directly points to mem_cgroup.
> And alloc_page(GFP_ACCOUNT) uses page->memdesc with a type in the bottom
> four bits to say that this is a pointer to an obj_cgroup.
> 
> Obviously we don't have a page->memdesc yet, so we'll keep storing
> pointers in page->memcg_data until we're ready to switch over.  But I
> do have a few patches to separate out GFP_ACCOUNT allocations from
> folio allocations that I think are worth merging now, and I'll send
> those imminently (think of this as a [-1/n] email).  We can't get
> rid of all the "handle any kind of accounting" code today because we
> lose information about whether this memory is a file/anon folio vs a
> GFP_ACCOUNT allocation in the freeing path.  That's a today problem that
> will get solved, but not in this patchset.
> 
> 

Thanks a lot of this awesome work.


      reply	other threads:[~2025-03-13 17:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 14:48 Matthew Wilcox
2025-03-13 17:06 ` Shakeel Butt [this message]

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=5e6rtjxoo56cgqhbhs7hvfjfz5cpv7qebsjr7gulxdfvhknhub@z6wvj2gxggbt \
    --to=shakeel.butt@linux.dev \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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