Messages in this thread Patch in this message |  | | From | Alex Shi <> | Subject | [PATCH] mm/memcg: bail out early when !memcg in mem_cgroup_lruvec | Date | Fri, 27 Nov 2020 11:08:35 +0800 |
| |
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 <alex.shi@linux.alibaba.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Shakeel Butt <shakeelb@google.com> Cc: Roman Gushchin <guro@fb.com> Cc: Lorenzo Stoakes <lstoakes@gmail.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com> Cc: Yafang Shao <laoar.shao@gmail.com> Cc: Wei Yang <richard.weiyang@gmail.com> Cc: linux-kernel@vger.kernel.org --- 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
|  |