[PATCH] mm/memcg: add missed warning in mem_cgroup_lruvec

From: Alex Shi
Date: Fri Nov 20 2020 - 04:02:41 EST


commit "(mm/memcontrol:rewrite mem_cgroup_page_lruvec())" on mm tree use
mem_cgroup_lruvec to rewrite mem_cgroup_page_lruvec, but it missed a
DEBUG_VM warning as following, since we always charge a page before
return from allocation. Add back this warning is helpful:

VM_WARN_ON_ONCE(!memcg);

Signed-off-by: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Shakeel Butt <shakeelb@xxxxxxxxxx>
Cc: Roman Gushchin <guro@xxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Yafang Shao <laoar.shao@xxxxxxxxx>
Cc: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx>
Cc: Hui Su <sh_def@xxxxxxx>
Cc: Wei Yang <richard.weiyang@xxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
include/linux/memcontrol.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 925b09ace986..303438822818 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -618,6 +618,7 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
goto out;
}

+ VM_WARN_ON_ONCE(!memcg);
if (!memcg)
memcg = root_mem_cgroup;

--
2.29.GIT