Sometime, we use NULL memcg in mem_cgroup_lruvec(memcg, pgdat) so we could get out early in the situation to avoid useless checking.
Also warning if both parameter are NULL. Signed-off-by: Alex Shi <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: Yafang Shao <[email protected]> Cc: Wei Yang <[email protected]> Cc: [email protected] --- include/linux/memcontrol.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 3e6a1df3bdb9..4cdb110f84e0 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -613,14 +613,13 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, struct mem_cgroup_per_node *mz; struct lruvec *lruvec; - if (mem_cgroup_disabled()) { + VM_WARN_ON_ONCE(!memcg && !pgdat); + + if (mem_cgroup_disabled() || !memcg) { lruvec = &pgdat->__lruvec; goto out; } - if (!memcg) - memcg = root_mem_cgroup; - mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id); lruvec = &mz->lruvec; out: -- 2.29.GIT

