From: Matthew Wilcox <willy@infradead.org>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <muchun.song@linux.dev>,
cgroups@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: memcg: remove direct use of __memcg_kmem_uncharge_page
Date: Wed, 13 Dec 2023 15:38:49 +0000 [thread overview]
Message-ID: <ZXnQCaficsZC2bN4@casper.infradead.org> (raw)
In-Reply-To: <CAJD7tkbuyyGNjhLcZfzBYBX+BSUCvBbMpUPyzgHcRPTM4jL9Gg@mail.gmail.com>
On Wed, Dec 13, 2023 at 07:08:52AM -0800, Yosry Ahmed wrote:
> On Wed, Dec 13, 2023 at 7:01 AM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Wed, Dec 13, 2023 at 01:04:14PM +0000, Yosry Ahmed wrote:
> > > memcg_kmem_uncharge_page() is an inline wrapper around
> > > __memcg_kmem_uncharge_page() that checks memcg_kmem_online() before
> > > making the function call. Internally, __memcg_kmem_uncharge_page() has a
> > > folio_memcg_kmem() check.
> > >
> > > The only direct user of __memcg_kmem_uncharge_page(),
> > > free_pages_prepare(), checks PageMemcgKmem() before calling it to avoid
> > > the function call if possible. Move the folio_memcg_kmem() check from
> > > __memcg_kmem_uncharge_page() to memcg_kmem_uncharge_page() as
> > > PageMemcgKmem() -- which does the same thing under the hood. Now
> > > free_pages_prepare() can also use memcg_kmem_uncharge_page().
> >
> > I think you've just pessimised all the other places which call
> > memcg_kmem_uncharge_page(). It's a matter of probabilities. In
> > free_pages_prepare(), most of the pages being freed are not accounted
> > to memcg. Whereas in fork() we are absolutely certain that the pages
> > were accounted because we accounted them.
>
> The check was already there for other callers, but it was inside
> __memcg_kmem_uncharge_page(). IIUC, the only change for other callers
> is an extra call to compound_head(), and they are not hot paths AFAICT
> so it shouldn't be noticeable.
How can you seriously claim that fork() is not a hot path?
> Am I missing something? Perhaps your point is about how branch
> prediction works across function call boundaries? or is this not about
> performance at all?
>
> >
> > I think this is a bad change.
next prev parent reply other threads:[~2023-12-13 15:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 13:04 Yosry Ahmed
2023-12-13 14:26 ` Muchun Song
2023-12-13 15:01 ` Matthew Wilcox
2023-12-13 15:08 ` Yosry Ahmed
2023-12-13 15:38 ` Matthew Wilcox [this message]
2023-12-13 15:42 ` Yosry Ahmed
2023-12-13 16:23 ` Matthew Wilcox
2023-12-13 16:24 ` Yosry Ahmed
2023-12-13 16:27 ` Matthew Wilcox
2023-12-13 16:31 ` Yosry Ahmed
2023-12-13 20:23 ` Shakeel Butt
2023-12-13 20:27 ` Matthew Wilcox
2023-12-13 20:41 ` Shakeel Butt
2023-12-13 20:58 ` Shakeel Butt
2023-12-13 22:04 ` Yosry Ahmed
2023-12-13 22:12 ` Shakeel Butt
2023-12-13 22:15 ` Yosry Ahmed
2023-12-14 1:46 ` Roman Gushchin
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=ZXnQCaficsZC2bN4@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=yosryahmed@google.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