From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 12/14] readahead: sequential mmap readahead Date: Tue, 07 Apr 2009 15:17:41 +0800 Message-ID: <20090407072134.111463227@intel.com> References: <20090407071729.233579162@intel.com> Cc: Ying Han , LKML , , , Nick Piggin , Linus Torvalds , Wu Fengguang To: Andrew Morton Return-path: Content-Disposition: inline; filename=readahead-mmap-sequential-readahead.patch Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org Auto-detect sequential mmap reads and do readahead for them. The sequential mmap readahead will be triggered when - sync readahead: it's a major fault and (prev_offset == offset-1); - async readahead: minor fault on PG_readahead page with valid readahead state. The benefits of doing readahead instead of read-around: - less I/O wait thanks to async readahead - double real I/O size and no more cache hits The single stream case is improved a little. For 100,000 sequential mmap reads: user system cpu total (1-1) plain -mm, 128KB readaround: 3.224 2.554 48.40% 11.838 (1-2) plain -mm, 256KB readaround: 3.170 2.392 46.20% 11.976 (2) patched -mm, 128KB readahead: 3.117 2.448 47.33% 11.607 The patched (2) has smallest total time, since it has no cache hit overheads and less I/O block time(thanks to async readahead). Here the I/O size makes no much difference, since there's only one single stream. Note that (1-1)'s real I/O size is 64KB and (1-2)'s real I/O size is 128KB, since the half of the read-around pages will be readahead cache hits. This is going to make _real_ differences for _concurrent_ IO streams. Cc: Nick Piggin Cc: Linus Torvalds Signed-off-by: Wu Fengguang --- mm/filemap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- mm.orig/mm/filemap.c +++ mm/mm/filemap.c @@ -1540,7 +1540,8 @@ static void do_sync_mmap_readahead(struc if (VM_RandomReadHint(vma)) return; - if (VM_SequentialReadHint(vma)) { + if (VM_SequentialReadHint(vma) || + offset - 1 == (ra->prev_pos >> PAGE_CACHE_SHIFT)) { page_cache_sync_readahead(mapping, ra, file, offset, 1); return; } -- -- 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: email@kvack.org