From: Wu Fengguang <wfg@mail.ustc.edu.cn>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@osdl.org>, Wu Fengguang <wfg@mail.ustc.edu.cn>
Subject: [PATCH 15/16] readahead: disable look-ahead for loopback file
Date: Wed, 09 Nov 2005 21:49:53 +0800 [thread overview]
Message-ID: <20051109141548.814311000@localhost.localdomain> (raw)
In-Reply-To: <20051109134938.757187000@localhost.localdomain>
[-- Attachment #1: readahead-disable-lookahead-for-loopback.patch --]
[-- Type: text/plain, Size: 2000 bytes --]
Loopback files normally contain filesystem, in which case there are already
proper look-aheads in the upper layer, more look-aheads on the loopback file
only ruin the read-ahead hit rate.
Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn>
---
I'd like to thank Tero Grundstr?m for uncovering the loopback problem.
drivers/block/loop.c | 6 ++++++
include/linux/fs.h | 1 +
mm/readahead.c | 8 ++++++++
3 files changed, 15 insertions(+)
--- linux-2.6.14-mm1.orig/include/linux/fs.h
+++ linux-2.6.14-mm1/include/linux/fs.h
@@ -585,6 +585,7 @@ struct file_ra_state {
};
#define RA_FLAG_MISS 0x01 /* a cache miss occured against this file */
#define RA_FLAG_INCACHE 0x02 /* file is already in cache */
+#define RA_FLAG_NO_LOOKAHEAD (1<<31) /* disable look-ahead */
struct file {
/*
--- linux-2.6.14-mm1.orig/drivers/block/loop.c
+++ linux-2.6.14-mm1/drivers/block/loop.c
@@ -769,6 +769,12 @@ static int loop_set_fd(struct loop_devic
mapping = file->f_mapping;
inode = mapping->host;
+ /*
+ * The upper layer should already do proper look-ahead,
+ * one more look-ahead here only ruins the cache hit rate.
+ */
+ file->f_ra.flags |= RA_FLAG_NO_LOOKAHEAD;
+
if (!(file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY;
--- linux-2.6.14-mm1.orig/mm/readahead.c
+++ linux-2.6.14-mm1/mm/readahead.c
@@ -1272,6 +1272,11 @@ static inline void ra_state_update(struc
if (ra_size < old_ra && ra_cache_hit(ra, 0))
ra_account(ra, RA_EVENT_READAHEAD_SHRINK, old_ra - ra_size);
#endif
+
+ /* Disable look-ahead for loopback file. */
+ if (unlikely(ra->flags & RA_FLAG_NO_LOOKAHEAD))
+ la_size = 0;
+
ra_addup_cache_hit(ra);
ra->ra_index = ra->readahead_index;
ra->la_index = ra->lookahead_index;
@@ -1628,6 +1633,9 @@ static int query_page_cache(struct addre
if (count < ra_max)
goto out;
+ if (unlikely(ra->flags & RA_FLAG_NO_LOOKAHEAD))
+ goto out;
+
/*
* Check the far pages coarsely.
* The big count here helps increase la_size.
--
next prev parent reply other threads:[~2005-11-09 14:15 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-09 13:49 [PATCH 00/16] Adaptive read-ahead V7 Wu Fengguang
2005-11-09 13:49 ` [PATCH 01/16] mm: delayed page activation Wu Fengguang
2005-11-10 0:21 ` Nick Piggin
2005-11-10 3:15 ` Wu Fengguang
2005-11-10 9:17 ` Peter Zijlstra
2005-11-10 10:30 ` Wu Fengguang
2005-11-09 13:49 ` [PATCH 02/16] mm: balance page aging between zones Wu Fengguang
2005-11-09 13:49 ` [PATCH 03/16] radixtree: sync with mainline Wu Fengguang
2005-11-09 13:49 ` [PATCH 04/16] radix-tree: look-aside cache Wu Fengguang
2005-11-09 23:31 ` Nick Piggin
2005-11-10 5:25 ` Wu Fengguang
2005-11-10 6:50 ` Nick Piggin
2005-11-10 8:30 ` Wu Fengguang
2005-11-18 11:25 ` Wu Fengguang
2005-11-18 12:12 ` Wu Fengguang
2005-11-09 13:49 ` [PATCH 05/16] readahead: some preparation Wu Fengguang
2005-11-18 7:46 ` 2.6.15-rc1-mm2 Andrew Morton
2005-11-18 8:56 ` 2.6.15-rc1-mm2 Benoit Boissinot
2005-11-18 9:04 ` 2.6.15-rc1-mm2 Andrew Morton
2005-11-18 9:13 ` 2.6.15-rc1-mm2 Benoit Boissinot
2005-11-18 13:43 ` 2.6.15-rc1-mm2 Rafael J. Wysocki
2005-11-18 10:10 ` 2.6.15-rc1-mm2 Mauro Carvalho Chehab
2005-11-18 10:55 ` 2.6.15-rc1-mm2 Wu Fengguang
2005-11-18 11:29 ` 2.6.15-rc1-mm2 Andy Whitcroft
2005-11-18 16:29 ` 2.6.15-rc1-mm2 Michael Krufky
2005-11-20 0:23 ` 2.6.15-rc1-mm2 Michal Piotrowski
2005-11-20 8:04 ` 2.6.15-rc1-mm2 Hugh Dickins
2005-11-20 12:53 ` 2.6.15-rc1-mm2 Michal Piotrowski
2005-11-09 13:49 ` [PATCH 06/16] readahead: call scheme Wu Fengguang
2005-11-09 13:49 ` [PATCH 07/16] readahead: tunable parameters Wu Fengguang
2005-11-09 13:49 ` [PATCH 08/16] readahead: state based method Wu Fengguang
2005-11-09 13:49 ` [PATCH 09/16] readahead: context " Wu Fengguang
2005-11-09 13:49 ` [PATCH 10/16] readahead: other methods Wu Fengguang
2005-11-09 13:49 ` [PATCH 11/16] readahead: mandatory thrashing protection Wu Fengguang
2005-11-09 13:49 ` [PATCH 12/16] readahead: events accounting Wu Fengguang
2005-11-09 13:49 ` [PATCH 13/16] readahead: page aging accounting Wu Fengguang
2005-11-09 13:49 ` [PATCH 14/16] readahead: laptop mode support Wu Fengguang
2005-11-09 13:49 ` Wu Fengguang [this message]
2005-11-09 13:49 ` [PATCH 16/16] io: reduce lantency Wu Fengguang
2005-11-09 20:39 ` [PATCH 00/16] Adaptive read-ahead V7 Christoph Lameter
2005-11-10 10:19 ` 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=20051109141548.814311000@localhost.localdomain \
--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
all inboxes | Powered by JetHome®