aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2011-05-24 20:12:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 11:39:26 -0400
commit275b12bf5486f6f531111fd3d7dbbf01df427cfe (patch)
treeebed0109eaa3e4a015bc1653f4d933f2e84c794f
parent1495f230fa7750479c79e3656286b9183d662077 (diff)
readahead: return early when readahead is disabled
Reduce readahead overheads by returning early in do_sync_mmap_readahead(). tmpfs has ra_pages=0 and it can page fault really fast (not constraint by IO if not swapping). Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Tested-by: Tim Chen <tim.c.chen@intel.com> Reported-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/filemap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 88354ae0b1fd..c974a2863897 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1556,6 +1556,8 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma,
1556 /* If we don't want any read-ahead, don't bother */ 1556 /* If we don't want any read-ahead, don't bother */
1557 if (VM_RandomReadHint(vma)) 1557 if (VM_RandomReadHint(vma))
1558 return; 1558 return;
1559 if (!ra->ra_pages)
1560 return;
1559 1561
1560 if (VM_SequentialReadHint(vma) || 1562 if (VM_SequentialReadHint(vma) ||
1561 offset - 1 == (ra->prev_pos >> PAGE_CACHE_SHIFT)) { 1563 offset - 1 == (ra->prev_pos >> PAGE_CACHE_SHIFT)) {
@@ -1578,12 +1580,10 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma,
1578 * mmap read-around 1580 * mmap read-around
1579 */ 1581 */
1580 ra_pages = max_sane_readahead(ra->ra_pages); 1582 ra_pages = max_sane_readahead(ra->ra_pages);
1581 if (ra_pages) { 1583 ra->start = max_t(long, 0, offset - ra_pages / 2);
1582 ra->start = max_t(long, 0, offset - ra_pages/2); 1584 ra->size = ra_pages;
1583 ra->size = ra_pages; 1585 ra->async_size = 0;
1584 ra->async_size = 0; 1586 ra_submit(ra, mapping, file);
1585 ra_submit(ra, mapping, file);
1586 }
1587} 1587}
1588 1588
1589/* 1589/*