]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: memcontrol: prepare objcg API for non-kmem usage
authorMuchun Song <songmuchun@bytedance.com>
Tue, 21 Jun 2022 12:56:50 +0000 (20:56 +0800)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 20 Jul 2022 00:15:10 +0000 (20:15 -0400)
commit88f261c8a9730faf5085c0d1338b3c4ee2ccce48
tree9b004546dc6e9f4aa4f69dfe3eb797feb96d1a76
parent4377c54b57824611d5b9119bfe75fed45f09ba04
mm: memcontrol: prepare objcg API for non-kmem usage

Pagecache pages are charged at the allocation time and holding a reference
to the original memory cgroup until being reclaimed.  Depending on the
memory pressure, specific patterns of the page sharing between different
cgroups and the cgroup creation and destruction rates, a large number of
dying memory cgroups can be pinned by pagecache pages.  It makes the page
reclaim less efficient and wastes memory.

We can convert LRU pages and most other raw memcg pins to the objcg
direction to fix this problem, and then the page->memcg will always point
to an object cgroup pointer.

Therefore, the infrastructure of objcg no longer only serves
CONFIG_MEMCG_KMEM.  In this patch, we move the infrastructure of the objcg
out of the scope of the CONFIG_MEMCG_KMEM so that the LRU pages can reuse
it to charge pages.

We know that the LRU pages are not accounted at the root level.  But the
page->memcg_data points to the root_mem_cgroup.  So the page->memcg_data
of the LRU pages always points to a valid pointer.  But the
root_mem_cgroup dose not have an object cgroup.  If we use obj_cgroup APIs
to charge the LRU pages, we should set the page->memcg_data to a root
object cgroup.  So we also allocate an object cgroup for the
root_mem_cgroup.

Link: https://lkml.kernel.org/r/20220621125658.64935-4-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
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/memcontrol.c