From: Roman Gushchin <guro@fb.com>
To: Muchun Song <songmuchun@bytedance.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Shakeel Butt <shakeelb@google.com>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Xiongchun duan <duanxiongchun@bytedance.com>,
<fam.zheng@bytedance.com>,
"Singh, Balbir" <bsingharora@gmail.com>,
Yang Shi <shy828301@gmail.com>, Alex Shi <alexs@kernel.org>,
Muchun Song <smuchun@gmail.com>,
Qi Zheng <zhengqi.arch@bytedance.com>
Subject: Re: [PATCH v2 00/13] Use obj_cgroup APIs to charge the LRU pages
Date: Fri, 17 Sep 2021 17:13:46 -0700 [thread overview]
Message-ID: <YUUvOhX4Yk2xuGTu@carbon.dhcp.thefacebook.com> (raw)
In-Reply-To: <CAMZfGtU42K0O+_KuuQ2untdYTiQet=W8K0m4+eh1CosJ96QL1Q@mail.gmail.com>
On Fri, Sep 17, 2021 at 06:49:21PM +0800, Muchun Song wrote:
> On Fri, Sep 17, 2021 at 9:29 AM Roman Gushchin <guro@fb.com> wrote:
> >
> > Hi Muchun!
> >
> > On Thu, Sep 16, 2021 at 09:47:35PM +0800, Muchun Song wrote:
> > > This version is rebased over linux 5.15-rc1, because Shakeel has asked me
> > > if I could do that. I rework some code suggested by Roman as well in this
> > > version. I have not removed the Acked-by tags which are from Roman, because
> > > this version is not based on the folio relevant. If Roman wants me to
> > > do this, please let me know, thanks.
> >
> > I'm fine with this, thanks for clarifying.
> >
> > >
> > > Since the following patchsets applied. All the kernel memory are charged
> > > with the new APIs of obj_cgroup.
> > >
> > > [v17,00/19] The new cgroup slab memory controller[1]
> > > [v5,0/7] Use obj_cgroup APIs to charge kmem pages[2]
> > >
> > > But user memory allocations (LRU pages) pinning memcgs for a long time -
> > > it exists at a larger scale and is causing recurring problems in the real
> > > world: page cache doesn't get reclaimed for a long time, or is used by the
> > > second, third, fourth, ... instance of the same job that was restarted into
> > > a new cgroup every time. Unreclaimable dying cgroups pile up, waste memory,
> > > and make page reclaim very inefficient.
> >
> > I've an idea: what if we use struct list_lru_memcg as an intermediate object
> > between an individual page and struct mem_cgroup?
> >
> > It could contain a pointer to a memory cgroup structure (not even sure if a
> > reference is needed), and a lru page can contain a pointer to the lruvec instead
> > of memcg/objcg.
lruvec_memcg I mean.
>
> Hi Roman,
>
> If I understand properly, here you mean the struct page has a pointer
> to the struct lruvec not struct list_lru_memcg. What's the functionality
> of the struct list_lru_memcg? Would you mind exposing more details?
So the basic idea is simple: a lru page charged to a memcg is associated with
a per-memcg lruvec (list_lru_memcg), which is associated with a memory cgroup.
And after your patches there is a second link of associations: page to objcg
to memcg:
1) page->objcg->memcg
2) page->list_lru_memcg->memcg
(those are not necessarily direct pointers, but generally speaking, relations).
My gut feeling is that if we can merge them into just 2) and use list_lru_memcg
as an intermediate object between pages and memory cgroups, the whole thing can
be more efficient and beautiful.
Yes, on reparenting we'd need to scan over all pages in the lru list, but
hopefully we can do it from a worker context. And it's not such a big deal as
with slab objects, where we simple had no list of all objects.
Again, I'm not 100% sure if it's possible and worth it, so it shouldn't block
your patchset if everybody else like it.
Thanks
next prev parent reply other threads:[~2021-09-18 0:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 13:47 Muchun Song
2021-09-16 13:47 ` [PATCH v2 01/13] mm: move mem_cgroup_kmem_disabled() to memcontrol.h Muchun Song
2021-09-16 13:47 ` [PATCH v2 02/13] mm: memcontrol: prepare objcg API for non-kmem usage Muchun Song
2021-09-17 17:40 ` kernel test robot
2021-09-16 13:47 ` [PATCH v2 03/13] mm: memcontrol: introduce compact_lock_page_irqsave Muchun Song
2021-09-16 13:47 ` [PATCH v2 04/13] mm: memcontrol: make lruvec lock safe when the LRU pages reparented Muchun Song
2021-09-16 13:47 ` [PATCH v2 05/13] mm: vmscan: rework move_pages_to_lru() Muchun Song
2021-09-16 13:47 ` [PATCH v2 06/13] mm: thp: introduce split_queue_lock/unlock{_irqsave}() Muchun Song
2021-09-17 2:43 ` kernel test robot
2021-09-17 17:07 ` kernel test robot
2021-09-16 13:47 ` [PATCH v2 07/13] mm: thp: make split queue lock safe when LRU pages reparented Muchun Song
2021-09-17 6:38 ` kernel test robot
2021-09-16 13:47 ` [PATCH v2 08/13] mm: memcontrol: make all the callers of page_memcg() safe Muchun Song
2021-09-16 13:47 ` [PATCH v2 09/13] mm: memcontrol: introduce memcg_reparent_ops Muchun Song
2021-09-16 13:47 ` [PATCH v2 10/13] mm: memcontrol: use obj_cgroup APIs to charge the LRU pages Muchun Song
2021-09-17 16:31 ` kernel test robot
2021-09-16 13:47 ` [PATCH v2 11/13] mm: memcontrol: rename {un}lock_page_memcg() to {un}lock_page_objcg() Muchun Song
2021-09-16 13:47 ` [PATCH v2 12/13] mm: lru: add VM_BUG_ON_PAGE to lru maintenance function Muchun Song
2021-09-16 13:47 ` [PATCH v2 13/13] mm: lru: use lruvec lock to serialize memcg changes Muchun Song
2021-09-17 1:28 ` [PATCH v2 00/13] Use obj_cgroup APIs to charge the LRU pages Roman Gushchin
2021-09-17 10:49 ` Muchun Song
2021-09-18 0:13 ` Roman Gushchin [this message]
2021-09-18 7:55 ` Muchun Song
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=YUUvOhX4Yk2xuGTu@carbon.dhcp.thefacebook.com \
--to=guro@fb.com \
--cc=akpm@linux-foundation.org \
--cc=alexs@kernel.org \
--cc=bsingharora@gmail.com \
--cc=duanxiongchun@bytedance.com \
--cc=fam.zheng@bytedance.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=shakeelb@google.com \
--cc=shy828301@gmail.com \
--cc=smuchun@gmail.com \
--cc=songmuchun@bytedance.com \
--cc=vdavydov.dev@gmail.com \
--cc=zhengqi.arch@bytedance.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