[RHEL7,COMMIT] mm/workingset: Fix workingset_activation() with disabled mem cgroups.

Submitted by Konstantin Khorenko on May 28, 2019, 4:07 p.m.

Details

Message ID 201905281607.x4SG7JhU006205@finist-ce7.sw.ru
State New
Series "mm/workingset: Fix workingset_activation() with disabled mem cgroups."
Headers show

Commit Message

Konstantin Khorenko May 28, 2019, 4:07 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.6
------>
commit eb081deaa5c63ae3c3b4ce00a3dc6b05262ff5fb
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Tue May 28 18:54:52 2019 +0300

    mm/workingset: Fix workingset_activation() with disabled mem cgroups.
    
    When mem cgroups are disabled in workingset_activation()
    lookup_page_cgroup() can return NULL and trigger crash on next step on
    page bit check.
    
    Fixes: f6a8b015027e ("ms/mm: workingset: per-cgroup cache
    thrash detection")
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 mm/workingset.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/workingset.c b/mm/workingset.c
index 1598d2b02314..f9ffc9d69f62 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -322,9 +322,12 @@  void workingset_activation(struct page *page)
 	unsigned long flags;
 
 	mem_cgroup_begin_update_page_stat(page, &locked, &flags);
-	pc = lookup_page_cgroup(page);
-	if (likely(PageCgroupUsed(pc)))
-		memcg = pc->mem_cgroup;
+	if (!mem_cgroup_disabled()) {
+		pc = lookup_page_cgroup(page);
+		if (likely(PageCgroupUsed(pc)))
+			memcg = pc->mem_cgroup;
+	}
+	/* else memcg == NULL (set above) */
 
 	/*
 	 * Filter non-memcg pages here, e.g. unmap can call