lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1606446515-36069-1-git-send-email-alex.shi@linux.alibaba.com>
Date:   Fri, 27 Nov 2020 11:08:35 +0800
From:   Alex Shi <alex.shi@...ux.alibaba.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Johannes Weiner <hannes@...xchg.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        Roman Gushchin <guro@...com>,
        Lorenzo Stoakes <lstoakes@...il.com>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Alexander Duyck <alexander.h.duyck@...ux.intel.com>,
        Yafang Shao <laoar.shao@...il.com>,
        Wei Yang <richard.weiyang@...il.com>,
        linux-kernel@...r.kernel.org
Subject: [PATCH] mm/memcg: bail out early when !memcg in mem_cgroup_lruvec

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@...ux.alibaba.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Shakeel Butt <shakeelb@...gle.com>
Cc: Roman Gushchin <guro@...com>
Cc: Lorenzo Stoakes <lstoakes@...il.com>
Cc: Stephen Rothwell <sfr@...b.auug.org.au>
Cc: Alexander Duyck <alexander.h.duyck@...ux.intel.com>
Cc: Yafang Shao <laoar.shao@...il.com>
Cc: Wei Yang <richard.weiyang@...il.com>
Cc: linux-kernel@...r.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ