lkml.org 
[lkml]   [2007]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 8/8] readahead: laptop mode fix
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;
}
}

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-01-27 09:29    [W:0.220 / U:0.088 seconds]
©2003-2014 Jasper Spaans. Advertise on this site