

Remove the hardwired pagefault readaround distance in filemap_nopage() and
use the per-file readahead setting.

The main reason for this is in fact laptop-mode.  If you want to prevent the
disk from spinning up then you want all of your application's pages to be
pulled into memory in one hit.  Otherwise the disk will spin up each time you
use a new part of whatever application(s) you are running.


---

 25-akpm/mm/filemap.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff -puN mm/filemap.c~tunable-pagefault-readaround mm/filemap.c
--- 25/mm/filemap.c~tunable-pagefault-readaround	2004-04-03 03:04:10.048218448 -0800
+++ 25-akpm/mm/filemap.c	2004-04-03 03:04:10.053217688 -0800
@@ -1006,7 +1006,6 @@ static int fastcall page_cache_read(stru
 	return error == -EEXIST ? 0 : error;
 }
 
-#define MMAP_READAROUND (16UL)
 #define MMAP_LOTSAMISS  (100)
 
 /*
@@ -1062,6 +1061,8 @@ retry_all:
 retry_find:
 	page = find_get_page(mapping, pgoff);
 	if (!page) {
+		unsigned long ra_pages;
+
 		if (VM_SequentialReadHint(area)) {
 			handle_ra_miss(mapping, ra, pgoff);
 			goto no_cached_page;
@@ -1084,8 +1085,15 @@ retry_find:
 			inc_page_state(pgmajfault);
 		}
 		did_readaround = 1;
-		do_page_cache_readahead(mapping, file,
-				pgoff & ~(MMAP_READAROUND-1), MMAP_READAROUND);
+		ra_pages = max_sane_readahead(file->f_ra.ra_pages);
+		if (ra_pages) {
+			long start;
+
+			start = pgoff - ra_pages / 2;
+			if (pgoff < 0)
+				pgoff = 0;
+			do_page_cache_readahead(mapping, file, pgoff, ra_pages);
+		}
 		goto retry_find;
 	}
 

_
