Skip to content

Commit

Permalink
mm: more likely reclaim MADV_SEQUENTIAL mappings
Browse files Browse the repository at this point in the history
File pages mapped only in sequentially read mappings are perfect reclaim
canditates.

This patch makes these mappings behave like weak references, their pages
will be reclaimed unless they have a strong reference from a normal
mapping as well.

It changes the reclaim and the unmap path where they check if the page has
been referenced.  In both cases, accesses through sequentially read
mappings will be ignored.

Benchmark results from KOSAKI Motohiro:

    http://marc.info/?l=linux-mm&m=122485301925098&w=2

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
Signed-off-by: Rik van Riel <riel@redhat.com>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Johannes Weiner authored and Linus Torvalds committed Jan 6, 2009
1 parent 64cdd54 commit 4917e5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,8 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
else {
if (pte_dirty(ptent))
set_page_dirty(page);
if (pte_young(ptent))
if (pte_young(ptent) &&
likely(!VM_SequentialReadHint(vma)))
mark_page_accessed(page);
file_rss--;
}
Expand Down
13 changes: 11 additions & 2 deletions mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,17 @@ static int page_referenced_one(struct page *page,
goto out_unmap;
}

if (ptep_clear_flush_young_notify(vma, address, pte))
referenced++;
if (ptep_clear_flush_young_notify(vma, address, pte)) {
/*
* Don't treat a reference through a sequentially read
* mapping as such. If the page has been used in
* another mapping, we will catch it; if this other
* mapping is already gone, the unmap path will have
* set PG_referenced or activated the page.
*/
if (likely(!VM_SequentialReadHint(vma)))
referenced++;
}

/* Pretend the page is referenced if the task has the
swap token and is in the middle of a page fault. */
Expand Down

0 comments on commit 4917e5d

Please sign in to comment.