memcg: avoid vmpressure oops when memcg disabled
authorHugh Dickins <hughd@google.com>
Thu, 14 Jan 2016 23:21:37 +0000 (15:21 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Jan 2016 00:00:49 +0000 (16:00 -0800)
A CONFIG_MEMCG=y kernel booted with "cgroup_disable=memory" crashes on a
NULL memcg (but non-NULL root_mem_cgroup) when vmpressure kicks in.
Here's the patch I use to avoid that, but you might prefer a test on
mem_cgroup_disabled() somewhere.

Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/vmpressure.c

index 506f03e..9a6c070 100644 (file)
@@ -260,7 +260,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
                enum vmpressure_levels level;
 
                /* For now, no users for root-level efficiency */
-               if (memcg == root_mem_cgroup)
+               if (!memcg || memcg == root_mem_cgroup)
                        return;
 
                spin_lock(&vmpr->sr_lock);