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

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

Details

Message ID 20190528160636.6139-1-khorenko@virtuozzo.com
State New
Series "mm/workingset: Fix workingset_activation() with disabled mem cgroups."
Headers show

Commit Message

Konstantin Khorenko May 28, 2019, 4:06 p.m.
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

Comments

Andrey Ryabinin May 28, 2019, 4:09 p.m.
On 5/28/19 7:06 PM, Konstantin Khorenko wrote:
> 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>
> ---

Ack