From: Roman Gushchin <guro@fb.com>
To: Muchun Song <songmuchun@bytedance.com>
Cc: <hannes@cmpxchg.org>, <mhocko@kernel.org>,
<akpm@linux-foundation.org>, <shakeelb@google.com>,
<vdavydov.dev@gmail.com>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <duanxiongchun@bytedance.com>,
<fam.zheng@bytedance.com>, <bsingharora@gmail.com>,
<shy828301@gmail.com>, <alexs@kernel.org>, <smuchun@gmail.com>,
<zhengqi.arch@bytedance.com>
Subject: Re: [PATCH v2 00/13] Use obj_cgroup APIs to charge the LRU pages
Date: Thu, 16 Sep 2021 18:28:53 -0700 [thread overview]
Message-ID: <YUPvVYFyBR/qwy2X@carbon.DHCP.thefacebook.com> (raw)
In-Reply-To: <20210916134748.67712-1-songmuchun@bytedance.com>
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.
This approach can probably simplify the locking scheme. But what's more
important, it can dramatically reduce the number of css_get()/put() calls.
The latter are not particularly cheap after the deletion of a cgroup:
they are atomic_dec()'s. As a result, the reclaim efficiency could be much
better. The downside: we will need to update page->lruvec_memcg pointers on
reparenting pages during the cgroup removal.
This is a rough idea, maybe there are significant reasons why it's not possible
or will be way worse. But I think it's worth discussing. What do you think?
Thanks!
next prev parent reply other threads:[~2021-09-17 1:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 13:47 [PATCH v2 00/13] Use obj_cgroup APIs to charge the LRU pages 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 ` Roman Gushchin [this message]
2021-09-17 10:49 ` [PATCH v2 00/13] Use obj_cgroup APIs to charge the LRU pages Muchun Song
2021-09-18 0:13 ` Roman Gushchin
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=YUPvVYFyBR/qwy2X@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;
as well as URLs for NNTP newsgroup(s).