Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memcg: remove PCG_FILE_MAPPED

With the new lock scheme for updating memcg's page stat, we don't need a
flag PCG_FILE_MAPPED which was duplicated information of page_mapped().

[hughd@google.com: cosmetic fix]
[hughd@google.com: add comment to MEM_CGROUP_CHARGE_TYPE_MAPPED case in __mem_cgroup_uncharge_common()]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Greg Thelen <gthelen@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Ying Han <yinghan@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

KAMEZAWA Hiroyuki and committed by
Linus Torvalds
2ff76f11 89c06bd5

+6 -11
-6
include/linux/page_cgroup.h
··· 6 6 PCG_LOCK, /* Lock for pc->mem_cgroup and following bits. */ 7 7 PCG_USED, /* this object is in use. */ 8 8 PCG_MIGRATION, /* under page migration */ 9 - /* flags for mem_cgroup and file and I/O status */ 10 - PCG_FILE_MAPPED, /* page is accounted as "mapped" */ 11 9 __NR_PCG_FLAGS, 12 10 }; 13 11 ··· 63 65 TESTPCGFLAG(Used, USED) 64 66 CLEARPCGFLAG(Used, USED) 65 67 SETPCGFLAG(Used, USED) 66 - 67 - SETPCGFLAG(FileMapped, FILE_MAPPED) 68 - CLEARPCGFLAG(FileMapped, FILE_MAPPED) 69 - TESTPCGFLAG(FileMapped, FILE_MAPPED) 70 68 71 69 SETPCGFLAG(Migration, MIGRATION) 72 70 CLEARPCGFLAG(Migration, MIGRATION)
+6 -5
mm/memcontrol.c
··· 1966 1966 1967 1967 switch (idx) { 1968 1968 case MEMCG_NR_FILE_MAPPED: 1969 - if (val > 0) 1970 - SetPageCgroupFileMapped(pc); 1971 - else if (!page_mapped(page)) 1972 - ClearPageCgroupFileMapped(pc); 1973 1969 idx = MEM_CGROUP_STAT_FILE_MAPPED; 1974 1970 break; 1975 1971 default: ··· 2613 2617 2614 2618 move_lock_mem_cgroup(from, &flags); 2615 2619 2616 - if (PageCgroupFileMapped(pc)) { 2620 + if (!anon && page_mapped(page)) { 2617 2621 /* Update mapped_file data for mem_cgroup */ 2618 2622 preempt_disable(); 2619 2623 __this_cpu_dec(from->stat->count[MEM_CGROUP_STAT_FILE_MAPPED]); ··· 2978 2982 2979 2983 switch (ctype) { 2980 2984 case MEM_CGROUP_CHARGE_TYPE_MAPPED: 2985 + /* 2986 + * Generally PageAnon tells if it's the anon statistics to be 2987 + * updated; but sometimes e.g. mem_cgroup_uncharge_page() is 2988 + * used before page reached the stage of being marked PageAnon. 2989 + */ 2981 2990 anon = true; 2982 2991 /* fallthrough */ 2983 2992 case MEM_CGROUP_CHARGE_TYPE_DROP: