lkml.org 
[lkml]   [2020]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v4 5/8] mm/workingset: handle the page without memcg
Date
From: Joonsoo Kim <iamjoonsoo.kim@lge.com>

When implementing workingset detection for anonymous page, I found
some swapcache pages with NULL memcg. They are brought in by swap
readahead and nobody has touched it.

The idea behind the workingset code is to tell on page fault time
whether pages have been previously used or not. Since this page
hasn't been used, don't store a shadow entry for it; when it later
faults back in, we treat it as the new page that it is.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
mm/workingset.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/mm/workingset.c b/mm/workingset.c
index 59415e0..8b192e8 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -257,6 +257,19 @@ void *workingset_eviction(struct page *page, struct mem_cgroup *target_memcg)
VM_BUG_ON_PAGE(page_count(page), page);
VM_BUG_ON_PAGE(!PageLocked(page), page);

+ /*
+ * A page can be without a cgroup here when it was brought in by
+ * swap readahead and nobody has touched it since.
+ *
+ * The idea behind the workingset code is to tell on page fault
+ * time whether pages have been previously used or not. Since
+ * this page hasn't been used, don't store a shadow entry for it;
+ * when it later faults back in, we treat it as the new page
+ * that it is.
+ */
+ if (!page_memcg(page))
+ return NULL;
+
advance_inactive_age(page_memcg(page), pgdat, file);

lruvec = mem_cgroup_lruvec(target_memcg, pgdat);
--
2.7.4
\
 
 \ /
  Last update: 2020-03-23 06:53    [W:0.169 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site