[Devel] [PATCH rh7] mm/workingset: Fix workingset_activation() with disabled mem cgroups.

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 28 19:06:36 MSK 2019


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 at virtuozzo.com>
---
 mm/workingset.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

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
-- 
2.15.1



More information about the Devel mailing list