public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"npiggin@suse.de" <npiggin@suse.de>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	"yinghan@google.com" <yinghan@google.com>
Subject: [PATCH] readahead: enforce full sync mmap readahead size
Date: Sun, 12 Apr 2009 15:09:44 +0800	[thread overview]
Message-ID: <20090412070943.GB5737@localhost> (raw)
In-Reply-To: <20090410163413.a014bde0.akpm@linux-foundation.org>

Now that we do readahead for sequential mmap reads, here is
a simple evaluation of the impacts, and one further optimization.

It's an NFS-root debian desktop system, readahead size = 60 pages.
The numbers are grabbed after a fresh boot into console.

approach        pgmajfault      RA miss ratio   mmap IO count   avg IO size(pages)
   A            383             31.6%           383             11
   B            225             32.4%           390             11
   C            224             32.6%           307             13

case A: mmap sync/async readahead disabled
case B: mmap sync/async readahead enabled, with enforced full async readahead size
case C: mmap sync/async readahead enabled, with enforced full sync/async readahead size
or:
A = vanilla 2.6.30-rc1
B = A plus mmap readahead
C = B plus this patch

The numbers show that
- there are good possibilities for random mmap reads to trigger readahead
- 'pgmajfault' is reduced by 1/3, due to the _async_ nature of readahead
- case C can further reduce IO count by 1/4
- readahead miss ratios are not quite affected

The theory is
- readahead is _good_ for clustered random reads, and can perform
  _better_ than readaround because they could be _async_.
- async readahead size is guaranteed to be larger than readaround
  size, and they are _async_, hence will mostly behave better
However for B
- sync readahead size could be smaller than readaround size, hence may
  make things worse by produce more smaller IOs
which will be fixed by this patch.

Final conclusion:
- mmap readahead reduced major faults by 1/3 and no obvious overheads;
- mmap io can be further reduced by 1/4 with this patch.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 mm/filemap.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- mm.orig/mm/filemap.c
+++ mm/mm/filemap.c
@@ -1471,7 +1471,8 @@ static void do_sync_mmap_readahead(struc
 	if (VM_SequentialReadHint(vma) ||
 			offset - 1 == (ra->prev_pos >> PAGE_CACHE_SHIFT)) {
 		ra->flags |= RA_FLAG_MMAP;
-		page_cache_sync_readahead(mapping, ra, file, offset, 1);
+		page_cache_sync_readahead(mapping, ra, file, offset,
+					  ra->ra_pages);
 		return;
 	}
 

  parent reply	other threads:[~2009-04-12  7:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-10  6:09 [PATCH 0/9] filemap and readahead fixes for linux-next Wu Fengguang
2009-04-10  6:09 ` [PATCH 1/9] readahead: move max_sane_readahead() calls into force_page_cache_readahead() Wu Fengguang
2009-04-10  6:09 ` [PATCH 2/9] readahead: apply max_sane_readahead() limit in ondemand_readahead() Wu Fengguang
2009-04-10  6:10 ` [PATCH 3/9] readahead: remove one unnecessary radix tree lookup Wu Fengguang
2009-04-10  6:10 ` [PATCH 4/9] readahead: increase interleaved readahead size Wu Fengguang
2009-04-10  6:10 ` [PATCH 5/9] readahead: remove sync/async readahead call dependency Wu Fengguang
2009-04-10  6:10 ` [PATCH 6/9] readahead: clean up and simplify the code for filemap page fault readahead Wu Fengguang
2009-04-10 23:48   ` Andrew Morton
2009-04-11 13:58     ` KOSAKI Motohiro
2009-04-11 18:49       ` Andrew Morton
2009-04-12 23:16         ` KOSAKI Motohiro
2009-04-10  6:10 ` [PATCH 7/9] readahead: sequential mmap readahead Wu Fengguang
2009-04-10 23:34   ` Andrew Morton
2009-04-12  6:50     ` Wu Fengguang
2009-04-12  7:09     ` Wu Fengguang [this message]
2009-04-12 15:15       ` [PATCH] readahead: enforce full sync mmap readahead size Linus Torvalds
2009-04-13 13:53         ` Wu Fengguang
2009-04-14  7:01         ` Nick Piggin
2009-04-10  6:10 ` [PATCH 8/9] readahead: enforce full readahead size on async mmap readahead Wu Fengguang
2009-04-10  6:10 ` [PATCH 9/9] readahead: record mmap read-around states in file_ra_state Wu Fengguang
2009-04-10 23:38   ` Andrew Morton
2009-04-11  4:24     ` Wu Fengguang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090412070943.GB5737@localhost \
    --to=fengguang.wu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yinghan@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox