mm: memcontrol: switch to native NR_FILE_PAGES and NR_SHMEM counters
Memcg maintains private MEMCG_CACHE and NR_SHMEM counters. This divergence from the generic VM accounting means unnecessary code overhead, and creates a dependency for memcg that page->mapping is set up at the time of charging, so that page types can be told apart. Convert the generic accounting sites to mod_lruvec_page_state and friends to maintain the per-cgroup vmstat counters of NR_FILE_PAGES and NR_SHMEM. The page is already locked in these places, so page->mem_cgroup is stable; we only need minimal tweaks of two mem_cgroup_migrate() calls to ensure it's set up in time. Then replace MEMCG_CACHE with NR_FILE_PAGES and delete the private NR_SHMEM accounting sites. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Alex Shi <alex.shi@linux.alibaba.com> Cc: Hugh Dickins <hughd@google.com> Cc: "Kirill A. Shutemov" <kirill@shutemov.name> Cc: Michal Hocko <mhocko@suse.com> Cc: Roman Gushchin <guro@fb.com> Cc: Shakeel Butt <shakeelb@google.com> Cc: Balbir Singh <bsingharora@gmail.com> Link: http://lkml.kernel.org/r/20200508183105.225460-10-hannes@cmpxchg.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
这个提交包含在:
15
mm/migrate.c
15
mm/migrate.c
@@ -490,11 +490,18 @@ int migrate_page_move_mapping(struct address_space *mapping,
|
||||
* are mapped to swap space.
|
||||
*/
|
||||
if (newzone != oldzone) {
|
||||
__dec_node_state(oldzone->zone_pgdat, NR_FILE_PAGES);
|
||||
__inc_node_state(newzone->zone_pgdat, NR_FILE_PAGES);
|
||||
struct lruvec *old_lruvec, *new_lruvec;
|
||||
struct mem_cgroup *memcg;
|
||||
|
||||
memcg = page_memcg(page);
|
||||
old_lruvec = mem_cgroup_lruvec(memcg, oldzone->zone_pgdat);
|
||||
new_lruvec = mem_cgroup_lruvec(memcg, newzone->zone_pgdat);
|
||||
|
||||
__dec_lruvec_state(old_lruvec, NR_FILE_PAGES);
|
||||
__inc_lruvec_state(new_lruvec, NR_FILE_PAGES);
|
||||
if (PageSwapBacked(page) && !PageSwapCache(page)) {
|
||||
__dec_node_state(oldzone->zone_pgdat, NR_SHMEM);
|
||||
__inc_node_state(newzone->zone_pgdat, NR_SHMEM);
|
||||
__dec_lruvec_state(old_lruvec, NR_SHMEM);
|
||||
__inc_lruvec_state(new_lruvec, NR_SHMEM);
|
||||
}
|
||||
if (dirty && mapping_cap_account_dirty(mapping)) {
|
||||
__dec_node_state(oldzone->zone_pgdat, NR_FILE_DIRTY);
|
||||
|
在新工单中引用
屏蔽一个用户