[Devel] [PATCH RHEL7 COMMIT] ms/mm: vmscan: check if mem cgroup is disabled or not before calling memcg slab shrinker
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Jul 18 15:51:32 MSK 2019
The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.21.3.vz7.106.6
------>
commit bd917ca7b8474159799a97eaaec985c32164c4fb
Author: Yang Shi <yang.shi at linux.alibaba.com>
Date: Thu Jul 18 15:51:30 2019 +0300
ms/mm: vmscan: check if mem cgroup is disabled or not before calling memcg slab shrinker
Shakeel Butt reported premature oom on kernel with
"cgroup_disable=memory" since mem_cgroup_is_root() returns false even
though memcg is actually NULL. The drop_caches is also broken.
It is because commit aeed1d325d42 ("mm/vmscan.c: generalize shrink_slab()
calls in shrink_node()") removed the !memcg check before
!mem_cgroup_is_root(). And, surprisingly root memcg is allocated even
though memory cgroup is disabled by kernel boot parameter.
Add mem_cgroup_disabled() check to make reclaimer work as expected.
Fixes: aeed1d325d42 ("mm/vmscan.c: generalize shrink_slab() calls in shrink_node()")
Reported-by: Shakeel Butt <shakeelb at google.com>
Cc: Vladimir Davydov <vdavydov.dev at gmail.com>
Cc: Johannes Weiner <hannes at cmpxchg.org>
Cc: Michal Hocko <mhocko at suse.com>
Cc: Kirill Tkhai <ktkhai at virtuozzo.com>
Cc: Roman Gushchin <guro at fb.com>
Cc: Hugh Dickins <hughd at google.com>
Cc: Qian Cai <cai at lca.pw>
Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
Cc: stable at vger.kernel.org 4.19+
Reviewed-by: Shakeel Butt <shakeelb at google.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
mm/vmscan.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 74d3e8c61cf7..539b171c7073 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -544,8 +544,14 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
if (unlikely(test_tsk_thread_flag(current, TIF_MEMDIE)))
return 0;
-
- if (!mem_cgroup_is_root(memcg))
+ /*
+ * The root memcg might be allocated even though memcg is disabled
+ * via "cgroup_disable=memory" boot parameter. This could make
+ * mem_cgroup_is_root() return false, then just run memcg slab
+ * shrink, but skip global shrink. This may result in premature
+ * oom.
+ */
+ if (!mem_cgroup_disabled() && !mem_cgroup_is_root(memcg))
return shrink_slab_memcg(gfp_mask, nid, memcg, priority);
if (!down_read_trylock(&shrinker_rwsem)) {
More information about the Devel
mailing list