linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeelb@google.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Yosry Ahmed <yosryahmed@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	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 12:41:57 -0800	[thread overview]
Message-ID: <CALvZod7bGiQvEGjiDcKeFFDhdTkAr18rK+20orLX+vCkK4WUUA@mail.gmail.com> (raw)
In-Reply-To: <ZXoTmwIiBoeLItlg@casper.infradead.org>

On Wed, Dec 13, 2023 at 12:27 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Wed, Dec 13, 2023 at 08:23:25PM +0000, Shakeel Butt wrote:
> > On Wed, Dec 13, 2023 at 08:31:00AM -0800, Yosry Ahmed wrote:
> > > On Wed, Dec 13, 2023 at 8:27 AM Matthew Wilcox <willy@infradead.org> wrote:
> > > >
> > > > On Wed, Dec 13, 2023 at 08:24:04AM -0800, Yosry Ahmed wrote:
> > > > > I doubt an extra compound_head() will matter in that path, but if you
> > > > > feel strongly about it that's okay. It's a nice cleanup that's all.
> > > >
> > > > i don't even understand why you think it's a nice cleanup.
> > >
> > > free_pages_prepare() is directly calling __memcg_kmem_uncharge_page()
> > > instead of memcg_kmem_uncharge_page(), and open-coding checks that
> > > already exist in both of them to avoid the unnecessary function call
> > > if possible. I think this should be the job of
> > > memcg_kmem_uncharge_page(), but it's currently missing the
> > > PageMemcgKmem() check (which is in __memcg_kmem_uncharge_page()).
> > >
> > > So I think moving that check to the wrapper allows
> > > free_pages_prepare() to call memcg_kmem_uncharge_page() and without
> > > worrying about those memcg-specific checks.
> >
> > There is a (performance) reason these open coded check are present in
> > page_alloc.c and that is very clear for __memcg_kmem_charge_page() but
> > not so much for __memcg_kmem_uncharge_page(). So, for uncharge path,
> > this seems ok. Now to resolve Willy's concern for the fork() path, I
> > think we can open code the checks there.
> >
> > Willy, any concern with that approach?
>
> The justification for this change is insufficient.  Or really any change
> in this area.  It's fine the way it is.  "The check is done twice" is
> really weak, when the check is so cheap (much cheaper than calling
> compound_head!)

I think that is what Yosry is trying i.e. reducing two calls to
page_folio() to one in the page free path.


  reply	other threads:[~2023-12-13 20:42 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
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 [this message]
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=CALvZod7bGiQvEGjiDcKeFFDhdTkAr18rK+20orLX+vCkK4WUUA@mail.gmail.com \
    --to=shakeelb@google.com \
    --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=willy@infradead.org \
    --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