From: Michal Hocko <mhocko@suse.com>
To: Roman Gushchin <guro@fb.com>
Cc: Hui Su <sh_def@163.com>,
hannes@cmpxchg.org, vdavydov.dev@gmail.com,
akpm@linux-foundation.org, shakeelb@google.com,
laoar.shao@gmail.com, chris@chrisdown.name,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm/memcontrol:rewrite mem_cgroup_page_lruvec()
Date: Thu, 5 Nov 2020 08:26:52 +0100 [thread overview]
Message-ID: <20201105072652.GA21348@dhcp22.suse.cz> (raw)
In-Reply-To: <20201104223800.GD1938922@carbon.dhcp.thefacebook.com>
On Wed 04-11-20 14:38:00, Roman Gushchin wrote:
> On Wed, Nov 04, 2020 at 10:25:16PM +0800, Hui Su wrote:
> > mem_cgroup_page_lruvec() in memcontrol.c and
> > mem_cgroup_lruvec() in memcontrol.h is very similar
> > except for the param(page and memcg) which also can be
> > convert to each other.
> >
> > So rewrite mem_cgroup_page_lruvec() with mem_cgroup_lruvec().
> >
> > Signed-off-by: Hui Su <sh_def@163.com>
> > ---
> > include/linux/memcontrol.h | 18 +++++++++++++++--
> > mm/memcontrol.c | 40 --------------------------------------
> > 2 files changed, 16 insertions(+), 42 deletions(-)
> >
> > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> > index e391e3c56de5..a586363fb766 100644
> > --- a/include/linux/memcontrol.h
> > +++ b/include/linux/memcontrol.h
> > @@ -457,9 +457,10 @@ mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid)
> > /**
> > * mem_cgroup_lruvec - get the lru list vector for a memcg & node
> > * @memcg: memcg of the wanted lruvec
> > + * @pgdat: pglist_data
> > *
> > * Returns the lru list vector holding pages for a given @memcg &
> > - * @node combination. This can be the node lruvec, if the memory
> > + * @pgdat combination. This can be the node lruvec, if the memory
> > * controller is disabled.
> > */
> > static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
> > @@ -489,7 +490,20 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
> > return lruvec;
> > }
>
> Hi Hui,
>
> >
> > -struct lruvec *mem_cgroup_page_lruvec(struct page *, struct pglist_data *);
> > +/**
> > + * mem_cgroup_page_lruvec - return lruvec for isolating/putting an LRU page
> > + * @page: the page
> > + * @pgdat: pgdat of the page
> > + *
> > + * This function relies on page->mem_cgroup being stable.
> > + */
> > +static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page,
> > + struct pglist_data *pgdat)
>
> Hm, do we need to pass page and pgdat?
Not really because page already knows its node so pgdat can be easily
taken from there. I suspect the only reason for having pgdat here is
that many callers already know it and we optimize for memcg disable
case. Hard to tell whether this actually matters because most of those
paths are not really hot but something that would require a deeper
investigation. Hint hint...
Anyway, this looks like a nice simplification already. There were some
attempts to do similar thing recently but they were adding nodeid as an
additional argument and I really disliked those.
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2020-11-05 7:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-04 14:25 Hui Su
[not found] ` <20201104223800.GD1938922@carbon.dhcp.thefacebook.com>
2020-11-05 7:26 ` Michal Hocko [this message]
2020-11-05 15:53 ` Johannes Weiner
2020-11-06 16:44 ` Shakeel Butt
2020-11-07 1:30 ` Andrew Morton
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=20201105072652.GA21348@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chris@chrisdown.name \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sh_def@163.com \
--cc=shakeelb@google.com \
--cc=vdavydov.dev@gmail.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