Skip to content

Commit 275b12b

Browse files
Wu Fengguangtorvalds
authored andcommitted
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>
1 parent 1495f23 commit 275b12b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎mm/filemap.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,8 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma,
15561556
/* If we don't want any read-ahead, don't bother */
15571557
if (VM_RandomReadHint(vma))
15581558
return;
1559+
if (!ra->ra_pages)
1560+
return;
15591561

15601562
if (VM_SequentialReadHint(vma) ||
15611563
offset - 1 == (ra->prev_pos >> PAGE_CACHE_SHIFT)) {
@@ -1578,12 +1580,10 @@ static void do_sync_mmap_readahead(struct vm_area_struct *vma,
15781580
* mmap read-around
15791581
*/
15801582
ra_pages = max_sane_readahead(ra->ra_pages);
1581-
if (ra_pages) {
1582-
ra->start = max_t(long, 0, offset - ra_pages/2);
1583-
ra->size = ra_pages;
1584-
ra->async_size = 0;
1585-
ra_submit(ra, mapping, file);
1586-
}
1583+
ra->start = max_t(long, 0, offset - ra_pages / 2);
1584+
ra->size = ra_pages;
1585+
ra->async_size = 0;
1586+
ra_submit(ra, mapping, file);
15871587
}
15881588

15891589
/*

0 commit comments

Comments
 (0)