public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wu Fengguang <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, Wu Fengguang <wfg@mail.ustc.edu.cn>
Subject: [PATCH 2/6] readahead: backward prefetching method fix
Date: Sun, 25 Jun 2006 21:07:06 +0800	[thread overview]
Message-ID: <351240952.82409@ustc.edu.cn> (raw)
Message-ID: <20060625130921.987235199@localhost.localdomain> (raw)
In-Reply-To: 20060625130704.464870100@localhost.localdomain

[-- Attachment #1: readahead-backward-prefetching-fix.patch --]
[-- Type: text/plain, Size: 1870 bytes --]

- The backward prefetching method fails near start of file. Fix it.
- Make it scale up more quickly by adding ra_min to ra_size.
- Do not discount readahead_hit_rate, that's not a documented behavior.

Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn>
---


--- linux-2.6.17-mm2.orig/mm/readahead.c
+++ linux-2.6.17-mm2/mm/readahead.c
@@ -1636,8 +1636,9 @@ initial_readahead(struct address_space *
  * Important for certain scientific arenas(i.e. structural analysis).
  */
 static int
-try_read_backward(struct file_ra_state *ra, pgoff_t begin_index,
-			unsigned long ra_size, unsigned long ra_max)
+try_read_backward(struct file_ra_state *ra,
+			pgoff_t begin_index, unsigned long ra_size,
+			unsigned long ra_min, unsigned long ra_max)
 {
 	pgoff_t end_index;
 
@@ -1646,11 +1647,11 @@ try_read_backward(struct file_ra_state *
 		return 0;
 
 	if ((ra->flags & RA_CLASS_MASK) == RA_CLASS_BACKWARD &&
-					ra_has_index(ra, ra->prev_page)) {
-		ra_size += 2 * ra->hit0;
+		ra_has_index(ra, ra->prev_page) && ra_cache_hit_ok(ra)) {
+		ra_size += ra_min + 2 * ra_readahead_size(ra);
 		end_index = ra->la_index;
 	} else {
-		ra_size += ra_size + ra_size * (readahead_hit_rate - 1) / 2;
+		ra_size += ra_size * readahead_hit_rate;
 		end_index = ra->prev_page;
 	}
 
@@ -1661,7 +1662,7 @@ try_read_backward(struct file_ra_state *
 	if (end_index > begin_index + ra_size)
 		return 0;
 
-	begin_index = end_index - ra_size;
+	begin_index = end_index > ra_size ? end_index - ra_size : 0;
 
 	ra_set_class(ra, RA_CLASS_BACKWARD);
 	ra_set_index(ra, begin_index, begin_index);
@@ -1864,7 +1865,7 @@ page_cache_readahead_adaptive(struct add
 	 * Backward read-ahead.
 	 */
 	if (!page && begin_index == index &&
-				try_read_backward(ra, index, size, ra_max))
+				try_read_backward(ra, index, size, ra_min, ra_max))
 		return ra_dispatch(ra, mapping, filp);
 
 	/*

--

  parent reply	other threads:[~2006-06-25 13:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060625130704.464870100@localhost.localdomain>
2006-06-25 13:07 ` [PATCH 0/6] Adaptive readahead updates 3 Wu Fengguang
     [not found] ` <20060625130921.549904049@localhost.localdomain>
2006-06-25 13:07   ` [PATCH 1/6] readahead: context based method - slow start Wu Fengguang
     [not found]   ` <20060626023529.GB6120@mail.ustc.edu.cn>
2006-06-26  2:35     ` [updated PATCH " Wu Fengguang
     [not found] ` <20060625130921.987235199@localhost.localdomain>
2006-06-25 13:07   ` Wu Fengguang [this message]
     [not found] ` <20060625130922.216691316@localhost.localdomain>
2006-06-25 13:07   ` [PATCH 3/6] readahead: kconfig option READAHEAD_ALLOW_OVERHEADS Wu Fengguang
     [not found] ` <20060625130922.816467605@localhost.localdomain>
2006-06-25 13:07   ` [PATCH 5/6] readahead: kconfig option READAHEAD_HIT_FEEDBACK Wu Fengguang
     [not found] ` <20060625130923.154258797@localhost.localdomain>
2006-06-25 13:07   ` [PATCH 6/6] readahead: remove the size limit of max_sectors_kb on read_ahead_kb Wu Fengguang
     [not found] ` <20060626015256.GA6120@mail.ustc.edu.cn>
2006-06-26  1:52   ` [PATCH 0/6] Adaptive readahead updates 3 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=351240952.82409@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox