Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 658b72c5 authored by Sha Zhengju's avatar Sha Zhengju Committed by Linus Torvalds
Browse files

memcg: check for proper lock held in mem_cgroup_update_page_stat



We should call mem_cgroup_begin_update_page_stat() before
mem_cgroup_update_page_stat() to get proper locks, however the latter
doesn't do any checking that we use proper locking, which would be hard.
Suggested by Michal Hock we could at least test for rcu_read_lock_held()
because RCU is held if !mem_cgroup_disabled().

Signed-off-by: default avatarSha Zhengju <handai.szj@taobao.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
Reviewed-by: default avatarGreg Thelen <gthelen@google.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 68b4876d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2225,6 +2225,7 @@ void mem_cgroup_update_page_stat(struct page *page,
	if (mem_cgroup_disabled())
		return;

	VM_BUG_ON(!rcu_read_lock_held());
	memcg = pc->mem_cgroup;
	if (unlikely(!memcg || !PageCgroupUsed(pc)))
		return;