linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm] mm: more likely reclaim MADV_SEQUENTIAL mappings
@ 2008-07-19 17:31 Johannes Weiner
  2008-07-19 17:59 ` Rik van Riel
  2008-07-21  0:09 ` KOSAKI Motohiro
  0 siblings, 2 replies; 13+ messages in thread
From: Johannes Weiner @ 2008-07-19 17:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Rik van Riel, Peter Zijlstra, Nossum, linux-mm, linux-kernel

File pages accessed only once through sequential-read mappings between
fault and scan time are perfect candidates for reclaim.

This patch makes page_referenced() ignore these singular references and
the pages stay on the inactive list where they likely fall victim to the
next reclaim phase.

Already activated pages are still treated normally.  If they were
accessed multiple times and therefor promoted to the active list, we
probably want to keep them.

Benchmarks show that big (relative to the system's memory)
MADV_SEQUENTIAL mappings read sequentially cause much less kernel
activity.  Especially less LRU moving-around because we never activate
read-once pages in the first place just to demote them again.

And leaving these perfect reclaim candidates on the inactive list makes
it more likely for the real working set to survive the next reclaim
scan.

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
Signed-off-by: Rik van Riel <riel@redhat.com>
---
 mm/rmap.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Benchmark graphs and the test-application can be found here:

	http://hannes.saeurebad.de/madvseq/

Patch is against -mm, although only tested on good ol' linus-tree as
-mmotm wouldn't compile at the moment.

--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -333,8 +333,18 @@ static int page_referenced_one(struct pa
 		goto out_unmap;
 	}
 
-	if (ptep_clear_flush_young_notify(vma, address, pte))
-		referenced++;
+	if (ptep_clear_flush_young_notify(vma, address, pte)) {
+		/*
+		 * If there was just one sequential access to the
+		 * page, ignore it.  Otherwise, mark_page_accessed()
+		 * will have promoted the page to the active list and
+		 * it should be kept.
+		 */
+		if (VM_SequentialReadHint(vma) && !PageActive(page))
+			ClearPageReferenced(page);
+		else
+			referenced++;
+	}
 
 	/* Pretend the page is referenced if the task has the
 	   swap token and is in the middle of a page fault. */
@@ -455,9 +465,6 @@ int page_referenced(struct page *page, i
 {
 	int referenced = 0;
 
-	if (TestClearPageReferenced(page))
-		referenced++;
-
 	if (page_mapped(page) && page->mapping) {
 		if (PageAnon(page))
 			referenced += page_referenced_anon(page, mem_cont);
@@ -473,6 +480,9 @@ int page_referenced(struct page *page, i
 		}
 	}
 
+	if (TestClearPageReferenced(page))
+		referenced++;
+
 	if (page_test_and_clear_young(page))
 		referenced++;
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-07-22  3:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-19 17:31 [PATCH -mm] mm: more likely reclaim MADV_SEQUENTIAL mappings Johannes Weiner
2008-07-19 17:59 ` Rik van Riel
2008-07-21  0:09 ` KOSAKI Motohiro
2008-07-21  1:48   ` Andrew Morton
2008-07-21  3:53     ` KOSAKI Motohiro
2008-07-21  5:49     ` Nick Piggin
2008-07-21 15:14       ` Rik van Riel
2008-07-22  2:02         ` Nick Piggin
2008-07-22  2:36           ` Rik van Riel
2008-07-22  2:54             ` Nick Piggin
2008-07-22  3:04               ` Rik van Riel
2008-07-22  3:43                 ` Nick Piggin
2008-07-22  3:49                   ` Nick Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox