[rh7,3/3] mm/workingset: Fix memcg_inc_ws_activate() with disabled mem cgroups.

Submitted by Andrey Ryabinin on May 17, 2019, 1:08 p.m.

Details

Message ID 20190517130802.4596-3-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin May 17, 2019, 1:08 p.m.
When mem cgroups are disabled memcg_inc_ws_activate might be called with
NULL memcg and crash. Fix it.

Fixes: f6a8b015027e ("ms/mm: workingset: per-cgroup cache thrash detection")
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/memcontrol.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 301fedcbc312..929dbdbb72c8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1143,6 +1143,9 @@  unsigned long memcg_ws_activates(struct mem_cgroup *memcg)
 
 void memcg_inc_ws_activate(struct mem_cgroup *memcg)
 {
+	if (mem_cgroup_disabled())
+		return;
+
 	percpu_counter_inc(&memcg->stat2.counters[MEM_CGROUP_STAT_WS_ACTIVATE]);
 }