]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: memcontrol: use obj_cgroup APIs to charge the LRU pages
authorMuchun Song <songmuchun@bytedance.com>
Tue, 21 Jun 2022 12:56:56 +0000 (20:56 +0800)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 20 Jul 2022 00:15:11 +0000 (20:15 -0400)
commit0f6ab2c233c9169d7818c5596ef3d635535fe93c
tree4047a3983460a38b46f15a1817d596c14a3eac73
parentfd14afa36ccd4c55b35e30d25ad51e83c2bf7421
mm: memcontrol: use obj_cgroup APIs to charge the LRU pages

We will reuse the obj_cgroup APIs to charge the LRU pages.  Finally,
page->memcg_data will have 2 different meanings.

  - For the slab pages, page->memcg_data points to an object cgroups
    vector.

  - For the kmem pages (exclude the slab pages) and the LRU pages,
    page->memcg_data points to an object cgroup.

In this patch, we reuse obj_cgroup APIs to charge LRU pages.  In the end,
The page cache cannot prevent long-living objects from pinning the
original memory cgroup in the memory.

At the same time we also changed the rules of page and objcg or memcg
binding stability.  The new rules are as follows.

For a page any of the following ensures page and objcg binding stability:

  - the page lock
  - LRU isolation
  - lock_page_memcg()
  - exclusive reference

Based on the stable binding of page and objcg, for a page any of the
following ensures page and memcg binding stability:

  - objcg_lock
  - cgroup_mutex
  - the lruvec lock
  - the split queue lock (only THP page)

If the caller only want to ensure that the page counters of memcg are
updated correctly, ensure that the binding stability of page and objcg is
sufficient.

Link: https://lkml.kernel.org/r/20220621125658.64935-10-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Xiongchun Duan <duanxiongchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/memcontrol.h
mm/huge_memory.c
mm/memcontrol.c