From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/6] readahead: context based method: update ra_min
Date: Sat, 06 Jan 2007 15:26:29 +0800 [thread overview]
Message-ID: <368068421.78607@ustc.edu.cn> (raw)
Message-ID: <20070106072729.755581784@mail.ustc.edu.cn> (raw)
In-Reply-To: 20070106072626.911640026@mail.ustc.edu.cn
[-- Attachment #1: readahead-context-based-method-update-ra_min.patch --]
[-- Type: text/plain, Size: 3342 bytes --]
Classify the 4 cases into 2 classes, and assign proper ra_min for them.
Also update comments correspondly.
Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
---
mm/readahead.c | 49 +++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 16 deletions(-)
--- linux-2.6.20-rc3-mm1.orig/mm/readahead.c
+++ linux-2.6.20-rc3-mm1/mm/readahead.c
@@ -1285,17 +1285,26 @@ static int
try_context_based_readahead(struct address_space *mapping,
struct file_ra_state *ra,
struct page *page, pgoff_t offset,
- unsigned long ra_min, unsigned long ra_max)
+ unsigned long req_size, unsigned long ra_max)
{
pgoff_t start;
+ unsigned long ra_min;
unsigned long ra_size;
unsigned long la_size;
- /* Check if there is a segment of history pages, and its end index.
+ /*
+ * Check if there is a segment of history pages, and its end index.
* Based on which we decide whether and where to start read-ahead.
- *
- * Case 1: we have a current page.
- * Search forward for a nearby hole.
+ */
+
+ /*
+ * Select a reasonable large initial size for sequential reads.
+ */
+ ra_min = min(req_size * 4, mapping->backing_dev_info->ra_pages0);
+
+ /*
+ * Case s1: we have a current page.
+ * =======> Search forward for a nearby hole.
*/
read_lock_irq(&mapping->tree_lock);
if (page) {
@@ -1308,8 +1317,9 @@ try_context_based_readahead(struct addre
return -1;
}
- /* Case 2: current page is missing; previous page is present.
- * Just do read-ahead from the current index on.
+ /*
+ * Case s2: current page is missing; previous page is present.
+ * =======> Just do read-ahead from the current index on.
* There's clear sign of sequential reading. It can be
* a) seek => read => this read
* b) cache hit read(s) => this read
@@ -1321,26 +1331,33 @@ try_context_based_readahead(struct addre
goto has_history_pages;
}
- /* Case 2x: the same context info as 2.
- * It can be the early stage of semi-sequential reads(interleaved/nfsd),
- * or an ugly random one. So be conservative.
+ /*
+ * Not an obvious sequential read:
+ * select a conservative initial size, plus user prefered agressiveness.
+ */
+ ra_min = min(req_size, MIN_RA_PAGES) +
+ readahead_hit_rate * 8192 / PAGE_CACHE_SIZE;
+
+ /*
+ * Case r1: the same context info as s2, but not that obvious.
+ * =======> The same action as s2, but be conservative.
+ * It can be the early stage of intermixed sequential reads,
+ * or an ugly random one.
*/
if (readahead_hit_rate && __probe_page(mapping, offset - 1)) {
start = offset;
- if (ra_min > 2 * readahead_hit_rate)
- ra_min = 2 * readahead_hit_rate;
goto has_history_pages;
}
- /* Case 3: no current/previous pages;
- * sparse read-ahead is enabled: ok, be aggressive.
- * Check if there's any adjecent history pages.
+ /*
+ * Case r2: no current/previous pages; sparse read-ahead is enabled.
+ * =======> Do sparse read-ahead if there are adjecent history pages.
*/
if (readahead_hit_rate > 1) {
start = radix_tree_scan_data_backward(&mapping->page_tree,
offset, ra_min);
if (start != ULONG_MAX && offset - start < ra_min) {
- ra_min += offset - start;
+ ra_min *= 2;
offset = ++start; /* pretend the request starts here */
goto has_history_pages;
}
--
next prev parent reply other threads:[~2007-01-06 7:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-06 7:26 [PATCH 0/6] adaptive readahead update Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu
2007-01-06 7:26 ` [PATCH 1/6] readahead: sysctl parameters: set readahead_hit_rate=1 Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu
2007-01-06 7:26 ` [PATCH 2/6] readahead: min/max sizes: remove get_readahead_bounds() Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu [this message]
2007-01-06 7:26 ` [PATCH 3/6] readahead: context based method: update ra_min Fengguang Wu
2007-01-06 7:26 ` [PATCH 4/6] readahead: context based method: remove readahead_ratio Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu
2007-01-06 7:26 ` [PATCH 5/6] readahead: call scheme: remove get_readahead_bounds() Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu
2007-01-06 7:26 ` [PATCH 6/6] readahead: nfsd case: remove ra_min Fengguang Wu
2007-01-06 7:26 ` Fengguang Wu
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=368068421.78607@ustc.edu.cn \
--to=wfg@mail.ustc.edu.cn \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.