[PATCH] mm: vmscan: detect file thrashing at the reclaim root fix

From: Johannes Weiner
Date: Fri Nov 15 2019 - 09:14:04 EST


Shakeel points out that the page is locked and already charged by the
time we call workingset_refault(). Instead of doing another cgroup
lookup and reference from current->mm we can simply use page_memcg().

Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
---
mm/workingset.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/mm/workingset.c b/mm/workingset.c
index f0885d9f41cd..474186b76ced 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -338,7 +338,7 @@ void workingset_refault(struct page *page, void *shadow)
* However, the cgroup that will own the page is the one that
* is actually experiencing the refault event.
*/
- memcg = get_mem_cgroup_from_mm(current->mm);
+ memcg = page_memcg(page);
lruvec = mem_cgroup_lruvec(memcg, pgdat);

inc_lruvec_state(lruvec, WORKINGSET_REFAULT);
@@ -349,7 +349,7 @@ void workingset_refault(struct page *page, void *shadow)
* the memory was available to the page cache.
*/
if (refault_distance > active_file)
- goto out_memcg;
+ goto out;

SetPageActive(page);
advance_inactive_age(memcg, pgdat);
@@ -360,9 +360,6 @@ void workingset_refault(struct page *page, void *shadow)
SetPageWorkingset(page);
inc_lruvec_state(lruvec, WORKINGSET_RESTORE);
}
-
-out_memcg:
- mem_cgroup_put(memcg);
out:
rcu_read_unlock();
}
--
2.24.0