LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: Martin Peschke <mp3@de.ibm.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 8/8] readahead: laptop mode fix
Date: Sat, 27 Jan 2007 16:02:27 +0800	[thread overview]
Message-ID: <369886264.38864@ustc.edu.cn> (raw)
Message-ID: <20070127082530.379485097@mail.ustc.edu.cn> (raw)
In-Reply-To: 20070127080219.161473179@mail.ustc.edu.cn

[-- Attachment #1: readahead-laptop-mode-fix.patch --]
[-- Type: text/plain, Size: 2151 bytes --]

1) make LAPTOP_POLL_INTERVAL independent of page size

2) defer readahead to the _last_ minute

There's no luck for the kernel to know the right time of
waking up the disk in order to hide the spin up latency.

So we make the rule simple:
- The kernel ensures _longest_ spin down time;
- The media player caches enough data to hide the spin up delay.

That means, if one enabled laptop mode, and want to watch movies
without pauses, he should setup proper media player cache as well.

Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
---
 mm/readahead.c |   22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

--- linux-2.6.20-rc4-mm1.orig/mm/readahead.c
+++ linux-2.6.20-rc4-mm1/mm/readahead.c
@@ -37,7 +37,7 @@
 #define INITIAL_RA_PAGES  DIV_ROUND_UP(64*1024, PAGE_CACHE_SIZE)
 
 /* In laptop mode, poll delayed look-ahead on every ## pages read. */
-#define LAPTOP_POLL_INTERVAL 16
+#define LAPTOP_POLL_INTERVAL	DIV_ROUND_UP(64*1024, PAGE_CACHE_SIZE)
 
 /* Set look-ahead size to 1/# of the thrashing-threshold. */
 #define LOOKAHEAD_RATIO 8
@@ -788,28 +788,22 @@ out:
 
 /*
  * Set a new look-ahead mark at @next.
- * Return 0 if the new mark is successfully set.
  */
-static int renew_lookahead(struct address_space *mapping,
+static void defer_lookahead(struct address_space *mapping,
 				struct file_ra_state *ra,
 				pgoff_t offset, pgoff_t next)
 {
 	struct page *page;
 
-	if (offset == ra->lookahead_index &&
-	      next >= ra->readahead_index)
-		return 1;
-
-	if (!(page = find_get_page(mapping, next)))
-		return 1;
+	page = find_get_page(mapping, next);
+	if (!page)
+		return;
 
 	SetPageReadahead(page);
 	page_cache_release(page);
 
 	if (ra->lookahead_index == offset)
 	    ra->lookahead_index = next;
-
-	return 0;
 }
 
 /*
@@ -1617,9 +1611,9 @@ page_cache_readahead_adaptive(struct add
 		 * Defer read-ahead to save energy.
 		 */
 		if (unlikely(laptop_mode && laptop_spinned_down())) {
-			if (!renew_lookahead(mapping, ra, offset,
-						offset + LAPTOP_POLL_INTERVAL))
-				return 0;
+			defer_lookahead(mapping, ra, offset,
+						offset + LAPTOP_POLL_INTERVAL);
+			return 0;
 		}
 	}
 

--

      parent reply	other threads:[~2007-01-27  8:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <369886263.20106@ustc.edu.cn>
2007-01-27  8:02 ` [PATCH 0/8] readahead updates Fengguang Wu
     [not found]   ` <369886263.49250@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 1/8] readahead: min/max sizes: increase VM_MIN_READAHEAD to 32KB Fengguang Wu
     [not found]   ` <369886263.27547@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 2/8] readahead: state based method routines: explicitly embed class_new/class_old inside flags Fengguang Wu
     [not found]   ` <369886263.59195@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 3/8] readahead: state based method: prevent tiny size Fengguang Wu
     [not found]   ` <369886263.12429@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 4/8] readahead: state based method: move readahead_ratio out of compute_thrashing_threshold() Fengguang Wu
     [not found]   ` <369886264.20106@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 5/8] readahead: initial method: user recommended size: rename to read_ahead_initial_kb Fengguang Wu
     [not found]   ` <369886264.06097@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 6/8] readahead: thrashing recovery method fix Fengguang Wu
     [not found]   ` <369886264.76457@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 7/8] readahead: call scheme: fix thrashed unaligned read Fengguang Wu
     [not found]   ` <369886264.38864@ustc.edu.cn>
2007-01-27  8:02     ` [PATCH 8/8] readahead: laptop mode fix Fengguang Wu
2007-01-31 13:37   ` [PATCH 0/8] readahead updates martin

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=369886264.38864@ustc.edu.cn \
    --to=wfg@mail.ustc.edu.cn \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mp3@de.ibm.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;
as well as URLs for NNTP newsgroup(s).